All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ##|+PRIV ##|*IDENT=page-status-rrdgraphs ##|*NAME=Status: RRD Graphs page ##|*DESCR=Allow access to the 'Status: RRD Graphs' page. ##|*MATCH=status_rrd_graph.php* ##|-PRIV require("guiconfig.inc"); /* if the rrd graphs are not enabled redirect to settings page */ if(! isset($config['rrd']['enable'])) { header("Location: status_rrd_graph_settings.php"); } if ($_GET['cat']) { $curcat = $_GET['cat']; } else { if(! empty($config['rrd']['category'])) { $curcat = $config['rrd']['category']; } else { $curcat = "system"; } } if ($_GET['option']) { $curoption = $_GET['option']; } else { if($curcat == "system") { $curoption = "processor"; } else if($curcat == "queues") { $curoption = "queues"; } else if($curcat == "queuedrops") { $curoption = "queuedrops"; } else { $curoption = "wan"; } } if ($_GET['style']) { $curstyle = $_GET['style']; } else { if(! empty($config['rrd']['style'])) { $curstyle = $config['rrd']['style']; } else { $curstyle = "inverse"; } } $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); /* these boilerplate databases are required for the other menu choices */ $dbheader = array("allgraphs-traffic.rrd", "allgraphs-quality.rrd", "allgraphs-wireless.rrd", "allgraphs-packets.rrd", "system-allgraphs.rrd", "system-throughput.rrd", "outbound-quality.rrd", "outbound-packets.rrd", "outbound-traffic.rrd"); /* append the existing array to the header */ $databases = array_merge($dbheader, $databases); $styles = array('inverse' => 'Inverse', 'absolute' => 'Absolute'); $periods = array("4h", "16h", "48h", "32d", "6m", "1y", "4y"); $pgtitle = array("Status","RRD Graphs"); include("head.inc"); ?>
">
\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(! preg_match("/($curcat)/i", $curdatabase)) { continue; } $optionc = split("-", $curdatabase); $search = array("-", ".rrd", $optionc); $replace = array(" :: ", "", $friendly); switch($curoption) { case "outbound": /* only show interfaces with a gateway */ $optionc = "$optionc[0]"; if(!interface_has_gateway($optionc)) { continue 2; } if(! preg_match("/($optionc)[-.]/i", $curdatabase)) { continue 2; } break; case "allgraphs": /* make sure we do not show the placeholder databases in the all view */ if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { continue 2; } break; default: /* just use the name here */ if(! preg_match("/($curoption)[-.]/i", $curdatabase)) { continue 2; } } if(in_array($curdatabase, $databases)) { echo "
\n"; echo "\"$prettydb\n"; echo "


\n"; echo "