diff options
Diffstat (limited to 'inc/collectd.inc.php')
-rw-r--r-- | inc/collectd.inc.php | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 5927bf6..74595aa 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php | |||
@@ -168,75 +168,6 @@ function plugin_sort($data) { | |||
168 | return $data; | 168 | return $data; |
169 | } | 169 | } |
170 | 170 | ||
171 | # generate graph url's for a plugin of a host | ||
172 | function graphs_from_plugin($host, $plugin, $overview=false) { | ||
173 | global $CONFIG; | ||
174 | |||
175 | if (!$plugindata = collectd_plugindata($host, $plugin)) | ||
176 | return false; | ||
177 | if (!$plugindata = group_plugindata($plugindata)) | ||
178 | return false; | ||
179 | if (!$plugindata = plugin_sort($plugindata)) | ||
180 | return false; | ||
181 | |||
182 | foreach ($plugindata as $items) { | ||
183 | |||
184 | if ( | ||
185 | $overview && isset($CONFIG['overview_filter'][$plugin]) && | ||
186 | $CONFIG['overview_filter'][$plugin] !== array_intersect_assoc($CONFIG['overview_filter'][$plugin], $items) | ||
187 | ) { | ||
188 | continue; | ||
189 | } | ||
190 | |||
191 | $items['h'] = $host; | ||
192 | |||
193 | $time = array_key_exists($plugin, $CONFIG['time_range']) | ||
194 | ? $CONFIG['time_range'][$plugin] | ||
195 | : $CONFIG['time_range']['default']; | ||
196 | |||
197 | if ($CONFIG['graph_type'] == 'canvas') { | ||
198 | chdir($CONFIG['webdir']); | ||
199 | isset($items['p']) ? $_GET['p'] = $items['p'] : $_GET['p'] = ''; | ||
200 | isset($items['pi']) ? $_GET['pi'] = $items['pi'] : $_GET['pi'] = ''; | ||
201 | isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = ''; | ||
202 | isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = ''; | ||
203 | include $CONFIG['webdir'].'/plugin/'.$plugin.'.php'; | ||
204 | } else { | ||
205 | printf('<a href="%s%s"><img src="%s%s"></a>'."\n", | ||
206 | $CONFIG['weburl'], | ||
207 | build_url('detail.php', $items, $time), | ||
208 | $CONFIG['weburl'], | ||
209 | build_url('graph.php', $items, $time) | ||
210 | ); | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | |||
215 | # generate an url with GET values from $items | ||
216 | function build_url($base, $items, $s=NULL) { | ||
217 | global $CONFIG; | ||
218 | |||
219 | if (!is_array($items)) | ||
220 | return false; | ||
221 | |||
222 | if (!is_numeric($s)) | ||
223 | $s = $CONFIG['time_range']['default']; | ||
224 | |||
225 | $i=0; | ||
226 | foreach ($items as $key => $value) { | ||
227 | # don't include empty values | ||
228 | if ($value == 'NULL') | ||
229 | continue; | ||
230 | |||
231 | $base .= sprintf('%s%s=%s', $i==0 ? '?' : '&', $key, $value); | ||
232 | $i++; | ||
233 | } | ||
234 | if (!isset($items['s'])) | ||
235 | $base .= '&s='.$s; | ||
236 | |||
237 | return $base; | ||
238 | } | ||
239 | |||
240 | function socket_cmd($socket, $cmd) { | 171 | function socket_cmd($socket, $cmd) { |
241 | $r = fwrite($socket, $cmd, strlen($cmd)); | 172 | $r = fwrite($socket, $cmd, strlen($cmd)); |
242 | if ($r === false || $r != strlen($cmd)) { | 173 | if ($r === false || $r != strlen($cmd)) { |