summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Baker <warren@decoy.co.za>2011-03-17 12:21:01 +0200
committerWarren Baker <warren@decoy.co.za>2011-03-17 12:21:01 +0200
commit7e5f3edbf67907370c280330855ccbfc00802fec (patch)
tree92190c077bb148e1c6d592ed4173f352757c0116
parentaf4c040e43f2c2e7bd2701b106fa7bf6aac288cd (diff)
downloadpfsense-7e5f3edbf67907370c280330855ccbfc00802fec.zip
pfsense-7e5f3edbf67907370c280330855ccbfc00802fec.tar.gz
Add Total number of CP users graph
-rw-r--r--etc/inc/rrd.inc43
-rw-r--r--usr/local/www/status_rrd_graph_img.php22
2 files changed, 62 insertions, 3 deletions
diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc
index 58c4df1..c45e885 100644
--- a/etc/inc/rrd.inc
+++ b/etc/inc/rrd.inc
@@ -177,6 +177,7 @@ 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";
@@ -673,7 +674,7 @@ function enable_rrd_graphing() {
/* Captive Portal statistics, set up the rrd file */
if(isset($config['captiveportal']['enable'])) {
$ifname= "captiveportal";
- if (!file_exists("$rrddbpath$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 ";
@@ -708,7 +709,7 @@ function enable_rrd_graphing() {
$rrdupdatesh .= "`$php -q $captiveportal_gather concurrent`\n";
$ifname= "captiveportal";
- if (!file_exists("$rrddbpath$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 ";
@@ -738,9 +739,45 @@ function enable_rrd_graphing() {
/* the Captive Portal stats gathering function. */
$rrdupdatesh .= "\n";
- $rrdupdatesh .= "# polling Captive Portal for number of logged in users and concurrent users\n";
+ $rrdupdatesh .= "# polling Captive Portal for number of logged in users\n";
$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportalloggedin \\\n";
$rrdupdatesh .= "`$php -q $captiveportal_gather loggedin`\n";
+
+ $ifname= "captiveportal";
+ if (!file_exists("$rrddbpath$ifname$captiveportaltotalusers")) {
+ $rrdcreate = "$rrdtool create $rrddbpath$ifname$captiveportaltotalusers --step $rrdcaptiveportalinterval ";
+ $rrdcreate .= "DS:totalusers:GAUGE:$captiveportalvalid:0:10000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:5:1100 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:60:1175 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
+ $rrdcreate .= "RRA:MIN:0.5:1:1000 ";
+ $rrdcreate .= "RRA:MIN:0.5:5:1100 ";
+ $rrdcreate .= "RRA:MIN:0.5:60:1175 ";
+ $rrdcreate .= "RRA:MIN:0.5:720:3000 ";
+ $rrdcreate .= "RRA:MAX:0.5:1:1000 ";
+ $rrdcreate .= "RRA:MAX:0.5:5:1100 ";
+ $rrdcreate .= "RRA:MAX:0.5:60:1175 ";
+ $rrdcreate .= "RRA:MAX:0.5:720:3000 ";
+ $rrdcreate .= "RRA:LAST:0.5:1:1000 ";
+ $rrdcreate .= "RRA:LAST:0.5:5:1100 ";
+ $rrdcreate .= "RRA:LAST:0.5:60:1175 ";
+ $rrdcreate .= "RRA:LAST:0.5:720:3000 ";
+
+ create_new_rrd($rrdcreate);
+ }
+
+ /* enter UNKNOWN values in the RRD so it knows we rebooted. */
+ if($g['booting']) {
+ mwexec("$rrdtool update $rrddbpath$ifname$captiveportaltotalusers N:U");
+ }
+
+ /* the Captive Portal stats gathering function. */
+ $rrdupdatesh .= "\n";
+ $rrdupdatesh .= "# polling Captive Portal for number of concurrent users\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportaltotalusers \\\n";
+ $rrdupdatesh .= "`$php -q $captiveportal_gather total`\n";
+
}
$rrdupdatesh .= "sleep 60\n";
diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php
index dccdecc..2094a87 100644
--- a/usr/local/www/status_rrd_graph_img.php
+++ b/usr/local/www/status_rrd_graph_img.php
@@ -960,6 +960,28 @@ elseif((strstr($curdatabase, "-concurrent.rrd")) && (file_exists("$rrddbpath$cur
$graphcmd .= "COMMENT:\"\\n\" ";
$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" ";
}
+elseif((strstr($curdatabase, "-totalusers.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 ";
+ $graphcmd .= "--vertical-label \"Total Captive Portal Users\" ";
+ $graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
+ $graphcmd .= "--base=1000 ";
+ $graphcmd .= "--lower-limit=0 ";
+ $graphcmd .= "--slope-mode ";
+ $graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
+ $graphcmd .= "--height 200 --width 620 ";
+ $graphcmd .= "DEF:\"$curif-totalusers=$rrddbpath$curdatabase:totalusers:AVERAGE\" ";
+ $graphcmd .= "AREA:\"$curif-totalusers#{$colorcaptiveportalusers[0]}:$curif-totalusers\" ";
+ $graphcmd .= "COMMENT:\"\\n\" ";
+ $graphcmd .= "COMMENT:\"\t\t\t current\t\t average\t maximum\\n\" ";
+ $graphcmd .= "COMMENT:\"Users Online\t\" ";
+ $graphcmd .= "GPRINT:\"$curif-totalusers:LAST:%8.0lf \" ";
+ $graphcmd .= "GPRINT:\"$curif-totalusers:AVERAGE:%8.0lf \" ";
+ $graphcmd .= "GPRINT:\"$curif-totalusers:MAX:%8.0lf \" ";
+ $graphcmd .= "COMMENT:\"\\n\" ";
+ $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" ";
+}
else {
$data = false;
log_error(sprintf(gettext("Sorry we do not have data to graph for %s"),$curdatabase));
OpenPOWER on IntegriCloud