summaryrefslogtreecommitdiffstats
path: root/etc/inc/rrd.inc
diff options
context:
space:
mode:
authorVinicius Coque <vinicius.coque@bluepex.com>2011-03-25 08:59:29 -0300
committerVinicius Coque <vinicius.coque@bluepex.com>2011-03-25 08:59:29 -0300
commit152ab4d0c036889d5d983cef0f612c2dcf211e7b (patch)
tree2120aa2834d2b0218a8bede4629aaac4acfbd5ec /etc/inc/rrd.inc
parent54bdff758f68e2e1b1ebd42b8b0b629b68ed1a3d (diff)
parentd93ee937f2305f06148d972be92224a2a52ba9e5 (diff)
downloadpfsense-152ab4d0c036889d5d983cef0f612c2dcf211e7b.zip
pfsense-152ab4d0c036889d5d983cef0f612c2dcf211e7b.tar.gz
Merge remote-tracking branch 'mainline/master' into inc
Conflicts: etc/inc/interfaces.inc etc/inc/priv.defs.inc etc/inc/shaper.inc etc/inc/system.inc
Diffstat (limited to 'etc/inc/rrd.inc')
-rw-r--r--etc/inc/rrd.inc77
1 files changed, 57 insertions, 20 deletions
diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc
index 35c461c..629e0df 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";
@@ -185,7 +186,7 @@ function enable_rrd_graphing() {
$pfctl = "/sbin/pfctl";
$sysctl = "/sbin/sysctl";
$php = "/usr/local/bin/php";
- $top = "/usr/bin/top";
+ $cpustats = "/usr/local/sbin/cpustats";
$spamd_gather = "/usr/local/bin/spamd_gather_stats.php";
$ifconfig = "/sbin/ifconfig";
$captiveportal_gather = "/usr/local/bin/captiveportal_gather_stats.php";
@@ -355,8 +356,8 @@ function enable_rrd_graphing() {
$rrdupdatesh .= "\n";
$rrdupdatesh .= "# polling wireless for interface $ifname $realif \n";
- $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$wireless N:\\\n";
- $rrdupdatesh .= "`$ifconfig {$realif} list sta| $awk 'gsub(\"M\", \"\") {getline 2;print substr(\$5, 0, length(\$5)-2) \":\" $4 \":\" $3}'`\n";
+ $rrdupdatesh .= "WIFI=`$ifconfig {$realif} list sta| $awk 'gsub(\"M\", \"\") {getline 2;print substr(\$5, 0, length(\$5)-2) \":\" $4 \":\" $3}'`\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$wireless N:${WIFI}\n";
}
/* OpenVPN, set up the rrd file */
@@ -393,8 +394,8 @@ function enable_rrd_graphing() {
$rrdupdatesh .= " sleep 0.2\n";
$rrdupdatesh .= " echo \"quit\"\n";
$rrdupdatesh .= "}\n";
- $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$vpnusers N:\\\n";
- $rrdupdatesh .= "`list_current_users | nc -U {$g['varetc_path']}/openvpn/server{$vpnid}.sock | awk -F\",\" '/^CLIENT_LIST/ {print \$2}' | wc -l | awk '{print $1}'` &\n";
+ $rrdupdatesh .= "OVPN=`list_current_users | nc -U {$g['varetc_path']}/openvpn/server{$vpnid}.sock | awk -F\",\" '/^CLIENT_LIST/ {print \$2}' | wc -l | awk '{print $1}'` &\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$vpnusers N:\${OVPN}\n";
}
/* QUEUES, set up the queues databases */
@@ -566,11 +567,10 @@ function enable_rrd_graphing() {
}
/* the CPU stats gathering function. */
- $rrdupdatesh .= "`$top -d 2 -s 1 0 | $awk '{gsub(/%/, \"\")} BEGIN { \\\n";
- $rrdupdatesh .= "printf \"$rrdtool update $rrddbpath$ifname$proc \" } \\\n";
- $rrdupdatesh .= "{ if ( \$2 == \"processes:\" ) { processes = \$1; } \\\n";
- $rrdupdatesh .= "else if ( \$1 == \"CPU:\" ) { user = \$2; nice = \$4; sys = \$6; interrupt = \$8; } \\\n";
- $rrdupdatesh .= "} END { printf \"N:\"user\":\"nice\":\"sys\":\"interrupt\":\"processes }'`\n\n";
+ $rrdupdatesh .= "CPU=`$cpustats | cut -f1-4 -d':'`\n";
+ /* Using ps uxaH will count all processes including system threads. Top was undercounting. */
+ $rrdupdatesh .= "PROCS=`ps uxaH | wc -l | awk '{print \$1;}'`\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$proc N:\${CPU}:\${PROCS}\n";
/* End CPU statistics */
@@ -604,9 +604,10 @@ function enable_rrd_graphing() {
}
/* the Memory stats gathering function. */
- $rrdupdatesh .= "`$sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_free_count vm.stats.vm.v_cache_count vm.stats.vm.v_wire_count | ";
- $rrdupdatesh .= " $awk '{getline active;getline inactive;getline free;getline cache;getline wire;printf \"$rrdtool update $rrddbpath$ifname$mem N:\"";
- $rrdupdatesh .= "((active/$0) * 100)\":\"((inactive/$0) * 100)\":\"((free/$0) * 100)\":\"((cache/$0) * 100)\":\"(wire/$0 * 100)}'`\n\n";
+ $rrdupdatesh .= "MEM=`$sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_free_count vm.stats.vm.v_cache_count vm.stats.vm.v_wire_count | ";
+ $rrdupdatesh .= " $awk '{getline active;getline inactive;getline free;getline cache;getline wire;printf ";
+ $rrdupdatesh .= "((active/$0) * 100)\":\"((inactive/$0) * 100)\":\"((free/$0) * 100)\":\"((cache/$0) * 100)\":\"(wire/$0 * 100)}'`\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$mem N:\${MEM}\n";
/* End Memory statistics */
@@ -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 ";
@@ -704,11 +705,11 @@ function enable_rrd_graphing() {
/* the Captive Portal stats gathering function. */
$rrdupdatesh .= "\n";
$rrdupdatesh .= "# polling Captive Portal for number of concurrent users\n";
- $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportalconcurrent \\\n";
- $rrdupdatesh .= "`$php -q $captiveportal_gather concurrent`\n";
+ $rrdupdatesh .= "CP=`$php -q $captiveportal_gather concurrent`\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportalconcurrent \${CP}\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 .= "$rrdtool update $rrddbpath$ifname$captiveportalloggedin \\\n";
- $rrdupdatesh .= "`$php -q $captiveportal_gather loggedin`\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";
+
+ $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 .= "CP=`$php -q $captiveportal_gather total`\n";
+ $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$captiveportaltotalusers \${CP}\n";
+
}
$rrdupdatesh .= "sleep 60\n";
OpenPOWER on IntegriCloud