From d55cba63e730d919f50c398fc07c35138c682ca9 Mon Sep 17 00:00:00 2001 From: N0YB Date: Wed, 19 Feb 2014 18:18:07 -0800 Subject: [PATCH] Fix gateway quality RRD to have the correct granularity and be consistent with the pfSense graphs set. Create gateway quality RRD with settings suitable for pfSense graph set, since apinger uses default step (300) and other settings that are not so good/consistent with the pfSense graphs set. Originally Submitted as Pull Request #672. Resubmitting to Master. --- etc/inc/gwlb.inc | 7 +++++++ etc/inc/rrd.inc | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 27271d72ce..cfcffd0ed0 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -30,6 +30,7 @@ */ require_once("config.inc"); +require_once("rrd.inc"); /* Returns an array of default values used for apinger.conf */ function return_apinger_defaults() { @@ -299,6 +300,11 @@ EOD; $apingerconfig .= $alarmscfg; $apingerconfig .= $apingercfg; + + # Create gateway quality RRD with settings more suitable for pfSense graph set, + # since apinger uses default step (300; 5 minutes) and other settings that don't + # match the pfSense gateway quality graph set. + create_gateway_quality_rrd("{$g['vardb_path']}/rrd/{$gateway['name']}-quality.rrd"); } @file_put_contents("{$g['varetc_path']}/apinger.conf", $apingerconfig); unset($apingerconfig); @@ -310,6 +316,7 @@ EOD; @chown("{$g['vardb_path']}/rrd", "nobody"); + /* Restart apinger process */ if (isvalidpid("{$g['varrun_path']}/apinger.pid")) sigkillbypid("{$g['varrun_path']}/apinger.pid", "HUP"); else { diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index f08ad52594..222c39bed4 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -927,6 +927,33 @@ function enable_rrd_graphing() { } +# Create gateway quality RRD with settings suitable for pfSense graph set. +function create_gateway_quality_rrd($rrd_file) { + $rrdinterval = 60; + $valid = $rrdinterval * 2; + $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool"; + + /* GATEWAY QUALITY, set up the rrd file */ + if (!file_exists("$rrd_file")) { + $rrdcreate = "$rrdtool create $rrd_file --step $rrdinterval "; + $rrdcreate .= "DS:loss:GAUGE:$valid:0:100 "; + $rrdcreate .= "DS:delay:GAUGE:$valid:0:100000 "; + $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 "; + + create_new_rrd($rrdcreate); + unset($rrdcreate); + } + + /* enter UNKNOWN values in the RRD so it knows we rebooted. */ + if($g['booting']) { + mwexec("$rrdtool update $rrd_file N:U:U"); + } + unset($rrdtool, $rrdinterval, $valid, $rrd_file); +} + function kill_traffic_collector() { global $g;