summaryrefslogtreecommitdiffstats
path: root/usr/local/www/status_rrd_graph.php
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2006-11-22 17:47:36 +0000
committerSeth Mos <seth.mos@xs4all.nl>2006-11-22 17:47:36 +0000
commit6ab7ae508a026c9a0fa906d3a274a9efc7adfe75 (patch)
tree9a11da22755935484cdd5dd0030c755e70595887 /usr/local/www/status_rrd_graph.php
parent09da8bfab1063df6e50aa0a9a51c1b0a851c06d1 (diff)
downloadpfsense-6ab7ae508a026c9a0fa906d3a274a9efc7adfe75.zip
pfsense-6ab7ae508a026c9a0fa906d3a274a9efc7adfe75.tar.gz
Merge newer rrd graphing code, drop down now only lists valid rrd
targets. Added CPU and States graphs. More logging in case of graph generation. Minor bugfixes and cleanup.
Diffstat (limited to 'usr/local/www/status_rrd_graph.php')
-rwxr-xr-xusr/local/www/status_rrd_graph.php110
1 files changed, 54 insertions, 56 deletions
diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php
index b40f23b..80311a7 100755
--- a/usr/local/www/status_rrd_graph.php
+++ b/usr/local/www/status_rrd_graph.php
@@ -3,11 +3,7 @@
/*
status_rrd_graph.php
Part of pfSense
- Copyright (C) 2004 Scott Ullrich
- All rights reserved.
-
- Originally part of m0n0wall (http://m0n0.ch/wall)
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ Copyright (C) 2006 Seth Mos <seth.mos@xs4all.nl>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,88 +30,90 @@
require("guiconfig.inc");
-function gettext($text) {
- return $text;
-}
-if ($_GET['if']) {
- $curif = $_GET['if'];
- $ifnum = $config['interfaces'][$curif]['if'];
+if ($_GET['database']) {
+ $curdatabase = $_GET['database'];
} else {
- $curif = "wan";
+ $curdatabase = "wan-traffic.rrd";
}
-if ($_GET['graph']) {
- $curgraph = $_GET['graph'];
+if ($_GET['style']) {
+ $curstyle = $_GET['style'];
} else {
- $curgraph = "traffic";
+ $curstyle = "inverse";
}
$pgtitle = gettext("Status: RRD Graphs");
include("head.inc");
$rrddbpath = "/var/db/rrd/";
-$traffic = "-traffic.rrd";
-$quality = "-quality.rrd";
-$queues = "-queues.rrd";
-$queuesdrop = "-queuesdrop.rrd";
-$packets = "-packets.rrd";
-$spamd = "spamd.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');
+
+?>
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<p class="pgtitle"><?=$pgtitle?></p>
+<p><b><?=gettext("Note: Change of color and/or style may not take effect until the next
+refresh");?></b></p>
+<form name="form1" action="status_rrd_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid #999999">
+<?=gettext("Graphs:");?>
+<select name="database" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
<?php
-$ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
-$graphs = array('traffic' => 'Traffic', 'quality' => 'Quality', 'queues' => 'Queues', 'packets' => 'Packets', 'spamd' => 'Spamd');
-
-for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- if(isset($config['interfaces']['opt' . $j]['enable'])) {
- $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
- }
-}
-?>
-<form name="form1" action="status_rrd_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px;
-border-bottom: 1px solid #999999">
-<?=gettext("Interface:");?>
-<select name="if" class="formfld" style="z-index: -10;" onchange="document.form1.submit()">
-<?php
-foreach ($ifdescrs as $ifn => $ifd) {
- echo "<option value=\"$ifn\"";
- if ($ifn == $curif) echo " selected";
- echo ">" . htmlspecialchars($ifd) . "</option>\n";
+foreach ($databases as $db => $database) {
+ echo "<option value=\"$database\"";
+ if ($database == $curdatabase) echo " selected";
+ /* Deduce a interface if possible and use the description */
+ $curif = split("-", $database);
+ $curif = "$curif[0]";
+ $friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif));
+ $search = array("-", ".rrd", $curif);
+ $replace = array(" :: ", "", $friendly);
+ $prettyprint = ucwords(str_replace($search, $replace, $database));
+ echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
}
?>
</select>
-<?=gettext("Graph:");?>
-<select name="graph" class="formfld" style="z-index: -10;" onchange="document.form1.submit()">
+<?=gettext("Style:");?>
+<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
<?php
-foreach ($graphs as $graph => $graphd) {
- echo "<option value=\"$graph\"";
- if ($graph == $curgraph) echo " selected";
- echo ">" . htmlspecialchars($graphd) . "</option>\n";
+foreach ($styles as $style => $styled) {
+ echo "<option value=\"$style\"";
+ if ($style == $curstyle) echo " selected";
+ echo ">" . htmlspecialchars($styled) . "</option>\n";
}
?>
</select>
</form>
-<p>
-<div>
+
+<div style="text-align: center;">
<?php
-$periods = array("2h", "6h", "48h", "14d", "2m", "18m");
+$periods = array("4h", "16h", "48h", "32d", "6m", "16m");
-if((file_exists("{$rrddbpath}{$curif}-{$curgraph}.rrd")) or (file_exists("{$rrddbpath}{$curgraph}.rrd"))) {
+if((file_exists("{$rrddbpath}{$curdatabase}"))) {
foreach($periods as $period => $interval) {
- PRINT "<B>Analysis for $curif -- $interval $curgraph</B><BR>";
- PRINT "\n<IMG BORDER='1' name='{$curif}-{$interval}-{$curgraph}' id='{$curif}-{$interval}-{$curgraph}' ALT=\"$ifname $curgraph Graph\" SRC=\"status_rrd_graph_img.php?if=$curif&interval=$interval&graph=$curgraph&style={$curstyle}&color={$curcolor}\"><BR><BR>";
+ PRINT "<B>Analysis for $prettydb -- $interval</B><br />";
+ PRINT "\n<IMG BORDER='1' name='{$interval}-{$curif}' id='{$interval}-{$curif}' ALT=\"$prettydb Graph\" SRC=\"status_rrd_graph_img.php?interval=$interval&amp;database={$curdatabase}&amp;style={$curstyle}\" /><br /><br />";
}
} else {
- PRINT "<b>There is no database available to generate $curgraph from.</b><br>";
+ PRINT "<b>There is no database available to generate $prettydb from.</b><br />";
}
+
?>
</div>
@@ -127,9 +125,9 @@ if((file_exists("{$rrddbpath}{$curif}-{$curgraph}.rrd")) or (file_exists("{$rrdd
<?php
/* generate update events utilizing prototype $('') feature */
echo "\n";
- foreach($periods as $period => $interval)
- echo "\t\t\$('{$curif}-{$interval}-{$curgraph}').src='status_rrd_graph_img.php?if={$curif}&interval={$interval}&graph={$curgraph}&tmp=' + randomid;\n";
- ?>
+ foreach($periods as $period => $interval)
+ echo "\t\t\$('{$interval}-{$curif}').src='status_rrd_graph_img.php?interval={$interval}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid;\n";
+ ?>
window.setTimeout('update_graph_images()', 355000);
}
window.setTimeout('update_graph_images()', 355000);
OpenPOWER on IntegriCloud