From b1f866709a3ce30678e183e08d424247e761ca44 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Tue, 29 Sep 2009 22:07:01 +0200 Subject: make width and heigth of graphs configurable These configuration options have been added: - width - heigth - detail-width - detail-heigth --- conf/config.php | 7 +++++++ detail.php | 6 ++++++ graph.php | 4 ++-- inc/collectd.inc.php | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/conf/config.php b/conf/config.php index 16a2d34..cbddfb3 100644 --- a/conf/config.php +++ b/conf/config.php @@ -5,6 +5,13 @@ $CONFIG['datadir'] = '/var/lib/collectd/rrd'; #$CONFIG['cat']['nethuis'] = array('pepper'); $CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap'); +# default width/height of the graphs +$CONFIG['width'] = 400; +$CONFIG['heigth'] = 175; +# default width/height of detailed graphs +$CONFIG['detail-width'] = 800; +$CONFIG['detail-heigth'] = 350; + $CONFIG['groupby'] = array( 'cpu' => 'type', 'irq' => 'type', diff --git a/detail.php b/detail.php index d8bd4eb..47ce197 100644 --- a/detail.php +++ b/detail.php @@ -4,6 +4,12 @@ require_once 'conf/common.inc.php'; require_once 'inc/html.inc.php'; require_once 'inc/collectd.inc.php'; +# use width/height from config if nothing is given +if (empty($_GET['x'])) + $_GET['x'] = $CONFIG['detail-width']; +if (empty($_GET['y'])) + $_GET['y'] = $CONFIG['detail-heigth']; + $host = $_GET['h']; $plugin = $_GET['p']; $pinstance = $_GET['pi']; diff --git a/graph.php b/graph.php index 4747552..cc3aeb1 100644 --- a/graph.php +++ b/graph.php @@ -7,8 +7,8 @@ $plugin = $_GET['p']; $pinstance = $_GET['pi']; $type = $_GET['t']; $tinstance = $_GET['ti']; -$width = $_GET['x']; -$heigth = $_GET['y']; +$width = empty($_GET['x']) ? $CONFIG['width'] : $_GET['x']; +$heigth = empty($_GET['y']) ? $CONFIG['heigth'] : $_GET['y']; $seconds = $_GET['s']; if (!preg_match('/^[a-z]+$/', $plugin)) { diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 2724c05..306086a 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -123,7 +123,7 @@ function graphs_from_plugin($host, $plugin) { ); printf(''."\n", $CONFIG['weburl'], - build_url('detail.php', $items).'&x=800&y=350', + build_url('detail.php', $items), $CONFIG['weburl'], build_url('graph.php', $items) ); @@ -140,7 +140,7 @@ function graphs_from_plugin($host, $plugin) { ); printf(''."\n", $CONFIG['weburl'], - build_url('detail.php', $items).'&x=800&y=350', + build_url('detail.php', $items), $CONFIG['weburl'], build_url('graph.php', $items) ); -- cgit v1.1