aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/html.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--inc/html.inc.php69
1 files changed, 68 insertions, 1 deletions
diff --git a/inc/html.inc.php b/inc/html.inc.php
index 01e7328..2bcbc3f 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -269,4 +269,71 @@ function breadcrumbs() {
269 return $path; 269 return $path;
270} 270}
271 271
272?> 272# generate graph url's for a plugin of a host
273function graphs_from_plugin($host, $plugin, $overview=false) {
274 global $CONFIG;
275
276 if (!$plugindata = collectd_plugindata($host, $plugin))
277 return false;
278 if (!$plugindata = group_plugindata($plugindata))
279 return false;
280 if (!$plugindata = plugin_sort($plugindata))
281 return false;
282
283 foreach ($plugindata as $items) {
284
285 if (
286 $overview && isset($CONFIG['overview_filter'][$plugin]) &&
287 $CONFIG['overview_filter'][$plugin] !== array_intersect_assoc($CONFIG['overview_filter'][$plugin], $items)
288 ) {
289 continue;
290 }
291
292 $items['h'] = $host;
293
294 $time = array_key_exists($plugin, $CONFIG['time_range'])
295 ? $CONFIG['time_range'][$plugin]
296 : $CONFIG['time_range']['default'];
297
298 if ($CONFIG['graph_type'] == 'canvas') {
299 chdir($CONFIG['webdir']);
300 isset($items['p']) ? $_GET['p'] = $items['p'] : $_GET['p'] = '';
301 isset($items['pi']) ? $_GET['pi'] = $items['pi'] : $_GET['pi'] = '';
302 isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = '';
303 isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = '';
304 include $CONFIG['webdir'].'/plugin/'.$plugin.'.php';
305 } else {
306 printf('<a href="%s%s"><img src="%s%s"></a>'."\n",
307 $CONFIG['weburl'],
308 build_url('detail.php', $items, $time),
309 $CONFIG['weburl'],
310 build_url('graph.php', $items, $time)
311 );
312 }
313 }
314}
315
316# generate an url with GET values from $items
317function build_url($base, $items, $s=NULL) {
318 global $CONFIG;
319
320 if (!is_array($items))
321 return false;
322
323 if (!is_numeric($s))
324 $s = $CONFIG['time_range']['default'];
325
326 $i=0;
327 foreach ($items as $key => $value) {
328 # don't include empty values
329 if ($value == 'NULL')
330 continue;
331
332 $base .= sprintf('%s%s=%s', $i==0 ? '?' : '&amp;', $key, $value);
333 $i++;
334 }
335 if (!isset($items['s']))
336 $base .= '&amp;s='.$s;
337
338 return $base;
339}