From 89d25faf99365850e9de5b1f49d355cded111878 Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Sat, 24 Feb 2007 11:25:23 +0000 Subject: New page layout and UI for the rrd graphs. --- usr/local/www/status_rrd_graph.php | 229 +++++++++++++++++++++------------ usr/local/www/status_rrd_graph_img.php | 8 ++ 2 files changed, 158 insertions(+), 79 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php index 80311a7..0ba76f5 100755 --- a/usr/local/www/status_rrd_graph.php +++ b/usr/local/www/status_rrd_graph.php @@ -30,10 +30,20 @@ require("guiconfig.inc"); -if ($_GET['database']) { - $curdatabase = $_GET['database']; +if ($_GET['cat']) { + $curcat = $_GET['cat']; } else { - $curdatabase = "wan-traffic.rrd"; + $curcat = "system"; +} + +if ($_GET['option']) { + $curoption = $_GET['option']; +} else { + if($curcat == "system") { + $curoption = "states"; + } else { + $curoption = "wan"; + } } if ($_GET['style']) { @@ -42,96 +52,157 @@ if ($_GET['style']) { $curstyle = "inverse"; } -$pgtitle = gettext("Status: RRD Graphs"); -include("head.inc"); - $rrddbpath = "/var/db/rrd/"; /* XXX: (billm) do we have an exec() type function that does this type of thing? */ exec("cd $rrddbpath;/usr/bin/find -name *.rrd", $databases); rsort($databases); -/* Deduce a interface if possible and use the description */ -$curif = split("-", $curdatabase); -$curif = "$curif[0]"; -$friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif)); -$search = array("-", ".rrd", $curif); -$replace = array(" :: ", "", $friendly); -$prettydb = ucwords(str_replace($search, $replace, $curdatabase)); +$styles = array('inverse' => 'Inverse', + 'absolute' => 'Absolute'); -$styles = array('inverse' => 'Inverse', 'absolute' => 'Absolute'); +$pgtitle = gettext("Status: RRD Graphs"); +include("head.inc"); ?> -

-

-
- - - - -
- -
- $interval) { - PRINT "Analysis for $prettydb -- $interval
"; - PRINT "\n\"$prettydb

"; - } -} else { - PRINT "There is no database available to generate $prettydb from.
"; -} - -?> - -
- - + + + + + + + +
+
+ "> + "> + +
+
+ + + + + + \n"; + } else { + echo "There is no database available to generate $prettydb from."; + } + } + } + ?> + + + + + +

+ + + + + + + $interval) { + /* check which databases are valid for our category */ + foreach($databases as $curdatabase) { + if(! stristr($curdatabase, $curcat)) { + continue; + } + switch($curoption) { + case "outbound": + /* only show interfaces with a gateway */ + if(! stristr($curdatabase, $curoption)) { + continue 2; + } + break;; + case "allgraphs": + echo "\n"; + break;; + default: + /* just use the name here */ + if(! stristr($curdatabase, $curoption)) { + continue 2; + } + } + if((file_exists("{$rrddbpath}{$curdatabase}"))) { + echo "
\n"; + echo "\"$prettydb\n"; + echo "


\n"; + echo "
+ + +
+
+
diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php index 1e5e03d..d59eca2 100644 --- a/usr/local/www/status_rrd_graph_img.php +++ b/usr/local/www/status_rrd_graph_img.php @@ -169,6 +169,7 @@ if((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabas $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --vertical-label \"bits/sec\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ --height 200 --width 620 -x \"$scale\" \\ DEF:$curif-in_bytes=$rrddbpath$curdatabase:in:AVERAGE \\ @@ -212,6 +213,7 @@ elseif((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdat $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --vertical-label \"packets/sec\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ --height 200 --width 620 -x \"$scale\" \\ DEF:$curif-in_pps=$rrddbpath$curdatabase:in:AVERAGE \\ @@ -253,6 +255,7 @@ elseif((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdata $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --vertical-label \"states, ip\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ --height 200 --width 620 -x \"$scale\" \\ DEF:$curif-pfrate=$rrddbpath$curdatabase:pfrate:AVERAGE \\ @@ -306,6 +309,7 @@ elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curd $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --vertical-label \"utilization, number\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ --height 200 --width 620 -x \"$scale\" \\ DEF:user=$rrddbpath$curdatabase:user:AVERAGE \\ @@ -357,6 +361,7 @@ elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdata $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --vertical-label \"bits/sec\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ --height 200 --width 620 -x \"$scale\" \\"; if (!is_array($config['shaper']['queue'])) { @@ -402,6 +407,7 @@ elseif((strstr($curdatabase, "-queuesdrop.rrd")) && (file_exists("$rrddbpath$cur $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --vertical-label \"drops / sec\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ --height 200 --width 620 -x \"$scale\" \\"; if (!is_array($config['shaper']['queue'])) { @@ -447,6 +453,7 @@ elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdat $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --vertical-label \"ms / %\" \\ --height 200 --width 620 \\ -x \"$scale\" --lower-limit 0 \\ @@ -481,6 +488,7 @@ elseif((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdataba $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\ --start -$seconds -e -$average \\ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\ + --color SHADEA#eeeeee --color SHADEB#eeeeee \\ --vertical-label=\"Conn / Time, sec.\" \\ --height 200 --width 620 --no-gridfit \\ -x \"$scale\" --lower-limit 0 \\ -- cgit v1.1