summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-02-06 15:52:19 -0200
committerRenato Botelho <garga@FreeBSD.org>2013-02-06 15:54:47 -0200
commitcba9d7d9a5edd4d2b49768a536740b288da99300 (patch)
treed5818f8a323ed7659d3e8ed0ef02036e87e0801b /usr
parent2e19a6834fb8b3f2e6f74278be9b9407d7c9d638 (diff)
downloadpfsense-cba9d7d9a5edd4d2b49768a536740b288da99300.zip
pfsense-cba9d7d9a5edd4d2b49768a536740b288da99300.tar.gz
Adjust RRD captive portal graphs for CP zones
- Create RRD configs per zone - Add tabs to see graphs per zone - Migrate existing rrd files to default cpZone - While I'm here, call unset() for $rrdcreate and $rrdupdatesh Resolves #2655
Diffstat (limited to 'usr')
-rw-r--r--usr/local/bin/captiveportal_gather_stats.php8
-rwxr-xr-xusr/local/www/status_rrd_graph.php52
-rwxr-xr-xusr/local/www/status_rrd_graph_settings.php2
3 files changed, 51 insertions, 11 deletions
diff --git a/usr/local/bin/captiveportal_gather_stats.php b/usr/local/bin/captiveportal_gather_stats.php
index 5e9f340..63d91a2 100644
--- a/usr/local/bin/captiveportal_gather_stats.php
+++ b/usr/local/bin/captiveportal_gather_stats.php
@@ -32,6 +32,11 @@ require_once("functions.inc");
require_once("captiveportal.inc");
require_once("util.inc");
+global $cpzone;
+
+$cpzone = $argv[1];
+$type = $argv[2];
+
/* read in captive portal db */
$cpdb = captiveportal_read_db();
@@ -45,8 +50,6 @@ $current_user_count = 0;
/* tmp file to use to store old data (per interface)*/
$tmpfile = "{$g['vardb_path']}/captiveportal_online_users";
-$type = $argv[1];
-
if(empty($type))
exit;
@@ -73,7 +76,6 @@ if ($type == "loggedin") {
}
@fclose($fd);
-
foreach($cpdb as $user) {
$user_ip = $user[2];
// Record the timestamp
diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php
index ab3fe9c..212b660 100755
--- a/usr/local/www/status_rrd_graph.php
+++ b/usr/local/www/status_rrd_graph.php
@@ -65,6 +65,11 @@ if ($_GET['cat']) {
}
}
+if ($_GET['zone'])
+ $curzone = $_GET['zone'];
+else
+ $curzone = '';
+
if ($_GET['period']) {
$curperiod = $_GET['period'];
} else {
@@ -198,7 +203,6 @@ $dbheader = array("allgraphs-traffic.rrd",
"allgraphs-wireless.rrd",
"allgraphs-cellular.rrd",
"allgraphs-vpnusers.rrd",
- "captiveportal-allgraphs.rrd",
"allgraphs-packets.rrd",
"system-allgraphs.rrd",
"system-throughput.rrd",
@@ -222,7 +226,7 @@ foreach($databases as $database) {
if(stristr($database, "-vpnusers")) {
$vpnusers = true;
}
- if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) {
+ if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
$captiveportal = true;
}
}
@@ -244,6 +248,27 @@ $graph_length = array(
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
$closehead = false;
+
+/* Load all CP zones */
+if ($captiveportal) {
+ $cp_zones_tab_array = array();
+ foreach($config['captiveportal'] as $cpkey => $cp) {
+ if (!isset($cp['enable']))
+ continue;
+
+ if ($curzone == '') {
+ $tabactive = true;
+ $curzone = $cpkey;
+ } elseif ($curzone == $cpkey) {
+ $tabactive = true;
+ } else {
+ $tabactive = false;
+ }
+
+ $cp_zones_tab_array[] = array($cp['zone'], $tabactive, "status_rrd_graph.php?cat=captiveportal&zone=$cpkey");
+ }
+}
+
include("head.inc");
?>
@@ -411,6 +436,13 @@ function get_dates($curperiod, $graph) {
?>
</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">
@@ -438,16 +470,19 @@ function get_dates($curperiod, $graph) {
}
}
foreach ($ui_databases as $db => $database) {
- if(! preg_match("/($curcat)/i", $database)) {
+ if(! preg_match("/($curcat)/i", $database))
continue;
- }
+
+ if (!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[1]);
+ $optionc = str_replace($search, $replace, $optionc[2]);
echo "<option value=\"$optionc\"";
$prettyprint = ucwords(str_replace($search, $replace, $optionc));
break;
@@ -533,9 +568,12 @@ function get_dates($curperiod, $graph) {
foreach($graphs as $graph) {
/* check which databases are valid for our category */
foreach($ui_databases as $curdatabase) {
- if(! preg_match("/($curcat)/i", $curdatabase)) {
+ if(! preg_match("/($curcat)/i", $curdatabase))
continue;
- }
+
+ if (!empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
+ continue;
+
$optionc = explode("-", $curdatabase);
$search = array("-", ".rrd", $optionc);
$replace = array(" :: ", "", $friendly);
diff --git a/usr/local/www/status_rrd_graph_settings.php b/usr/local/www/status_rrd_graph_settings.php
index 551fccb..6a30cc4 100755
--- a/usr/local/www/status_rrd_graph_settings.php
+++ b/usr/local/www/status_rrd_graph_settings.php
@@ -106,7 +106,7 @@ foreach($databases as $database) {
if(stristr($database, "-vpnusers")) {
$vpnusers = true;
}
- if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) {
+ if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
$captiveportal = true;
}
}
OpenPOWER on IntegriCloud