From 7432ce7b8d9d90a0b7ad3910c34e3b50d76c4440 Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Sun, 3 Jan 2010 20:08:58 +0100 Subject: Add more smarts to the RRD page, do not show tabs for database that do not exist, pick the 1st database for wireless, cellular. --- usr/local/www/status_rrd_graph.php | 68 +++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 16 deletions(-) (limited to 'usr/local/www/status_rrd_graph.php') diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php index 618f69b..f7b5b25 100755 --- a/usr/local/www/status_rrd_graph.php +++ b/usr/local/www/status_rrd_graph.php @@ -75,15 +75,34 @@ if ($_GET['option']) { break; case "queuedrops": $curoption = "queuedrops"; - case "quality": - foreach($databases as $database) { - if(preg_match("/[-]quality\.rrd/i", $database)) { - /* pick off the 1st database we find that matches the quality graph */ - $name = explode("-", $database); - $curoption = "$name[0]"; - continue 2; + break; + case "quality": + foreach($databases as $database) { + if(preg_match("/[-]quality\.rrd/i", $database)) { + /* pick off the 1st database we find that matches the quality graph */ + $name = explode("-", $database); + $curoption = "$name[0]"; + continue 2; + } + } + case "wireless": + foreach($databases as $database) { + if(preg_match("/[-]wireless\.rrd/i", $database)) { + /* pick off the 1st database we find that matches the wireless graph */ + $name = explode("-", $database); + $curoption = "$name[0]"; + continue 2; + } + } + case "cellular": + foreach($databases as $database) { + if(preg_match("/[-]cellular\.rrd/i", $database)) { + /* pick off the 1st database we find that matches the celullar graph */ + $name = explode("-", $database); + $curoption = "$name[0]"; + continue 2; + } } - } default: $curoption = "wan"; break; @@ -115,6 +134,17 @@ $dbheader = array("allgraphs-traffic.rrd", "outbound-packets.rrd", "outbound-traffic.rrd"); +foreach($databases as $database) { + if(stristr($database, "wireless")) { + $wireless = true; + } + if(stristr($database, "queues")) { + $queues = true; + } + if(stristr($database, "cellular")) { + $cellular = true; + } +} /* append the existing array to the header */ $ui_databases = array_merge($dbheader, $databases); @@ -143,14 +173,20 @@ include("head.inc"); $tab_array[] = array("Packets", $tabactive, "status_rrd_graph.php?cat=packets"); if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; } $tab_array[] = array("Quality", $tabactive, "status_rrd_graph.php?cat=quality"); - if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("Queues", $tabactive, "status_rrd_graph.php?cat=queues"); - if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("QueueDrops", $tabactive, "status_rrd_graph.php?cat=queuedrops"); - if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("Wireless", $tabactive, "status_rrd_graph.php?cat=wireless"); - if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("Cellular", $tabactive, "status_rrd_graph.php?cat=cellular"); + if($queues) { + if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; } + $tab_array[] = array("Queues", $tabactive, "status_rrd_graph.php?cat=queues"); + if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; } + $tab_array[] = array("QueueDrops", $tabactive, "status_rrd_graph.php?cat=queuedrops"); + } + if($wireless) { + if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; } + $tab_array[] = array("Wireless", $tabactive, "status_rrd_graph.php?cat=wireless"); + } + if($cellular) { + if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; } + $tab_array[] = array("Cellular", $tabactive, "status_rrd_graph.php?cat=cellular"); + } if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; } $tab_array[] = array("Settings", $tabactive, "status_rrd_graph_settings.php"); display_top_tabs($tab_array); -- cgit v1.1