summaryrefslogtreecommitdiffstats
path: root/usr/local/www/status_rrd_graph.php
diff options
context:
space:
mode:
Diffstat (limited to 'usr/local/www/status_rrd_graph.php')
-rwxr-xr-xusr/local/www/status_rrd_graph.php221
1 files changed, 154 insertions, 67 deletions
diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php
index 115d12c..97454c9 100755
--- a/usr/local/www/status_rrd_graph.php
+++ b/usr/local/www/status_rrd_graph.php
@@ -3,7 +3,7 @@
/*
status_rrd_graph.php
Part of pfSense
- Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>
+ Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,6 @@
POSSIBILITY OF SUCH DAMAGE.
*/
/*
- pfSense_BUILDER_BINARIES: /usr/bin/find
pfSense_MODULE: system
*/
@@ -50,8 +49,9 @@ if(! isset($config['rrd']['enable'])) {
}
$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);
+chdir($rrddbpath);
+$databases = glob("*.rrd");
+
if ($_GET['cat']) {
$curcat = $_GET['cat'];
@@ -109,12 +109,46 @@ if ($_GET['option']) {
continue 2;
}
}
+ case "vpnusers":
+ foreach($databases as $database) {
+ if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
+ /* pick off the 1st database we find that matches the VPN graphs */
+ $name = explode("-", $database);
+ $curoption = "$name[0]";
+ continue 2;
+ }
+ }
default:
$curoption = "wan";
break;
}
}
+$now = time();
+if($curcat == "custom") {
+ if (is_numeric($_GET['start'])) {
+ if($start < ($now - (3600 * 24 * 365 * 5))) {
+ $start = $now - (4 * 3600);
+ }
+ $start = $_GET['start'];
+ } else {
+ $start = $now - (4 * 3600);
+ }
+}
+
+if (is_numeric($_GET['end'])) {
+ $end = $_GET['end'];
+} else {
+ $end = $now;
+}
+
+/* this should never happen */
+if($end < $start) {
+ $end = $now;
+}
+
+$seconds = $end - $start;
+
if ($_GET['style']) {
$curstyle = $_GET['style'];
} else {
@@ -133,6 +167,7 @@ $dbheader = array("allgraphs-traffic.rrd",
"allgraphs-quality.rrd",
"allgraphs-wireless.rrd",
"allgraphs-cellular.rrd",
+ "allgraphs-vpnusers.rrd",
"allgraphs-packets.rrd",
"system-allgraphs.rrd",
"system-throughput.rrd",
@@ -141,15 +176,18 @@ $dbheader = array("allgraphs-traffic.rrd",
"outbound-traffic.rrd");
foreach($databases as $database) {
- if(stristr($database, "wireless")) {
+ if(stristr($database, "-wireless")) {
$wireless = true;
}
- if(stristr($database, "queues")) {
+ if(stristr($database, "-queues")) {
$queues = true;
}
- if(stristr($database, "cellular")) {
+ if(stristr($database, "-cellular")) {
$cellular = true;
}
+ if(stristr($database, "-vpnusers")) {
+ $vpnusers = true;
+ }
}
/* append the existing array to the header */
$ui_databases = array_merge($dbheader, $databases);
@@ -168,7 +206,7 @@ function get_dates($curperiod, $graph) {
$curyear = date('Y', $now);
$curmonth = date('m', $now);
$curweek = date('W', $now);
- $curweekday = date('w', $now);
+ $curweekday = date('N', $now) - 1; // We want to start on monday
$curday = date('d', $now);
switch($curperiod) {
@@ -184,8 +222,16 @@ function get_dates($curperiod, $graph) {
$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
break;
case "week":
- $start = mktime(0, 0, 0, $curmonth, (($curday + $curweekday) - $offset), $curyear);
- $end = mktime(0, 0, 0, $curmonth, (($curday + $curweekday) + 7), $curyear);
+ switch($offset) {
+ case 0;
+ $weekoffset = 0;
+ break;
+ default:
+ $weekoffset = ($offset * 7) - 7;
+ break;
+ }
+ $start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
+ $end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
break;
case "month":
$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
@@ -232,9 +278,9 @@ function get_dates($curperiod, $graph) {
$tab_array[] = array("Quality", $tabactive, "status_rrd_graph.php?cat=quality");
if($queues) {
if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
- $tab_array[] = array("Queues", $tabactive, "status_rrd_graph.php?cat=queues");
+ $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");
+ $tab_array[] = array("QueueDrops", $tabactive, "status_rrd_graph.php?cat=queuedrops");
}
if($wireless) {
if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
@@ -244,6 +290,12 @@ function get_dates($curperiod, $graph) {
if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
$tab_array[] = array("Cellular", $tabactive, "status_rrd_graph.php?cat=cellular");
}
+ if($vpnusers) {
+ if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
+ $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
+ }
+ if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
+ $tab_array[] = array("Custom", $tabactive, "status_rrd_graph.php?cat=custom");
if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
$tab_array[] = array("Settings", $tabactive, "status_rrd_graph_settings.php");
display_top_tabs($tab_array);
@@ -263,6 +315,19 @@ function get_dates($curperiod, $graph) {
<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
<?php
+ if($curcat == "custom") {
+ foreach ($databases as $db => $database) {
+ $optionc = split("-", $database);
+ $search = array("-", ".rrd", $optionc);
+ $replace = array(" :: ", "", $friendly);
+ echo "<option value=\"{$database}\"";
+ $prettyprint = ucwords(str_replace($search, $replace, $database));
+ if($curoption == $database) {
+ echo " selected ";
+ }
+ echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
+ }
+ }
foreach ($ui_databases as $db => $database) {
if(! preg_match("/($curcat)/i", $database)) {
continue;
@@ -270,11 +335,12 @@ function get_dates($curperiod, $graph) {
$optionc = split("-", $database);
$search = array("-", ".rrd", $optionc);
$replace = array(" :: ", "", $friendly);
+
switch($curcat) {
case "system":
- $optionc = str_replace($search, $replace, $optionc[1]);
- echo "<option value=\"$optionc\"";
- $prettyprint = ucwords(str_replace($search, $replace, $optionc));
+ $optioncf = str_replace($search, $replace, $optionc[1]);
+ echo "<option value=\"$optioncf\"";
+ $prettyprint = ucwords(str_replace($search, $replace, $optioncf));
break;
default:
/* Deduce a interface if possible and use the description */
@@ -308,65 +374,86 @@ function get_dates($curperiod, $graph) {
?>
</select>
- <?=gettext("Period:");?>
- <select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
- <?php
- foreach ($periods as $period => $value) {
- echo "<option value=\"$period\"";
- if ($period == $curperiod) echo " selected";
- echo ">" . htmlspecialchars($value) . "</option>\n";
+ <?
+ if($curcat <> "custom") {
+ ?>
+ <?=gettext("Period:");?>
+ <select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
+ <?php
+ foreach ($periods as $period => $value) {
+ echo "<option value=\"$period\"";
+ if ($period == $curperiod) echo " selected";
+ echo ">" . htmlspecialchars($value) . "</option>\n";
+ }
}
?>
-
</select>
-
<?php
- // echo "year $curyear, month $curmonth, week $curweek, day $curday, weekday $curweekday<br>";
- foreach($graphs as $graph) {
- /* check which databases are valid for our category */
- foreach($ui_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)) {
- if(!preg_match("/($optionc)-(quality)/", $curdatabase)) {
+ if($curcat == "custom") {
+ ?>
+ <?=gettext("Start:");?>
+ <input type="text" name="start" class="formfldunknown" length="32" value="<?php echo $start;?>">
+ <?=gettext("End:");?>
+ <input type="text" name="end" class="formfldunknown" length="32" value="<?php echo $now;?>">
+ <input type="submit" name="Submit" value="Go">
+ <?
+ $curdatabase = $curoption;
+ $graph = "custom-$curdatabase";
+ if(in_array($curdatabase, $databases)) {
+ echo "<tr><td colspan=2 class=\"list\">\n";
+ echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
+ echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
+ echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
+ echo "<br /><hr><br />\n";
+ echo "</td></tr>\n";
+ }
+ } else {
+ foreach($graphs as $graph) {
+ /* check which databases are valid for our category */
+ foreach($ui_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)) {
+ if(!preg_match("/($optionc)-(quality)/", $curdatabase)) {
+ continue 2;
+ }
+ }
+ if(! preg_match("/($optionc)[-.]/i", $curdatabase)) {
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)) {
- $dates = get_dates($curperiod, $graph);
- $start = $dates['start'];
- $end = $dates['end'];
- echo "<tr><td colspan=2 class=\"list\">\n";
- echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
- echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
- echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
- echo "<br /><hr><br />\n";
- echo "</td></tr>\n";
+ 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)) {
+ $dates = get_dates($curperiod, $graph);
+ $start = $dates['start'];
+ $end = $dates['end'];
+ echo "<tr><td colspan=2 class=\"list\">\n";
+ echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
+ echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
+ echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
+ echo "<br /><hr><br />\n";
+ echo "</td></tr>\n";
+ }
}
}
}
OpenPOWER on IntegriCloud