diff options
author | Renato Botelho <garga@FreeBSD.org> | 2015-05-15 08:02:55 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2015-05-15 08:02:55 -0300 |
commit | 83c380c3eb0ee38f591a455aabee40d0a543bb95 (patch) | |
tree | 02c0a29ccef3707ebbd554d7f124580d81c3ac0e | |
parent | 0922c015b52674bb18b93ca03bd1cb7726b0568d (diff) | |
parent | 38145b9bbf3fac089270641d9c8fde351c8842e4 (diff) | |
download | pfsense-83c380c3eb0ee38f591a455aabee40d0a543bb95.zip pfsense-83c380c3eb0ee38f591a455aabee40d0a543bb95.tar.gz |
Merge pull request #1660 from phil-davis/www-status-rrd
-rw-r--r-- | usr/local/www/status_rrd_graph.php | 825 | ||||
-rw-r--r-- | usr/local/www/status_rrd_graph_img.php | 262 | ||||
-rw-r--r-- | usr/local/www/status_rrd_graph_settings.php | 341 |
3 files changed, 778 insertions, 650 deletions
diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php index e64cf72..94111bc 100644 --- a/usr/local/www/status_rrd_graph.php +++ b/usr/local/www/status_rrd_graph.php @@ -28,7 +28,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: system */ @@ -47,7 +47,7 @@ require_once("rrd.inc"); unset($input_errors); /* if the rrd graphs are not enabled redirect to settings page */ -if(! isset($config['rrd']['enable'])) { +if (! isset($config['rrd']['enable'])) { header("Location: status_rrd_graph_settings.php"); } @@ -59,22 +59,23 @@ $databases = glob("*.rrd"); if ($_GET['cat']) { $curcat = htmlspecialchars($_GET['cat']); } else { - if(! empty($config['rrd']['category'])) { + if (! empty($config['rrd']['category'])) { $curcat = $config['rrd']['category']; } else { $curcat = "system"; } } -if ($_GET['zone']) +if ($_GET['zone']) { $curzone = $_GET['zone']; -else +} else { $curzone = ''; +} if ($_GET['period']) { $curperiod = $_GET['period']; } else { - if(! empty($config['rrd']['period'])) { + if (! empty($config['rrd']['period'])) { $curperiod = $config['rrd']['period']; } else { $curperiod = "absolute"; @@ -84,7 +85,7 @@ if ($_GET['period']) { if ($_GET['option']) { $curoption = $_GET['option']; } else { - switch($curcat) { + switch ($curcat) { case "system": $curoption = "processor"; break; @@ -95,8 +96,8 @@ if ($_GET['option']) { $curoption = "queuedrops"; break; case "quality": - foreach($databases as $database) { - if(preg_match("/[-]quality\.rrd/i", $database)) { + 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]"; @@ -104,8 +105,8 @@ if ($_GET['option']) { } } case "wireless": - foreach($databases as $database) { - if(preg_match("/[-]wireless\.rrd/i", $database)) { + 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]"; @@ -113,8 +114,8 @@ if ($_GET['option']) { } } case "cellular": - foreach($databases as $database) { - if(preg_match("/[-]cellular\.rrd/i", $database)) { + 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]"; @@ -122,8 +123,8 @@ if ($_GET['option']) { } } case "vpnusers": - foreach($databases as $database) { - if(preg_match("/[-]vpnusers\.rrd/i", $database)) { + 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]"; @@ -134,7 +135,7 @@ if ($_GET['option']) { $curoption = "allgraphs"; break; case "ntpd": - if(isset($config['ntpd']['statsgraph'])) { + if (isset($config['ntpd']['statsgraph'])) { $curoption = "allgraphs"; } else { $curoption = "processor"; @@ -148,9 +149,9 @@ if ($_GET['option']) { } $now = time(); -if($curcat == "custom") { +if ($curcat == "custom") { if (is_numeric($_GET['start'])) { - if($start < ($now - (3600 * 24 * 365 * 5))) { + if ($start < ($now - (3600 * 24 * 365 * 5))) { $start = $now - (8 * 3600); } $start = $_GET['start']; @@ -166,7 +167,7 @@ if($curcat == "custom") { } if (is_numeric($_GET['end'])) { - $end = $_GET['end']; + $end = $_GET['end']; } else if ($_GET['end']) { $end = strtotime($_GET['end']); if ($end === FALSE || $end === -1) { @@ -174,29 +175,30 @@ if (is_numeric($_GET['end'])) { $end = $now; } } else { - $end = $now; + $end = $now; } /* this should never happen */ -if($end < $start) { +if ($end < $start) { log_error("start $start is smaller than end $end"); - $end = $now; + $end = $now; } $seconds = $end - $start; $styles = array('inverse' => gettext('Inverse'), - 'absolute' => gettext('Absolute')); + 'absolute' => gettext('Absolute')); // Set default and override later $curstyle = "inverse"; if ($_GET['style']) { - foreach($styles as $style) - if(strtoupper($style) == strtoupper($_GET['style'])) + foreach ($styles as $style) + if (strtoupper($style) == strtoupper($_GET['style'])) { $curstyle = $_GET['style']; + } } else { - if(! empty($config['rrd']['style'])) { + if (! empty($config['rrd']['style'])) { $curstyle = $config['rrd']['style']; } else { $curstyle = "inverse"; @@ -208,37 +210,37 @@ rsort($databases); /* these boilerplate databases are required for the other menu choices */ $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", - "outbound-quality.rrd", - "outbound-packets.rrd", - "outbound-traffic.rrd"); + "allgraphs-quality.rrd", + "allgraphs-wireless.rrd", + "allgraphs-cellular.rrd", + "allgraphs-vpnusers.rrd", + "allgraphs-packets.rrd", + "system-allgraphs.rrd", + "system-throughput.rrd", + "outbound-quality.rrd", + "outbound-packets.rrd", + "outbound-traffic.rrd"); /* additional menu choices for the custom tab */ $dbheader_custom = array("system-throughput.rrd"); -foreach($databases as $database) { - if(stristr($database, "-wireless")) { +foreach ($databases as $database) { + if (stristr($database, "-wireless")) { $wireless = true; } - if(stristr($database, "-queues")) { + if (stristr($database, "-queues")) { $queues = true; } - if(stristr($database, "-cellular") && !empty($config['ppps'])) { + if (stristr($database, "-cellular") && !empty($config['ppps'])) { $cellular = true; } - if(stristr($database, "-vpnusers")) { + if (stristr($database, "-vpnusers")) { $vpnusers = true; } - if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) { + if (stristr($database, "captiveportal-") && is_array($config['captiveportal'])) { $captiveportal = true; } - if(stristr($database, "ntpd") && isset($config['ntpd']['statsgraph'])) { + if (stristr($database, "ntpd") && isset($config['ntpd']['statsgraph'])) { $ntpd = true; } } @@ -264,9 +266,10 @@ $closehead = false; /* Load all CP zones */ if ($captiveportal && is_array($config['captiveportal'])) { $cp_zones_tab_array = array(); - foreach($config['captiveportal'] as $cpkey => $cp) { - if (!isset($cp['enable'])) + foreach ($config['captiveportal'] as $cpkey => $cp) { + if (!isset($cp['enable'])) { continue; + } if ($curzone == '') { $tabactive = true; @@ -314,7 +317,7 @@ function get_dates($curperiod, $graph) { $now = time(); $end = $now; - if($curperiod == "absolute") { + if ($curperiod == "absolute") { $start = $end - $graph_length[$graph]; } else { $curyear = date('Y', $now); @@ -324,23 +327,26 @@ function get_dates($curperiod, $graph) { $curday = date('d', $now); $curhour = date('G', $now); - switch($curperiod) { + switch ($curperiod) { case "previous": $offset = -1; break; default: $offset = 0; } - switch($graph) { + switch ($graph) { case "eighthour": - if($curhour < 24) + if ($curhour < 24) { $starthour = 16; - if($curhour < 16) + } + if ($curhour < 16) { $starthour = 8; - if($curhour < 8) + } + if ($curhour < 8) { $starthour = 0; + } - switch($offset) { + switch ($offset) { case 0: $houroffset = $starthour; break; @@ -349,17 +355,18 @@ function get_dates($curperiod, $graph) { break; } $start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear); - if($offset != 0) { + if ($offset != 0) { $end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear); } break; case "day": $start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear); - if($offset != 0) + if ($offset != 0) { $end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear); + } break; case "week": - switch($offset) { + switch ($offset) { case 0: $weekoffset = 0; break; @@ -368,28 +375,33 @@ function get_dates($curperiod, $graph) { break; } $start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear); - if($offset != 0) + if ($offset != 0) { $end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear); + } break; case "month": $start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear); - if($offset != 0) + if ($offset != 0) { $end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear); + } break; case "quarter": $start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear); - if($offset != 0) + if ($offset != 0) { $end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear); + } break; case "year": $start = mktime(0, 0, 0, 1, 0, ($curyear + $offset)); - if($offset != 0) + if ($offset != 0) { $end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1)); + } break; case "fouryear": $start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset)); - if($offset != 0) + if ($offset != 0) { $end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1)); + } break; } } @@ -406,348 +418,415 @@ function get_dates($curperiod, $graph) { <?php include("fbegin.inc"); ?> <?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?> <form name="form1" action="status_rrd_graph.php" method="get"> -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graphs"> - <tr> - <td> - <input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" /> - <?php - $tab_array = array(); - if($curcat == "system") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system"); - if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic"); - if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets"); - if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality"); - if($queues) { - if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; } + <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graphs"> + <tr> + <td> + <input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" /> + <?php + $tab_array = array(); + if ($curcat == "system") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system"); + if ($curcat == "traffic") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic"); + if ($curcat == "packets") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets"); + if ($curcat == "quality") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality"); + if ($queues) { + if ($curcat == "queues") { + $tabactive = True; + } else { + $tabactive = False; + } $tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues"); - if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops"); - } - if($wireless) { - if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless"); - } - if($cellular) { - if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("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($captiveportal) { - if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal"); - } - if($ntpd) { - if($curcat == "ntpd") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd"); - } - if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); - if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php"); - display_top_tabs($tab_array); - ?> - </td> - </tr> - <?php if ($curcat == "captiveportal") : ?> - <tr> - <td class="tabnavtbl"> - <?php display_top_tabs($cp_zones_tab_array); ?> - </td> - </tr> - <?php endif; ?> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area"> - <tr> - <td colspan="2" class="list"><p><b><?=gettext("Note: Change of color and/or style may not take effect until the next refresh");?></b></p></td> - </tr> - <tr> - <td colspan="2" class="list"> - <?=gettext("Graphs:");?> - <?php if (!empty($curzone)): ?> - <input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" /> - <?php endif; ?> - <select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> - <?php - - if($curcat == "custom") { - foreach ($custom_databases as $db => $database) { - $optionc = explode("-", $database); - $friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0])); - if (empty($friendly)) { - $friendly = $optionc[0]; - } - $search = array("-", ".rrd", $optionc[0]); - $replace = array(" :: ", "", $friendly); - echo "<option value=\"{$database}\""; - $prettyprint = ucwords(str_replace($search, $replace, $database)); - if($curoption == $database) { - echo " selected=\"selected\""; - } - echo ">" . htmlspecialchars($prettyprint) . "</option>\n"; + if ($curcat == "queuedrops") { + $tabactive = True; + } else { + $tabactive = False; } + $tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops"); } - foreach ($ui_databases as $db => $database) { - if(! preg_match("/($curcat)/i", $database)) - continue; - - if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database)) - continue; - - $optionc = explode("-", $database); - $search = array("-", ".rrd", $optionc); - $replace = array(" :: ", "", $friendly); - - switch($curcat) { - case "captiveportal": - $optionc = str_replace($search, $replace, $optionc[2]); - echo "<option value=\"$optionc\""; - $prettyprint = ucwords(str_replace($search, $replace, $optionc)); - break; - case "system": - $optionc = str_replace($search, $replace, $optionc[1]); - echo "<option value=\"$optionc\""; - $prettyprint = ucwords(str_replace($search, $replace, $optionc)); - break; - default: - /* Deduce a interface if possible and use the description */ - $optionc = "$optionc[0]"; - $friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc)); - if(empty($friendly)) { - $friendly = $optionc; - } - $search = array("-", ".rrd", $optionc); - $replace = array(" :: ", "", $friendly); - echo "<option value=\"$optionc\""; - $prettyprint = ucwords(str_replace($search, $replace, $friendly)); + if ($wireless) { + if ($curcat == "wireless") { + $tabactive = True; + } else { + $tabactive = False; } - if($curoption == $optionc) { - echo " selected=\"selected\""; + $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless"); + } + if ($cellular) { + if ($curcat == "cellular") { + $tabactive = True; + } else { + $tabactive = False; } - echo ">" . htmlspecialchars($prettyprint) . "</option>\n"; + $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular"); } - - ?> - </select> - - <?=gettext("Style:");?> - <select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> - <?php - foreach ($styles as $style => $styled) { - echo "<option value=\"$style\""; - if ($style == $curstyle) echo " selected=\"selected\""; - echo ">" . htmlspecialchars($styled) . "</option>\n"; + if ($vpnusers) { + if ($curcat == "vpnusers") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers"); } - ?> - </select> - - <?php - 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=\"selected\""; - echo ">" . htmlspecialchars($value) . "</option>\n"; + if ($captiveportal) { + if ($curcat == "captiveportal") { + $tabactive = True; + } else { + $tabactive = False; } - echo "</select>\n"; - echo "</td></tr>\n"; + $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal"); } - ?> - <?php - - if($curcat == "custom") { - $tz = date_default_timezone_get(); - $tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz"; - $start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start); - $end_fmt = strftime("%m/%d/%Y %H:%M:%S", $end); - ?> - <?=gettext("Start:");?> - <input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfld unknown" size="24" value="<?= htmlentities($start_fmt); ?>" /> - <?=gettext("End:");?> - <input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfld unknown" size="24" value="<?= htmlentities($end_fmt); ?>" /> - <input type="submit" name="Submit" value="<?=gettext("Go"); ?>" /> - </td></tr> - <?php - $curdatabase = $curoption; - $graph = "custom-$curdatabase"; - if(in_array($curdatabase, $custom_databases)) { - $id = "{$graph}-{$curoption}-{$curdatabase}"; - $id = preg_replace('/\./', '_', $id); - - echo "<tr><td colspan=\"2\" class=\"list\">\n"; - echo "<img border=\"0\" name=\"{$id}\" "; - echo "id=\"{$id}\" alt=\"$prettydb Graph\" "; - echo "src=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n"; - echo "<br /><hr /><br />\n"; - echo "</td></tr>\n"; + if ($ntpd) { + if ($curcat == "ntpd") { + $tabactive = True; + } else { + $tabactive = False; } + $tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd"); + } + if ($curcat == "custom") { + $tabactive = True; } 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; - - if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase)) - continue; - - $optionc = explode("-", $curdatabase); - $search = array("-", ".rrd", $optionc); - $replace = array(" :: ", "", $friendly); - switch($curoption) { - case "outbound": - /* make sure we do not show the placeholder databases in the outbound view */ - if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { - continue 2; - } - /* only show interfaces with a gateway */ - $optionc = "$optionc[0]"; - if(!interface_has_gateway($optionc)) { - if(!isset($gateways_arr)) { - if(preg_match("/quality/i", $curdatabase)) - $gateways_arr = return_gateways_array(); - else - $gateways_arr = array(); - } - $found_gateway = false; - foreach ($gateways_arr as $gw) { - if ($gw['name'] == $optionc) { - $found_gateway = true; - break; - } - } - if(!$found_gateway) { - continue 2; - } - } - if(! preg_match("/(^$optionc-|-$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; + $tabactive = False; + } + $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); + if ($curcat == "settings") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php"); + display_top_tabs($tab_array); + ?> + </td> + </tr> +<?php if ($curcat == "captiveportal") : ?> + <tr> + <td class="tabnavtbl"> + <?php display_top_tabs($cp_zones_tab_array); ?> + </td> + </tr> +<?php endif; ?> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area"> + <tr> + <td colspan="2" class="list"><p><b><?=gettext("Note: Change of color and/or style may not take effect until the next refresh");?></b></p></td> + </tr> + <tr> + <td colspan="2" class="list"> + <?=gettext("Graphs:");?> + <?php if (!empty($curzone)): ?> + <input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" /> + <?php endif; ?> + <select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> + <?php + if ($curcat == "custom") { + foreach ($custom_databases as $db => $database) { + $optionc = explode("-", $database); + $friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0])); + if (empty($friendly)) { + $friendly = $optionc[0]; } - break; - default: - /* just use the name here */ - if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) { - continue 2; + $search = array("-", ".rrd", $optionc[0]); + $replace = array(" :: ", "", $friendly); + echo "<option value=\"{$database}\""; + $prettyprint = ucwords(str_replace($search, $replace, $database)); + if ($curoption == $database) { + echo " selected=\"selected\""; } + echo ">" . htmlspecialchars($prettyprint) . "</option>\n"; + } } - if(in_array($curdatabase, $ui_databases)) { - $id = "{$graph}-{$curoption}-{$curdatabase}"; - $id = preg_replace('/\./', '_', $id); - - $dates = get_dates($curperiod, $graph); - $start = $dates['start']; - $end = $dates['end']; - echo "<tr><td colspan=\"2\" class=\"list\">\n"; - echo "<img border=\"0\" name=\"{$id}\" "; - echo "id=\"{$id}\" alt=\"$prettydb Graph\" "; - echo "src=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n"; - echo "<br /><hr /><br />\n"; - echo "</td></tr>\n"; - } - } - } - } - ?> - <tr> - <td colspan="2" class="list"> - <script type="text/javascript"> - //<![CDATA[ - function update_graph_images() { - //alert('updating'); - var randomid = Math.floor(Math.random()*11); - <?php - foreach($graphs as $graph) { - /* check which databases are valid for our category */ - foreach($ui_databases as $curdatabase) { - if(! stristr($curdatabase, $curcat)) { + foreach ($ui_databases as $db => $database) { + if (! preg_match("/($curcat)/i", $database)) { continue; } - $optionc = explode("-", $curdatabase); + + if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database)) { + continue; + } + + $optionc = explode("-", $database); $search = array("-", ".rrd", $optionc); $replace = array(" :: ", "", $friendly); - switch($curoption) { - case "outbound": - /* make sure we do not show the placeholder databases in the outbound view */ - if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { - continue 2; - } - /* only show interfaces with a gateway */ - $optionc = "$optionc[0]"; - if(!interface_has_gateway($optionc)) { - if(!isset($gateways_arr)) - if(preg_match("/quality/i", $curdatabase)) - $gateways_arr = return_gateways_array(); - else - $gateways_arr = array(); - $found_gateway = false; - foreach ($gateways_arr as $gw) { - if ($gw['name'] == $optionc) { - $found_gateway = true; - break; - } - } - if(!$found_gateway) { - continue 2; - } - } - if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) { - continue 2; - } + + switch ($curcat) { + case "captiveportal": + $optionc = str_replace($search, $replace, $optionc[2]); + echo "<option value=\"$optionc\""; + $prettyprint = ucwords(str_replace($search, $replace, $optionc)); 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; - } + case "system": + $optionc = str_replace($search, $replace, $optionc[1]); + echo "<option value=\"$optionc\""; + $prettyprint = ucwords(str_replace($search, $replace, $optionc)); break; default: - /* just use the name here */ - if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) { - continue 2; + /* Deduce a interface if possible and use the description */ + $optionc = "$optionc[0]"; + $friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc)); + if (empty($friendly)) { + $friendly = $optionc; } + $search = array("-", ".rrd", $optionc); + $replace = array(" :: ", "", $friendly); + echo "<option value=\"$optionc\""; + $prettyprint = ucwords(str_replace($search, $replace, $friendly)); } - $dates = get_dates($curperiod, $graph); - $start = $dates['start']; - if($curperiod == "current") { - $end = $dates['end']; + if ($curoption == $optionc) { + echo " selected=\"selected\""; } - /* generate update events utilizing jQuery('') feature */ - $id = "{$graph}-{$curoption}-{$curdatabase}"; - $id = preg_replace('/\./', '_', $id); + echo ">" . htmlspecialchars($prettyprint) . "</option>\n"; + } + ?> + </select> - echo "\n"; - echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n"; + <?=gettext("Style:");?> + <select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> + <?php + foreach ($styles as $style => $styled) { + echo "<option value=\"$style\""; + if ($style == $curstyle) { + echo " selected=\"selected\""; } + echo ">" . htmlspecialchars($styled) . "</option>\n"; } ?> - window.setTimeout('update_graph_images()', 355000); + </select> + +<?php + if ($curcat == "custom") { + // Custom tab displays start and end time selectors. + $tz = date_default_timezone_get(); + $tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz"; + $start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start); + $end_fmt = strftime("%m/%d/%Y %H:%M:%S", $end); +?> + <?=gettext("Start:");?> + <input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfld unknown" size="24" value="<?= htmlentities($start_fmt); ?>" /> + <?=gettext("End:");?> + <input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfld unknown" size="24" value="<?= htmlentities($end_fmt); ?>" /> + <input type="submit" name="Submit" value="<?=gettext("Go"); ?>" /> +<?php + } else { + // Not on the custom tab - show the Period selector +?> + <?=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=\"selected\""; + } + echo ">" . htmlspecialchars($value) . "</option>\n"; + } + ?> + </select> +<?php + } +?> + </td> + </tr> +<?php + if ($curcat == "custom") { + // Insert the chosen graph + $curdatabase = $curoption; + $graph = "custom-$curdatabase"; + if (in_array($curdatabase, $custom_databases)) { + $id = "{$graph}-{$curoption}-{$curdatabase}"; + $id = preg_replace('/\./', '_', $id); + + echo "<tr><td colspan=\"2\" class=\"list\">\n"; + echo "<img border=\"0\" name=\"{$id}\" "; + echo "id=\"{$id}\" alt=\"$prettydb Graph\" "; + echo "src=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n"; + echo "<br /><hr /><br />\n"; + echo "</td></tr>\n"; + } + } else { + // Insert each of the graphs for the various set time periods + foreach ($graphs as $graph) { + /* check which databases are valid for our category */ + foreach ($ui_databases as $curdatabase) { + if (! preg_match("/($curcat)/i", $curdatabase)) { + continue; + } + + if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase)) { + continue; + } + + $optionc = explode("-", $curdatabase); + $search = array("-", ".rrd", $optionc); + $replace = array(" :: ", "", $friendly); + switch ($curoption) { + case "outbound": + /* make sure we do not show the placeholder databases in the outbound view */ + if ((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { + continue 2; + } + /* only show interfaces with a gateway */ + $optionc = "$optionc[0]"; + if (!interface_has_gateway($optionc)) { + if (!isset($gateways_arr)) { + if (preg_match("/quality/i", $curdatabase)) { + $gateways_arr = return_gateways_array(); + } else { + $gateways_arr = array(); + } + } + $found_gateway = false; + foreach ($gateways_arr as $gw) { + if ($gw['name'] == $optionc) { + $found_gateway = true; + break; + } + } + if (!$found_gateway) { + continue 2; + } + } + if (! preg_match("/(^$optionc-|-$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; } - window.setTimeout('update_graph_images()', 355000); - //]]> - </script> - </td> - </tr> - </table> - </div> - </td> - </tr> -</table> + break; + default: + /* just use the name here */ + if (! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) { + continue 2; + } + } + if (in_array($curdatabase, $ui_databases)) { + $id = "{$graph}-{$curoption}-{$curdatabase}"; + $id = preg_replace('/\./', '_', $id); + + $dates = get_dates($curperiod, $graph); + $start = $dates['start']; + $end = $dates['end']; + echo "<tr><td colspan=\"2\" class=\"list\">\n"; + echo "<img border=\"0\" name=\"{$id}\" "; + echo "id=\"{$id}\" alt=\"$prettydb Graph\" "; + echo "src=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n"; + echo "<br /><hr /><br />\n"; + echo "</td></tr>\n"; + } + } + } + } +?> + <tr> + <td colspan="2" class="list"> + <script type="text/javascript"> + //<![CDATA[ + function update_graph_images() { + //alert('updating'); + var randomid = Math.floor(Math.random()*11); + <?php + foreach ($graphs as $graph) { + /* check which databases are valid for our category */ + foreach ($ui_databases as $curdatabase) { + if (! stristr($curdatabase, $curcat)) { + continue; + } + $optionc = explode("-", $curdatabase); + $search = array("-", ".rrd", $optionc); + $replace = array(" :: ", "", $friendly); + switch ($curoption) { + case "outbound": + /* make sure we do not show the placeholder databases in the outbound view */ + if ((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { + continue 2; + } + /* only show interfaces with a gateway */ + $optionc = "$optionc[0]"; + if (!interface_has_gateway($optionc)) { + if (!isset($gateways_arr)) { + if (preg_match("/quality/i", $curdatabase)) { + $gateways_arr = return_gateways_array(); + } else { + $gateways_arr = array(); + } + } + $found_gateway = false; + foreach ($gateways_arr as $gw) { + if ($gw['name'] == $optionc) { + $found_gateway = true; + break; + } + } + if (!$found_gateway) { + continue 2; + } + } + if (! preg_match("/(^$optionc-|-$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-|-$curoption\\.)/i", $curdatabase)) { + continue 2; + } + } + $dates = get_dates($curperiod, $graph); + $start = $dates['start']; + if ($curperiod == "current") { + $end = $dates['end']; + } + /* generate update events utilizing jQuery('') feature */ + $id = "{$graph}-{$curoption}-{$curdatabase}"; + $id = preg_replace('/\./', '_', $id); + + echo "\n"; + echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n"; + } + } + ?> + window.setTimeout('update_graph_images()', 355000); + } + window.setTimeout('update_graph_images()', 355000); + //]]> + </script> + </td> + </tr> + </table> + </div> + </td> + </tr> + </table> </form> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php index bb84b1d..6d7c7eb 100644 --- a/usr/local/www/status_rrd_graph_img.php +++ b/usr/local/www/status_rrd_graph_img.php @@ -66,21 +66,21 @@ if ($_GET['graph']) { $now = time(); if (is_numeric($_GET['start'])) { - $start = $_GET['start']; + $start = $_GET['start']; } else { - $start = $now - (8 * 3600); + $start = $now - (8 * 3600); } if (is_numeric($_GET['end'])) { - $end = $_GET['end']; + $end = $_GET['end']; } else { - $end = $now; + $end = $now; } /* this should never happen */ -if($end < $start) { +if ($end < $start) { log_error("start $start is smaller than end $end"); - $end = $now; + $end = $now; } $seconds = $end - $start; @@ -110,19 +110,19 @@ $defOptions = array( /* always set the average to the highest value as a fallback */ $average = 1440 * 60; -foreach($archives as $rra => $value) { - $archivestart = $now - ($rra * 60 * $value); - if($archivestart <= $start) { - $average = $rra * 60; - break; - } +foreach ($archives as $rra => $value) { + $archivestart = $now - ($rra * 60 * $value); + if ($archivestart <= $start) { + $average = $rra * 60; + break; + } } -foreach($scales as $scalelength => $value) { - if($scalelength >= $seconds) { - $scale = $value; - break; - } +foreach ($scales as $scalelength => $value) { + if ($scalelength >= $seconds) { + $scale = $value; + break; + } } // log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds"); @@ -131,14 +131,13 @@ foreach($scales as $scalelength => $value) { $curif = explode("-", $curdatabase); $curif = "$curif[0]"; $friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif)); -if($friendly == "") { +if ($friendly == "") { $friendly = $curif; } $search = array("-", ".rrd", $curif); $replace = array(" :: ", "", $friendly); $prettydb = ucwords(str_replace($search, $replace, $curdatabase)); - $rrddbpath = "/var/db/rrd/"; $rrdtmppath = "/tmp/"; $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool"; @@ -169,25 +168,26 @@ read_altq_config(); if ($altq_list_queues[$curif]) { $altq =& $altq_list_queues[$curif]; switch ($altq->GetBwscale()) { - case "Gb": - $factor = 1024 * 1024 * 1024; - break; - case "Mb": - $factor = 1024 * 1024; - break; - case "Kb": - $factor = 1024; - break; - case "b": - default: - $factor = 1; - break; - } + case "Gb": + $factor = 1024 * 1024 * 1024; + break; + case "Mb": + $factor = 1024 * 1024; + break; + case "Kb": + $factor = 1024; + break; + case "b": + default: + $factor = 1; + break; + } $upstream = (($altq->GetBandwidth()*$factor)/8); - if ($upstream != 0) + if ($upstream != 0) { $downstream = $upstream; /* XXX: Ugly hack */ - else + } else { $downstream = $upstream = 12500000; + } $upif = $curif; $downif = "lan"; /* XXX should this be set to something else?! */ } else { @@ -262,71 +262,74 @@ $colorcaptiveportalusers = array('990000'); /* select theme colors if the inclusion file exists */ $rrdcolors = "{$g['www_path']}/themes/{$g['theme']}/rrdcolors.inc.php"; -if(file_exists($rrdcolors)) { +if (file_exists($rrdcolors)) { include($rrdcolors); } else { log_error(sprintf(gettext("rrdcolors.inc.php for theme %s does not exist, using defaults!"),$g['theme'])); } switch ($curstyle) { -case "absolute": - $multiplier = 1; - $AREA = "LINE1"; - break; -default: - $multiplier = -1; - $AREA = "AREA"; - break; + case "absolute": + $multiplier = 1; + $AREA = "LINE1"; + break; + default: + $multiplier = -1; + $AREA = "AREA"; + break; } function timeDiff($time, $opt = array()) { - // The default values - $defOptions = array( - 'to' => 0, - 'parts' => 1, - 'precision' => 'second', - 'distance' => TRUE, - 'separator' => ', ' - ); - $opt = array_merge($defOptions, $opt); - // Default to current time if no to point is given - (!$opt['to']) && ($opt['to'] = time()); - // Init an empty string - $str = ''; - // To or From computation - $diff = ($opt['to'] > $time) ? $opt['to'] - $time : $time - $opt['to']; - // An array of label => periods of seconds; - $periods = array( - 'decade' => 315569260, - 'year' => 31539600, - 'month' => 2629744, - 'week' => 604800, - 'day' => 86400, - 'hour' => 3600, - 'minute' => 60, - 'second' => 1 - ); + // The default values + $defOptions = array( + 'to' => 0, + 'parts' => 1, + 'precision' => 'second', + 'distance' => TRUE, + 'separator' => ', ' + ); + $opt = array_merge($defOptions, $opt); + // Default to current time if no to point is given + (!$opt['to']) && ($opt['to'] = time()); + // Init an empty string + $str = ''; + // To or From computation + $diff = ($opt['to'] > $time) ? $opt['to'] - $time : $time - $opt['to']; + // An array of label => periods of seconds; + $periods = array( + 'decade' => 315569260, + 'year' => 31539600, + 'month' => 2629744, + 'week' => 604800, + 'day' => 86400, + 'hour' => 3600, + 'minute' => 60, + 'second' => 1 + ); // 31539600, 31556926, 31622400 - // Round to precision - if ($opt['precision'] != 'second') - $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']]; - // Report the value is 'less than 1 ' precision period away - (0 == $diff) && ($str = 'less than 1 ' . $opt['precision']); - // Loop over each period - foreach ($periods as $label => $value) { - // Stitch together the time difference string - (($x = round($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x .' '. $label. ($x > 1 ? 's' : '')); - // Stop processing if no more parts are going to be reported. - if ($opt['parts'] == 0 || $label == $opt['precision']) break; - // Get ready for the next pass - $diff -= $x * $value; - } - $opt['distance'] && $str .= ($str && $opt['to'] >= $time) ? ' ago' : ' away'; - return $str; + // Round to precision + if ($opt['precision'] != 'second') { + $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']]; + } + // Report the value is 'less than 1 ' precision period away + (0 == $diff) && ($str = 'less than 1 ' . $opt['precision']); + // Loop over each period + foreach ($periods as $label => $value) { + // Stitch together the time difference string + (($x = round($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x .' '. $label. ($x > 1 ? 's' : '')); + // Stop processing if no more parts are going to be reported. + if ($opt['parts'] == 0 || $label == $opt['precision']) { + break; + } + // Get ready for the next pass + $diff -= $x * $value; + } + $opt['distance'] && $str .= ($str && $opt['to'] >= $time) ? ' ago' : ' away'; + return $str; } -if((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +if ((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for traffic stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step --vertical-label \"bits/sec\" "; @@ -477,8 +480,7 @@ if((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabas $graphcmd .= "GPRINT:\"$curif-bytes_out6_t_block:AVERAGE:%7.2lf %sB o\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif(strstr($curdatabase, "-throughput.rrd")) { +} elseif (strstr($curdatabase, "-throughput.rrd")) { /* define graphcmd for throughput stats */ /* this gathers all interface statistics, the database does not actually exist */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; @@ -504,7 +506,7 @@ elseif(strstr($curdatabase, "-throughput.rrd")) { $graphtputbyib = ""; $graphtputbyob = ""; $graphtputbytb = ""; - foreach($iflist as $ifname) { + foreach ($iflist as $ifname) { /* collect all interface stats */ $graphcmd .= "DEF:\"{$ifname}-in_bytes_pass={$rrddbpath}{$ifname}-traffic.rrd:inpass:AVERAGE:step=$step\" "; $graphcmd .= "DEF:\"{$ifname}-out_bytes_pass={$rrddbpath}{$ifname}-traffic.rrd:outpass:AVERAGE:step=$step\" "; @@ -605,8 +607,7 @@ elseif(strstr($curdatabase, "-throughput.rrd")) { $graphcmd .= "GPRINT:\"tput-bytes_out_t_block:AVERAGE:%7.2lf %sB o\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for packets stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -731,8 +732,7 @@ elseif((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdat $graphcmd .= "GPRINT:\"$curif-pps_out6_t_block:AVERAGE:%7.2lf %s pkts\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for packets stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -764,8 +764,7 @@ elseif((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curda $graphcmd .= "GPRINT:\"$curif-channel:LAST:%7.2lf\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-vpnusers.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-vpnusers.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for vpn users stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -783,8 +782,7 @@ elseif((strstr($curdatabase, "-vpnusers.rrd")) && (file_exists("$rrddbpath$curda $graphcmd .= "GPRINT:\"$curif-users:LAST:%7.2lf \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for states stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start -$seconds -e -$average --step $step "; @@ -837,8 +835,7 @@ elseif((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdata $graphcmd .= "GPRINT:\"$curif-dstip:LAST:%7.2lf %s \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for processor stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -889,8 +886,7 @@ elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curd $graphcmd .= "GPRINT:\"processes:LAST:%7.2lf %s \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for memory usage stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -941,8 +937,7 @@ elseif((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdata $graphcmd .= "GPRINT:\"wire:LAST:%7.2lf %S \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-mbuf.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-mbuf.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for mbuf usage stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -985,8 +980,7 @@ elseif((strstr($curdatabase, "-mbuf.rrd")) && (file_exists("$rrddbpath$curdataba $graphcmd .= "GPRINT:\"max:LAST:%7.2lf %S \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for queue stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -1004,18 +998,21 @@ elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdata } foreach ($a_queues as $name => $q) { $color = "$colorqueuesup[$t]"; - if($t > 0) { $stack = ":STACK"; } + if ($t > 0) { + $stack = ":STACK"; + } $graphcmd .= "DEF:\"$name=$rrddbpath$curdatabase:$name:AVERAGE:step=$step\" "; $graphcmd .= "CDEF:\"$name-bytes_out=$name,0,$speedlimit,LIMIT,UN,0,$name,IF\" "; $graphcmd .= "CDEF:\"$name-bits_out=$name-bytes_out,8,*\" "; $graphcmd .= "$AREA:\"$name-bits_out#${color}:$name$stack\" "; $t++; - if($t > 7) { $t = 0; } + if ($t > 7) { + $t = 0; + } } $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-queuedrops.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-queuedrops.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for queuedrop stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -1027,26 +1024,29 @@ elseif((strstr($curdatabase, "-queuedrops.rrd")) && (file_exists("$rrddbpath$cur $a_queues =& $altq->get_queue_list(); $t = 0; } else { - $a_queues = array(); + $a_queues = array(); $i = 0; $t = 0; } foreach ($a_queues as $name => $q) { $color = "$colorqueuesdropup[$t]"; - if($t > 0) { $stack = ":STACK"; } + if ($t > 0) { + $stack = ":STACK"; + } $graphcmd .= "DEF:\"$name=$rrddbpath$curdatabase:$name:AVERAGE:step=$step\" "; $graphcmd .= "CDEF:\"$name-bytes_out=$name,0,$speedlimit,LIMIT,UN,0,$name,IF\" "; $graphcmd .= "CDEF:\"$name-bits_out=$name-bytes_out,8,*\" "; $graphcmd .= "CDEF:\"$name-bits_out_neg=$name-bits_out,$multiplier,*\" "; $graphcmd .= "$AREA:\"$name-bits_out_neg#${color}:$name$stack\" "; $t++; - if($t > 7) { $t = 0; } + if ($t > 7) { + $t = 0; + } } $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { - /* make a link quality graphcmd, we only have WAN for now, others too follow */ +} elseif ((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { + /* make a link quality graphcmd */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png \\ --start $start --end $end --step $step \\ --title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" \\ @@ -1067,7 +1067,7 @@ elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdat AREA:delay#$colorqualityrtt[0]:\"> 420 ms\" \\ GPRINT:delay:MIN:\"\t\tMin\\: %7.2lf ms\" \\ GPRINT:loss:MIN:\"\tMin\\: %3.1lf %%\\n\" \\ - AREA:r3#$colorqualityrtt[1]:\"180-420 ms\" \\ + AREA:r3#$colorqualityrtt[1]:\"180-420 ms\" \\ GPRINT:delay:AVERAGE:\"\t\tAvg\\: %7.2lf ms\" \\ GPRINT:loss:AVERAGE:\"\tAvg\\: %3.1lf %%\\n\" \\ AREA:r2#$colorqualityrtt[2]:\"60-180 ms\" \\ @@ -1080,8 +1080,7 @@ elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdat AREA:loss10#$colorqualityloss:\"Packet loss\\n\" \\ LINE1:delay#$colorqualityrtt[5]:\"Delay average\\n\" \\ COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\""; -} -elseif((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* graph a spamd statistics graph */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png \\ --start $start --end $end --step $step \\ @@ -1119,8 +1118,7 @@ elseif((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdataba GPRINT:consavg:AVERAGE:\"Avg\\:%6.2lf\\t\" \\ GPRINT:consmax:MAX:\"Max\\:%6.2lf\\n\" \\ COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; $graphcmd .= "--vertical-label \"signal\" "; @@ -1137,8 +1135,7 @@ elseif((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curda $graphcmd .= "GPRINT:\"$curif-rssi:LAST:%7.2lf \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-loggedin.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-loggedin.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for online Captive Portal users stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -1156,8 +1153,7 @@ elseif((strstr($curdatabase, "-loggedin.rrd")) && (file_exists("$rrddbpath$curda $graphcmd .= "GPRINT:\"$curif-totalusers_d:MAX:%8.0lf \\n\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "-concurrent.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "-concurrent.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for online Captive Portal users stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -1178,8 +1174,7 @@ elseif((strstr($curdatabase, "-concurrent.rrd")) && (file_exists("$rrddbpath$cur $graphcmd .= "GPRINT:\"$curif-concurrentusers:MAX:%8.0lf \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -elseif((strstr($curdatabase, "ntpd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { +} elseif ((strstr($curdatabase, "ntpd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for ntpd (was: mbuf) usage stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end --step $step "; @@ -1222,15 +1217,14 @@ elseif((strstr($curdatabase, "ntpd.rrd")) && (file_exists("$rrddbpath$curdatabas $graphcmd .= "GPRINT:\"wander:LAST:%7.2lf %S \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; -} -else { +} else { $data = false; log_error(sprintf(gettext("Sorry we do not have data to graph for %s"),$curdatabase)); } /* check modification time to see if we need to generate image */ if (file_exists("$rrdtmppath$curdatabase-$curgraph.png")) { - if ((time() - filemtime("$rrdtmppath$curdatabase-$curgraph.png")) >= 15 ) { + if ((time() - filemtime("$rrdtmppath$curdatabase-$curgraph.png")) >= 15) { if ($data) { $_gb = exec("$graphcmd 2>&1", $graphcmdoutput, $graphcmdreturn); $graphcmdoutput = implode(" ", $graphcmdoutput) . $graphcmd; @@ -1246,16 +1240,16 @@ if (file_exists("$rrdtmppath$curdatabase-$curgraph.png")) { usleep(500); } } -if(($graphcmdreturn <> 0) || (! $data)) { +if (($graphcmdreturn <> 0) || (! $data)) { log_error(sprintf(gettext('Failed to create graph with error code %1$s, the error is: %2$s'),$graphcmdreturn,$graphcmdoutput)); - if(strstr($curdatabase, "queues")) { + if (strstr($curdatabase, "queues")) { log_error(sprintf(gettext("failed to create graph from %s%s, removing database"),$rrddbpath,$curdatabase)); unlink_if_exists($rrddbpath . $curif . $queues); flush(); usleep(500); enable_rrd_graphing(); } - if(strstr($curdatabase, "queuesdrop")) { + if (strstr($curdatabase, "queuesdrop")) { log_error(sprintf(gettext("failed to create graph from %s%s, removing database"),$rrddbpath,$curdatabase)); unlink_if_exists($rrddbpath . $curdatabase); flush(); @@ -1271,7 +1265,7 @@ if(($graphcmdreturn <> 0) || (! $data)) { readfile($file); } else { $file = "$rrdtmppath$curdatabase-$curgraph.png"; - if(file_exists("$file")) { + if (file_exists("$file")) { header("Content-type: image/png"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); diff --git a/usr/local/www/status_rrd_graph_settings.php b/usr/local/www/status_rrd_graph_settings.php index 2477a75..ef35951 100644 --- a/usr/local/www/status_rrd_graph_settings.php +++ b/usr/local/www/status_rrd_graph_settings.php @@ -28,7 +28,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_BUILDER_BINARIES: /usr/bin/find pfSense_MODULE: system */ @@ -52,21 +52,21 @@ $pconfig['period'] = $config['rrd']['period']; $curcat = "settings"; $categories = array('system' => gettext("System"), - 'traffic' => gettext("Traffic"), - 'packets' => gettext("Packets"), - 'quality' => gettext("Quality"), - 'queues' => gettext("Queues"), - 'captiveportal' => gettext("Captive Portal")); + 'traffic' => gettext("Traffic"), + 'packets' => gettext("Packets"), + 'quality' => gettext("Quality"), + 'queues' => gettext("Queues"), + 'captiveportal' => gettext("Captive Portal")); -if(isset($config['ntpd']['statsgraph'])) { +if (isset($config['ntpd']['statsgraph'])) { $categories['ntpd'] = gettext("NTP"); } $styles = array('inverse' => gettext("Inverse"), - 'absolute' => gettext("Absolute")); + 'absolute' => gettext("Absolute")); $periods = array("absolute" => gettext("Absolute Timespans"), - "current" => gettext("Current Period"), - "previous" => gettext("Previous Period")); + "current" => gettext("Current Period"), + "previous" => gettext("Previous Period")); if ($_POST['ResetRRD']) { mwexec('/bin/rm /var/db/rrd/*'); @@ -80,39 +80,37 @@ if ($_POST['ResetRRD']) { /* input validation */ /* none */ - if (!$input_errors) { - $config['rrd']['enable'] = $_POST['enable'] ? true : false; - $config['rrd']['category'] = $_POST['category']; - $config['rrd']['style'] = $_POST['style']; - $config['rrd']['period'] = $_POST['period']; - write_config(); + if (!$input_errors) { + $config['rrd']['enable'] = $_POST['enable'] ? true : false; + $config['rrd']['category'] = $_POST['category']; + $config['rrd']['style'] = $_POST['style']; + $config['rrd']['period'] = $_POST['period']; + write_config(); - $retval = 0; - $retval = enable_rrd_graphing(); - $savemsg = get_std_save_message($retval); + $retval = 0; + $retval = enable_rrd_graphing(); + $savemsg = get_std_save_message($retval); } } - - $rrddbpath = "/var/db/rrd/"; chdir($rrddbpath); $databases = glob("*.rrd"); -foreach($databases as $database) { - if(stristr($database, "wireless")) { +foreach ($databases as $database) { + if (stristr($database, "wireless")) { $wireless = true; } - if(stristr($database, "queues")) { + if (stristr($database, "queues")) { $queues = true; } - if(stristr($database, "-cellular") && !empty($config['ppps'])) { + if (stristr($database, "-cellular") && !empty($config['ppps'])) { $cellular = true; } - if(stristr($database, "-vpnusers")) { + if (stristr($database, "-vpnusers")) { $vpnusers = true; } - if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) { + if (stristr($database, "captiveportal-") && is_array($config['captiveportal'])) { $captiveportal = true; } } @@ -126,135 +124,192 @@ include("head.inc"); <?php if ($input_errors) print_input_errors($input_errors); ?> <?php if ($savemsg) print_info_box($savemsg); ?> <form action="status_rrd_graph_settings.php" method="post" name="iform" id="iform"> -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graph settings"> - <tr> - <td> + <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graph settings"> + <tr> + <td> <?php $tab_array = array(); - if($curcat == "system") { $tabactive = True; } else { $tabactive = False; } + if ($curcat == "system") { + $tabactive = True; + } else { + $tabactive = False; + } $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system"); - if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic"); - if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets"); - if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality"); - if($queues) { - if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues"); - if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops"); + if ($curcat == "traffic") { + $tabactive = True; + } else { + $tabactive = False; } - if($wireless) { - if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless"); + $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic"); + if ($curcat == "packets") { + $tabactive = True; + } else { + $tabactive = False; } - if($cellular) { - if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular"); + $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets"); + if ($curcat == "quality") { + $tabactive = True; + } else { + $tabactive = False; } - if($vpnusers) { - if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("VPN"), $tabactive, "status_rrd_graph.php?cat=vpnusers"); + $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality"); + if ($queues) { + if ($curcat == "queues") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues"); + if ($curcat == "queuedrops") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops"); } - if($captiveportal) { - if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Captive Portal"), $tabactive, "status_rrd_graph.php?cat=captiveportal"); + if ($wireless) { + if ($curcat == "wireless") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless"); } - if(isset($config['ntpd']['statsgraph'])) { - if($curcat == "ntpd") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd"); + if ($cellular) { + if ($curcat == "cellular") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular"); } - if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); - if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; } - $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php"); - - display_top_tabs($tab_array); - ?> - </td> - </tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="main area"> - <tr> - <td width="22%" valign="top" class="vtable"><?=gettext("RRD Graphs");?></td> - <td width="78%" class="vtable"> - <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\"" ?> onclick="enable_change(false)" /> - <b><?=gettext("Enables the RRD graphing backend.");?></b> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vtable"><?=gettext("Default category");?></td> - <td width="78%" class="vtable"> - <select name="category" id="category" class="formselect" style="z-index: -10;" > - <?php - foreach ($categories as $category => $categoryd) { - echo "<option value=\"$category\""; - if ($category == $pconfig['category']) echo " selected=\"selected\""; - echo ">" . htmlspecialchars($categoryd) . "</option>\n"; + if ($vpnusers) { + if ($curcat == "vpnusers") { + $tabactive = True; + } else { + $tabactive = False; } - ?> - </select> - <b><?=gettext("This selects default category.");?></b> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vtable"><?=gettext("Default style");?></td> - <td width="78%" class="vtable"> - <select name="style" class="formselect" style="z-index: -10;" > - <?php - foreach ($styles as $style => $styled) { - echo "<option value=\"$style\""; - if ($style == $pconfig['style']) echo " selected=\"selected\""; - echo ">" . htmlspecialchars($styled) . "</option>\n"; + $tab_array[] = array(gettext("VPN"), $tabactive, "status_rrd_graph.php?cat=vpnusers"); + } + if ($captiveportal) { + if ($curcat == "captiveportal") { + $tabactive = True; + } else { + $tabactive = False; } - ?> - </select> - <b><?=gettext("This selects the default style.");?></b> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vtable"><?=gettext("Default period");?></td> - <td width="78%" class="vtable"> - <select name="period" class="formselect" style="z-index: -10;" > - <?php - foreach ($periods as $period => $periodd) { - echo "<option value=\"$period\""; - if ($period == $pconfig['period']) echo " selected=\"selected\""; - echo ">" . htmlspecialchars($periodd) . "</option>\n"; + $tab_array[] = array(gettext("Captive Portal"), $tabactive, "status_rrd_graph.php?cat=captiveportal"); + } + if (isset($config['ntpd']['statsgraph'])) { + if ($curcat == "ntpd") { + $tabactive = True; + } else { + $tabactive = False; } - ?> - </select> - <b><?=gettext("This selects the default period.");?></b> - </td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" /> - </td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="ResetRRD" type="submit" class="formbtn" value="<?=gettext("Reset RRD Data");?>" onclick="return confirm('<?=gettext('Do you really want to reset the RRD graphs? This will erase all graph data.');?>')" /> - </td> - </tr> - <tr> - <td width="22%" height="53" valign="top"> </td> - <td width="78%"><strong><span class="red"><?=gettext("Note:");?></span></strong><br /> - <?=gettext("Graphs will not be allowed to be recreated within a 1 minute interval, please " . - "take this into account after changing the style.");?> - </td> - </tr> - </table> - </div> - </td> - </tr> -</table> + $tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd"); + } + if ($curcat == "custom") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); + if ($curcat == "settings") { + $tabactive = True; + } else { + $tabactive = False; + } + $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php"); + display_top_tabs($tab_array); + ?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="main area"> + <tr> + <td width="22%" valign="top" class="vtable"><?=gettext("RRD Graphs");?></td> + <td width="78%" class="vtable"> + <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\"" ?> onclick="enable_change(false)" /> + <b><?=gettext("Enables the RRD graphing backend.");?></b> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vtable"><?=gettext("Default category");?></td> + <td width="78%" class="vtable"> + <select name="category" id="category" class="formselect" style="z-index: -10;" > + <?php + foreach ($categories as $category => $categoryd) { + echo "<option value=\"$category\""; + if ($category == $pconfig['category']) { + echo " selected=\"selected\""; + } + echo ">" . htmlspecialchars($categoryd) . "</option>\n"; + } + ?> + </select> + <b><?=gettext("This selects default category.");?></b> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vtable"><?=gettext("Default style");?></td> + <td width="78%" class="vtable"> + <select name="style" class="formselect" style="z-index: -10;" > + <?php + foreach ($styles as $style => $styled) { + echo "<option value=\"$style\""; + if ($style == $pconfig['style']) { + echo " selected=\"selected\""; + } + echo ">" . htmlspecialchars($styled) . "</option>\n"; + } + ?> + </select> + <b><?=gettext("This selects the default style.");?></b> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vtable"><?=gettext("Default period");?></td> + <td width="78%" class="vtable"> + <select name="period" class="formselect" style="z-index: -10;" > + <?php + foreach ($periods as $period => $periodd) { + echo "<option value=\"$period\""; + if ($period == $pconfig['period']) { + echo " selected=\"selected\""; + } + echo ">" . htmlspecialchars($periodd) . "</option>\n"; + } + ?> + </select> + <b><?=gettext("This selects the default period.");?></b> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" /> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="ResetRRD" type="submit" class="formbtn" value="<?=gettext("Reset RRD Data");?>" onclick="return confirm('<?=gettext('Do you really want to reset the RRD graphs? This will erase all graph data.');?>')" /> + </td> + </tr> + <tr> + <td width="22%" height="53" valign="top"> </td> + <td width="78%"><strong><span class="red"><?=gettext("Note:");?></span></strong><br /> + <?=gettext("Graphs will not be allowed to be recreated within a 1 minute interval, please " . + "take this into account after changing the style.");?> + </td> + </tr> + </table> + </div> + </td> + </tr> + </table> </form> <?php include("fend.inc"); ?> </body> |