From 84005a744d2d6073296ab3fe7d3aa670a0cfe61b Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 26 Jun 2010 17:03:43 +0200 Subject: default graph time range is now configurable (not only for uptime) --- conf/config.php | 3 ++- inc/collectd.inc.php | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/conf/config.php b/conf/config.php index cebdc39..fccd250 100644 --- a/conf/config.php +++ b/conf/config.php @@ -19,7 +19,8 @@ $CONFIG['rrdtool_opts'] = ''; $CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap'); # default plugins time range -$CONFIG['time_range'] = array('uptime' => 31536000); +$CONFIG['time_range']['default'] = 86400; +$CONFIG['time_range']['uptime'] = 31536000; # show load averages on overview page $CONFIG['showload'] = true; diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 4e5d0e4..f5769c0 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -130,7 +130,7 @@ function graphs_from_plugin($host, $plugin) { $time = array_key_exists($plugin, $CONFIG['time_range']) ? $CONFIG['time_range'][$plugin] - : 86400; + : $CONFIG['time_range']['default']; printf(''."\n", $CONFIG['weburl'], @@ -144,12 +144,14 @@ function graphs_from_plugin($host, $plugin) { } # generate an url with GET values from $items -function build_url($base, $items, $s=86400) { +function build_url($base, $items, $s=NULL) { + global $CONFIG; + if (!is_array($items)) return false; if (!is_numeric($s)) - return false; + $s = $CONFIG['time_range']['default']; $i=0; foreach ($items as $key => $value) { -- cgit v1.1