summaryrefslogtreecommitdiffstats
path: root/etc/inc/rrd.inc
diff options
context:
space:
mode:
Diffstat (limited to 'etc/inc/rrd.inc')
-rw-r--r--etc/inc/rrd.inc150
1 files changed, 85 insertions, 65 deletions
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();
OpenPOWER on IntegriCloud