summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2008-03-26 17:05:17 +0000
committerSeth Mos <seth.mos@xs4all.nl>2008-03-26 17:05:17 +0000
commitf8e70893a187c890366ce86321e6524fe1b469c4 (patch)
tree4deb6a1266cf9239c2e9ee64122e6cf875aade5d
parent9583e25bb56315ee460bc9580e0707ea54ba6698 (diff)
downloadpfsense-f8e70893a187c890366ce86321e6524fe1b469c4.zip
pfsense-f8e70893a187c890366ce86321e6524fe1b469c4.tar.gz
Add detailed memory usage RRD graph.
Modifications by Nathan Moinvaziri (nathan@nathanm.com) to add
-rw-r--r--etc/inc/pfsense-utils.inc46
-rw-r--r--usr/local/www/status_rrd_graph_img.php53
-rw-r--r--usr/local/www/themes/_orange-flow/rrdcolors.inc.php1
-rw-r--r--usr/local/www/themes/metallic/rrdcolors.inc.php1
-rw-r--r--usr/local/www/themes/nervecenter/rrdcolors.inc.php1
-rw-r--r--usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php1
-rw-r--r--usr/local/www/themes/pfsense/rrdcolors.inc.php1
7 files changed, 104 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index c3906e8..3fe2e75 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -3031,12 +3031,14 @@ function enable_rrd_graphing() {
$queuesdrop = "-queuedrops.rrd";
$spamd = "-spamd.rrd";
$proc = "-processor.rrd";
+ $mem = "-memory.rrd";
$rrdtool = "/usr/local/bin/rrdtool";
$netstat = "/usr/bin/netstat";
$awk = "/usr/bin/awk";
$tar = "/usr/bin/tar";
$pfctl = "/sbin/pfctl";
+ $sysctl = "/sbin/sysctl";
$php = "/usr/local/bin/php";
$top = "/usr/bin/top";
$spamd_gather = "/usr/local/bin/spamd_gather_stats.php";
@@ -3052,6 +3054,7 @@ function enable_rrd_graphing() {
$rrdspamdinterval = 60;
$rrdlbpoolinterval = 60;
$rrdprocinterval = 60;
+ $rrdmeminterval = 60;
$trafficvalid = $rrdtrafficinterval * 2;
$qualityvalid = $rrdqualityinterval * 2;
@@ -3063,6 +3066,7 @@ function enable_rrd_graphing() {
$spamdvalid = $rrdspamdinterval * 2;
$lbpoolvalid = $rrdlbpoolinterval * 2;
$procvalid = $rrdlbpoolinterval * 2;
+ $memvalid = $rrdmeminterval * 2;
/* Asume GigE for now */
$downstream = 125000000;
@@ -3494,6 +3498,48 @@ function enable_rrd_graphing() {
/* End CPU statistics */
+ /* Memory, create Memory statistics database */
+ if(! file_exists("$rrddbpath$ifname$mem")) {
+ /* create rrd file if it does not exist */
+ log_error("Create RRD database $rrddbpath$ifname$mem");
+ $rrdcreate = "$rrdtool create $rrddbpath$ifname$mem --step $rrdmeminterval ";
+ $rrdcreate .= "DS:active:GAUGE:$memvalid:0:10000000 ";
+ $rrdcreate .= "DS:inactive:GAUGE:$memvalid:0:10000000 ";
+ $rrdcreate .= "DS:free:GAUGE:$memvalid:0:10000000 ";
+ $rrdcreate .= "DS:cache:GAUGE:$memvalid:0:10000000 ";
+ $rrdcreate .= "DS:wire:GAUGE:$memvalid:0:10000000 ";
+ $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:1000 ";
+ $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:1000 ";
+ $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:1000";
+
+ $rrdcreatel = exec("$rrdcreate 2>&1", $rrdcreateoutput, $rrdcreatereturn);
+ if($rrdcreatereturn != 0) {
+ log_error("RRD create failed exited with $rrdcreatereturn, the
+ error is: $rrdcreateoutput[0]\n");
+ }
+ }
+
+ /* enter UNKNOWN values in the RRD so it knows we rebooted. */
+ if($g['booting']) {
+ exec("$rrdtool update $rrddbpath$ifname$mem N:U:U:U:U:U");
+ }
+
+ /* 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";
+
+ /* End Memory statistics */
+
/* SPAMD, set up the spamd rrd file */
if (isset($config['installedpackages']['spamdsettings']) &&
isset ($config['installedpackages']['spamdsettings']['config'][0]['enablerrd'])) {
diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php
index 200a8b5..2a8cdd2 100644
--- a/usr/local/www/status_rrd_graph_img.php
+++ b/usr/local/www/status_rrd_graph_img.php
@@ -147,6 +147,7 @@ if(file_exists($rrdcolors)) {
$colorpacketsdown = "990000";
$colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
+ $colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorqueuesup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
$colorqueuesdown = array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
$colorqueuesdropup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
@@ -495,6 +496,58 @@ elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curd
COMMENT:\"\\n\"\\
COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\"";
}
+elseif((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
+ /* define graphcmd for memory usage stats */
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\
+ --start -$seconds -e -$average \\
+ --vertical-label \"utilization, percent\" \\
+ --color SHADEA#eeeeee --color SHADEB#eeeeee \\
+ --title \"`hostname` - $prettydb - $hperiod - $havg average\" \\
+ --height 200 --width 620 -x \"$scale\" \\
+ DEF:active=$rrddbpath$curdatabase:active:AVERAGE \\
+ DEF:inactive=$rrddbpath$curdatabase:inactive:AVERAGE \\
+ DEF:free=$rrddbpath$curdatabase:free:AVERAGE \\
+ DEF:cache=$rrddbpath$curdatabase:cache:AVERAGE \\
+ DEF:wire=$rrddbpath$curdatabase:wire:AVERAGE \\
+ LINE2:active#{$colormemory[0]}:active \\
+ LINE2:inactive#{$colormemory[1]}:inactive \\
+ LINE2:free#{$colormemory[2]}:free \\
+ LINE2:cache#{$colormemory[3]}:cache \\
+ LINE2:wire#{$colormemory[4]}:wire \\
+ COMMENT:\"\\n\"\\
+ COMMENT:\"\t\t minimum average maximum current\\n\"\\
+ COMMENT:\"Active. \"\\
+ GPRINT:active:MIN:'%7.2lf %s '\\
+ GPRINT:active:AVERAGE:'%7.2lf %s '\\
+ GPRINT:active:MAX:'%7.2lf %s '\\
+ GPRINT:active:LAST:'%7.2lf %S '\\
+ COMMENT:\"\\n\"\\
+ COMMENT:\"Inactive. \"\\
+ GPRINT:inactive:MIN:'%7.2lf %s '\\
+ GPRINT:inactive:AVERAGE:'%7.2lf %s '\\
+ GPRINT:inactive:MAX:'%7.2lf %s '\\
+ GPRINT:inactive:LAST:'%7.2lf %S '\\
+ COMMENT:\"\\n\"\\
+ COMMENT:\"Free. \"\\
+ GPRINT:free:MIN:'%7.2lf %s '\\
+ GPRINT:free:AVERAGE:'%7.2lf %s '\\
+ GPRINT:free:MAX:'%7.2lf %s '\\
+ GPRINT:free:LAST:'%7.2lf %S '\\
+ COMMENT:\"\\n\"\\
+ COMMENT:\"Cached. \"\\
+ GPRINT:cache:MIN:'%7.2lf %s '\\
+ GPRINT:cache:AVERAGE:'%7.2lf %s '\\
+ GPRINT:cache:MAX:'%7.2lf %s '\\
+ GPRINT:cache:LAST:'%7.2lf %S '\\
+ COMMENT:\"\\n\"\\
+ COMMENT:\"Wired. \"\\
+ GPRINT:wire:MIN:'%7.2lf %s '\\
+ GPRINT:wire:AVERAGE:'%7.2lf %s '\\
+ GPRINT:wire:MAX:'%7.2lf %s '\\
+ GPRINT:wire:LAST:'%7.2lf %S '\\
+ COMMENT:\"\\n\"\\
+ COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\"";
+ }
elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for queue stats */
$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\
diff --git a/usr/local/www/themes/_orange-flow/rrdcolors.inc.php b/usr/local/www/themes/_orange-flow/rrdcolors.inc.php
index 3901acb..14eb2cc 100644
--- a/usr/local/www/themes/_orange-flow/rrdcolors.inc.php
+++ b/usr/local/www/themes/_orange-flow/rrdcolors.inc.php
@@ -36,6 +36,7 @@ $colorpacketsup = "666666";
$colorpacketsdown = "990000";
$colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
+$colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorqueuesup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
$colorqueuesdown = array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
$colorqueuesdropup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
diff --git a/usr/local/www/themes/metallic/rrdcolors.inc.php b/usr/local/www/themes/metallic/rrdcolors.inc.php
index 490319f..87343dd 100644
--- a/usr/local/www/themes/metallic/rrdcolors.inc.php
+++ b/usr/local/www/themes/metallic/rrdcolors.inc.php
@@ -36,6 +36,7 @@ $colorpacketsup = "666666";
$colorpacketsdown = "990000";
$colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
+$colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorqueuesup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
$colorqueuesdown = array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
$colorqueuesdropup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
diff --git a/usr/local/www/themes/nervecenter/rrdcolors.inc.php b/usr/local/www/themes/nervecenter/rrdcolors.inc.php
index 490319f..87343dd 100644
--- a/usr/local/www/themes/nervecenter/rrdcolors.inc.php
+++ b/usr/local/www/themes/nervecenter/rrdcolors.inc.php
@@ -36,6 +36,7 @@ $colorpacketsup = "666666";
$colorpacketsdown = "990000";
$colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
+$colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorqueuesup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
$colorqueuesdown = array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
$colorqueuesdropup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
diff --git a/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php b/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php
index 490319f..87343dd 100644
--- a/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php
+++ b/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php
@@ -36,6 +36,7 @@ $colorpacketsup = "666666";
$colorpacketsdown = "990000";
$colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
+$colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorqueuesup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
$colorqueuesdown = array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
$colorqueuesdropup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
diff --git a/usr/local/www/themes/pfsense/rrdcolors.inc.php b/usr/local/www/themes/pfsense/rrdcolors.inc.php
index 490319f..87343dd 100644
--- a/usr/local/www/themes/pfsense/rrdcolors.inc.php
+++ b/usr/local/www/themes/pfsense/rrdcolors.inc.php
@@ -36,6 +36,7 @@ $colorpacketsup = "666666";
$colorpacketsdown = "990000";
$colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
+$colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000');
$colorqueuesup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
$colorqueuesdown = array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
$colorqueuesdropup = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000');
OpenPOWER on IntegriCloud