diff options
author | Renato Botelho <garga@FreeBSD.org> | 2013-02-06 15:52:19 -0200 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2013-02-06 15:54:47 -0200 |
commit | cba9d7d9a5edd4d2b49768a536740b288da99300 (patch) | |
tree | d5818f8a323ed7659d3e8ed0ef02036e87e0801b /etc | |
parent | 2e19a6834fb8b3f2e6f74278be9b9407d7c9d638 (diff) | |
download | pfsense-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 'etc')
-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 |
3 files changed, 99 insertions, 66 deletions
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(); +} + ?> |