diff options
-rw-r--r-- | conf.default/config.xml | 2 | ||||
-rw-r--r-- | etc/inc/globals.inc | 2 | ||||
-rw-r--r-- | etc/inc/rrd.inc | 150 | ||||
-rw-r--r-- | etc/inc/upgrade_config.inc | 13 | ||||
-rw-r--r-- | usr/local/bin/captiveportal_gather_stats.php | 8 | ||||
-rwxr-xr-x | usr/local/www/status_rrd_graph.php | 52 | ||||
-rwxr-xr-x | usr/local/www/status_rrd_graph_settings.php | 2 |
7 files changed, 151 insertions, 78 deletions
diff --git a/conf.default/config.xml b/conf.default/config.xml index 5e2134a..93ac0f9 100644 --- a/conf.default/config.xml +++ b/conf.default/config.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- pfSense default system configuration --> <pfsense> - <version>9.2</version> + <version>9.3</version> <lastchange></lastchange> <theme>pfsense_ng</theme> <sysctl> diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 6315a84..ed84cc0 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -77,7 +77,7 @@ $g = array( "disablecrashreporter" => false, "crashreporterurl" => "http://crashreporter.pfsense.org/crash_reporter.php", "debug" => false, - "latest_config" => "9.2", + "latest_config" => "9.3", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "101", "minimum_ram_warning_text" => "128 MB", diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index 61f89a5..6f44396 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -213,7 +213,6 @@ function enable_rrd_graphing() { $vpnusers = "-vpnusers.rrd"; $captiveportalconcurrent = "-concurrent.rrd"; $captiveportalloggedin = "-loggedin.rrd"; - $captiveportaltotalusers = "-totalusers.rrd"; $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool"; $netstat = "/usr/bin/netstat"; @@ -324,6 +323,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -356,6 +356,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -384,6 +385,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -408,6 +410,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -473,6 +476,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } if (!file_exists("$rrddbpath$ifname$queuesdrop")) { @@ -489,6 +493,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } if($g['booting']) { @@ -555,6 +560,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -588,6 +594,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -622,6 +629,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -659,6 +667,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:MAX:0.5:720:3000"; create_new_rrd($rrdcreate); + unset($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ @@ -696,6 +705,7 @@ function enable_rrd_graphing() { $rrdcreate .= "RRA:MAX:0.5:720:3000 "; create_new_rrd($rrdcreate); + unset($rrdcreate); } $rrdupdatesh .= "\n"; @@ -707,77 +717,85 @@ function enable_rrd_graphing() { /* End System statistics */ /* Captive Portal statistics, set up the rrd file */ - if(isset($config['captiveportal']['enable'])) { - $ifname= "captiveportal"; - if (!file_exists("$rrddbpath$ifname$captiveportalconcurrent")) { - $rrdcreate = "$rrdtool create $rrddbpath$ifname$captiveportalconcurrent --step $rrdcaptiveportalinterval "; - $rrdcreate .= "DS:concurrentusers:GAUGE:$captiveportalvalid:0:10000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; - $rrdcreate .= "RRA:MIN:0.5:1:1000 "; - $rrdcreate .= "RRA:MIN:0.5:5:1000 "; - $rrdcreate .= "RRA:MIN:0.5:60:1000 "; - $rrdcreate .= "RRA:MIN:0.5:720:3000 "; - $rrdcreate .= "RRA:MAX:0.5:1:1000 "; - $rrdcreate .= "RRA:MAX:0.5:5:1000 "; - $rrdcreate .= "RRA:MAX:0.5:60:1000 "; - $rrdcreate .= "RRA:MAX:0.5:720:3000 "; - $rrdcreate .= "RRA:LAST:0.5:1:1000 "; - $rrdcreate .= "RRA:LAST:0.5:5:1000 "; - $rrdcreate .= "RRA:LAST:0.5:60:1000 "; - $rrdcreate .= "RRA:LAST:0.5:720:3000 "; + if(is_array($config['captiveportal'])) { + foreach ($config['captiveportal'] as $cpkey => $cp) { + if (!isset($cp['enable'])) + continue; + + $ifname= "captiveportal"; + $concurrent_filename = $rrddbpath . $ifname . '-' . $cpkey . $captiveportalconcurrent; + if (!file_exists("$concurrent_filename")) { + $rrdcreate = "$rrdtool create $concurrent_filename --step $rrdcaptiveportalinterval "; + $rrdcreate .= "DS:concurrentusers:GAUGE:$captiveportalvalid:0:10000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; + $rrdcreate .= "RRA:MIN:0.5:1:1000 "; + $rrdcreate .= "RRA:MIN:0.5:5:1000 "; + $rrdcreate .= "RRA:MIN:0.5:60:1000 "; + $rrdcreate .= "RRA:MIN:0.5:720:3000 "; + $rrdcreate .= "RRA:MAX:0.5:1:1000 "; + $rrdcreate .= "RRA:MAX:0.5:5:1000 "; + $rrdcreate .= "RRA:MAX:0.5:60:1000 "; + $rrdcreate .= "RRA:MAX:0.5:720:3000 "; + $rrdcreate .= "RRA:LAST:0.5:1:1000 "; + $rrdcreate .= "RRA:LAST:0.5:5:1000 "; + $rrdcreate .= "RRA:LAST:0.5:60:1000 "; + $rrdcreate .= "RRA:LAST:0.5:720:3000 "; - create_new_rrd($rrdcreate); - } + create_new_rrd($rrdcreate); + unset($rrdcreate); + } - /* enter UNKNOWN values in the RRD so it knows we rebooted. */ - if($g['booting']) { - mwexec("$rrdtool update $rrddbpath$ifname$captiveportalconcurrent N:U"); - } + /* enter UNKNOWN values in the RRD so it knows we rebooted. */ + if($g['booting']) { + mwexec("$rrdtool update $concurrent_filename N:U"); + } - /* the Captive Portal stats gathering function. */ - $rrdupdatesh .= "\n"; - $rrdupdatesh .= "# polling Captive Portal for number of concurrent users\n"; - $rrdupdatesh .= "CP=`$php -q $captiveportal_gather concurrent`\n"; - $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportalconcurrent \${CP}\n"; - - $ifname= "captiveportal"; - if (!file_exists("$rrddbpath$ifname$captiveportalloggedin")) { - $rrdcreate = "$rrdtool create $rrddbpath$ifname$captiveportalloggedin --step $rrdcaptiveportalinterval "; - $rrdcreate .= "DS:loggedinusers:GAUGE:$captiveportalvalid:0:10000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; - $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; - $rrdcreate .= "RRA:MIN:0.5:1:1000 "; - $rrdcreate .= "RRA:MIN:0.5:5:1000 "; - $rrdcreate .= "RRA:MIN:0.5:60:1000 "; - $rrdcreate .= "RRA:MIN:0.5:720:3000 "; - $rrdcreate .= "RRA:MAX:0.5:1:1000 "; - $rrdcreate .= "RRA:MAX:0.5:5:1000 "; - $rrdcreate .= "RRA:MAX:0.5:60:1000 "; - $rrdcreate .= "RRA:MAX:0.5:720:3000 "; - $rrdcreate .= "RRA:LAST:0.5:1:1000 "; - $rrdcreate .= "RRA:LAST:0.5:5:1000 "; - $rrdcreate .= "RRA:LAST:0.5:60:1000 "; - $rrdcreate .= "RRA:LAST:0.5:720:3000 "; + /* the Captive Portal stats gathering function. */ + $rrdupdatesh .= "\n"; + $rrdupdatesh .= "# polling Captive Portal for number of concurrent users\n"; + $rrdupdatesh .= "CP=`$php -q $captiveportal_gather '$cpkey' $concurrent`\n"; + $rrdupdatesh .= "$rrdtool update $concurrent_filename \${CP}\n"; + + $loggedin_filename = $rrddbpath . $ifname . '-' . $cpkey . $captiveportalloggedin; + if (!file_exists("$loggedin_filename")) { + $rrdcreate = "$rrdtool create $loggedin_filename --step $rrdcaptiveportalinterval "; + $rrdcreate .= "DS:loggedinusers:GAUGE:$captiveportalvalid:0:10000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; + $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; + $rrdcreate .= "RRA:MIN:0.5:1:1000 "; + $rrdcreate .= "RRA:MIN:0.5:5:1000 "; + $rrdcreate .= "RRA:MIN:0.5:60:1000 "; + $rrdcreate .= "RRA:MIN:0.5:720:3000 "; + $rrdcreate .= "RRA:MAX:0.5:1:1000 "; + $rrdcreate .= "RRA:MAX:0.5:5:1000 "; + $rrdcreate .= "RRA:MAX:0.5:60:1000 "; + $rrdcreate .= "RRA:MAX:0.5:720:3000 "; + $rrdcreate .= "RRA:LAST:0.5:1:1000 "; + $rrdcreate .= "RRA:LAST:0.5:5:1000 "; + $rrdcreate .= "RRA:LAST:0.5:60:1000 "; + $rrdcreate .= "RRA:LAST:0.5:720:3000 "; - create_new_rrd($rrdcreate); - } + create_new_rrd($rrdcreate); + unset($rrdcreate); + } - /* enter UNKNOWN values in the RRD so it knows we rebooted. */ - if($g['booting']) { - mwexec("$rrdtool update $rrddbpath$ifname$captiveportalloggedin N:U"); - } + /* enter UNKNOWN values in the RRD so it knows we rebooted. */ + if($g['booting']) { + mwexec("$rrdtool update $loggedin_filename N:U"); + } - /* the Captive Portal stats gathering function. */ - $rrdupdatesh .= "\n"; - $rrdupdatesh .= "# polling Captive Portal for number of logged in users\n"; - $rrdupdatesh .= "CP=`$php -q $captiveportal_gather loggedin`\n"; - $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportalloggedin \${CP}\n"; + /* the Captive Portal stats gathering function. */ + $rrdupdatesh .= "\n"; + $rrdupdatesh .= "# polling Captive Portal for number of logged in users\n"; + $rrdupdatesh .= "CP=`$php -q $captiveportal_gather $cpkey loggedin`\n"; + $rrdupdatesh .= "$rrdtool update $loggedin_filename \${CP}\n"; + } } $rrdupdatesh .= "sleep 60\n"; @@ -789,6 +807,8 @@ function enable_rrd_graphing() { fwrite($fd, "$rrdupdatesh"); fclose($fd); + unset($rrdupdatesh); + /* kill off traffic collectors */ kill_traffic_collector(); diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index 608ce09..113c311 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -2979,4 +2979,17 @@ function upgrade_091_to_092() { } } +function upgrade_092_to_093() { + global $g; + + $suffixes = array("concurrent", "loggedin"); + + foreach ($suffixes as $suffix) + if (file_exists("{$g['vardb_path']}/rrd/captiveportal-{$suffix}.rrd")) + rename("{$g['vardb_path']}/rrd/captiveportal-{$suffix}.rrd", + "{$g['vardb_path']}/rrd/captiveportal-cpZone-{$suffix}.rrd"); + + enable_rrd_graphing(); +} + ?> 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; } } |