diff options
author | nagyrobi <robreg@zsurob.hu> | 2014-02-18 15:06:27 +0100 |
---|---|---|
committer | nagyrobi <robreg@zsurob.hu> | 2014-02-18 15:06:27 +0100 |
commit | 1f3eff9b66f478cfae48ada6e358eb59811fb5b0 (patch) | |
tree | a91e492cc9a2cd56ea43b730f6ba456b7e511e1e /etc | |
parent | 6766e4771ef6582212044ab8938f4757776618a4 (diff) | |
download | pfsense-1f3eff9b66f478cfae48ada6e358eb59811fb5b0.zip pfsense-1f3eff9b66f478cfae48ada6e358eb59811fb5b0.tar.gz |
Update rrd.inc
Add NTP graphing to RRD
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/rrd.inc | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index 16d7aaa..1c424ed 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -220,6 +220,7 @@ function enable_rrd_graphing() { $vpnusers = "-vpnusers.rrd"; $captiveportalconcurrent = "-concurrent.rrd"; $captiveportalloggedin = "-loggedin.rrd"; + $ntpd = "ntpd.rrd"; $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool"; $netstat = "/usr/bin/netstat"; @@ -232,6 +233,7 @@ function enable_rrd_graphing() { $spamd_gather = "/usr/local/bin/spamd_gather_stats.php"; $ifconfig = "/sbin/ifconfig"; $captiveportal_gather = "/usr/local/bin/captiveportal_gather_stats.php"; + $ntpq = "/usr/local/bin/ntpq"; $rrdtrafficinterval = 60; $rrdwirelessinterval = 60; @@ -247,6 +249,7 @@ function enable_rrd_graphing() { $rrdcellularinterval = 60; $rrdvpninterval = 60; $rrdcaptiveportalinterval = 60; + $rrdntpdinterval = 60; $trafficvalid = $rrdtrafficinterval * 2; $wirelessvalid = $rrdwirelessinterval * 2; @@ -262,6 +265,7 @@ function enable_rrd_graphing() { $cellularvalid = $rrdcellularinterval * 2; $vpnvalid = $rrdvpninterval * 2; $captiveportalvalid = $rrdcaptiveportalinterval * 2; + $ntpdvalid = $rrdntpdinterval * 2; /* Assume 2*10GigE for now */ $downstream = 2500000000; @@ -840,6 +844,56 @@ function enable_rrd_graphing() { } } + /* End Captive Portal statistics */ + + /* NTP, set up the ntpd rrd file */ + if (isset($config['ntpd']['statsgraph'])) { + /* set up the ntpd rrd file */ + if (!file_exists("$rrddbpath$ifname$ntpd")) { + $rrdcreate = "$rrdtool create $rrddbpath$ntpd --step $rrdntpdinterval "; + $rrdcreate .= "DS:offset:GAUGE:$ntpdvalid:0:1000 "; + $rrdcreate .= "DS:sjit:GAUGE:$ntpdvalid:0:1000 "; + $rrdcreate .= "DS:cjit:GAUGE:$ntpdvalid:0:1000 "; + $rrdcreate .= "DS:wander:GAUGE:$ntpdvalid:0:1000 "; + $rrdcreate .= "DS:freq:GAUGE:$ntpdvalid:0:1000 "; + $rrdcreate .= "DS:disp:GAUGE:$ntpdvalid:0:1000 "; + $rrdcreate .= "RRA:MIN:0.5:1:1200 "; + $rrdcreate .= "RRA:MIN:0.5:5:720 "; + $rrdcreate .= "RRA:MIN:0.5:60:1860 "; + $rrdcreate .= "RRA:MIN:0.5:1440:2284 "; + $rrdcreate .= "RRA:AVERAGE:0.5:1:1200 "; + $rrdcreate .= "RRA:AVERAGE:0.5:5:720 "; + $rrdcreate .= "RRA:AVERAGE:0.5:60:1860 "; + $rrdcreate .= "RRA:AVERAGE:0.5:1440:2284 "; + $rrdcreate .= "RRA:MAX:0.5:1:1200 "; + $rrdcreate .= "RRA:MAX:0.5:5:720 "; + $rrdcreate .= "RRA:MAX:0.5:60:1860 "; + $rrdcreate .= "RRA:MAX:0.5:1440:2284 "; + + create_new_rrd($rrdcreate); + unset($rrdcreate); + } + + /* enter UNKNOWN values in the RRD so it knows we rebooted. */ + if($g['booting']) { + mwexec("$rrdtool update $rrddbpath$ntpd N:U"); + } + + /* the ntp stats gathering function. */ + $rrdupdatesh .= "\n"; + $rrdupdatesh .= "$ntpq -c rv | $awk 'BEGIN{ RS=\",\"}{ print }' >> /tmp/ntp-rrdstats.$$\n"; + $rrdupdatesh .= "NOFFSET=`grep offset /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS=\"=\"}{print $2}'`\n"; + $rrdupdatesh .= "NFREQ=`grep frequency /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS=\"=\"}{print $2}'`\n"; + $rrdupdatesh .= "NSJIT=`grep sys_jitter /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS=\"=\"}{print $2}'`\n"; + $rrdupdatesh .= "NCJIT=`grep clk_jitter /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS=\"=\"}{print $2}'`\n"; + $rrdupdatesh .= "NWANDER=`grep clk_wander /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS=\"=\"}{print $2}'`\n"; + $rrdupdatesh .= "NDISPER=`grep rootdisp /tmp/ntp-rrdstats.$$ | awk 'BEGIN{FS=\"=\"}{print $2}'`\n"; + $rrdupdatesh .= "$rrdtool update $rrddbpath$ntpd \N:\${NOFFSET}:\${NSJIT}:\${NCJIT}:\${NWANDER}:\${NFREQ}:\${NDISPER}\n"; + $rrdupdatesh .= "rm /tmp/ntp-rrdstats.$$\n"; + $rrdupdatesh .= "\n"; + + } + /* End NTP statistics */ $rrdupdatesh .= "sleep 60\n"; $rrdupdatesh .= "done\n"; |