From 0b3613ef17eaeaf7981a65fab57600bf805fb022 Mon Sep 17 00:00:00 2001 From: Denny Page Date: Fri, 12 Feb 2016 19:42:13 -0800 Subject: Add standard deviation to quality rrd files --- src/etc/inc/rrd.inc | 12 ++++++-- src/etc/inc/upgrade_config.inc | 70 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/rrd.inc b/src/etc/inc/rrd.inc index ff1d3e1..45b03a1 100644 --- a/src/etc/inc/rrd.inc +++ b/src/etc/inc/rrd.inc @@ -1008,6 +1008,7 @@ for sock in {$g['varrun_path']}/dpinger_*.sock; do gw=\$(echo "\$t" | awk '{ print \$1 }') delay=\$(echo "\$t" | awk '{ print \$2 }') + stddev=\$(echo "\$t" | awk '{ print \$3 }') loss=\$(echo "\$t" | awk '{ print \$4 }') if echo "\$loss" | grep -Eqv '^[0-9]+\$'; then @@ -1019,20 +1020,27 @@ for sock in {$g['varrun_path']}/dpinger_*.sock; do # Convert delay to millisecond delay=\$(echo "scale=7; \$delay / 1000 / 1000" | /usr/bin/bc) fi + if echo "\$stddev" | grep -Eqv '^[0-9]+\$'; then + stddev="U" + else + # Convert stddev to millisecond + stddev=\$(echo "scale=7; \$stddev / 1000 / 1000" | /usr/bin/bc) + fi if [ ! -f {$rrddbpath}\$gw-quality.rrd ]; then {$rrdtool} create {$rrddbpath}\$gw-quality.rrd --step 60 \\ DS:loss:GAUGE:120:0:100 \\ DS:delay:GAUGE:120:0:100000 \\ + DS:stddev:GAUGE:120:0:100000 \\ RRA:AVERAGE:0.5:1:1200 \\ RRA:AVERAGE:0.5:5:720 \\ RRA:AVERAGE:0.5:60:1860 \\ RRA:AVERAGE:0.5:1440:2284 - {$rrdtool} update {$rrddbpath}\$gw-quality.rrd -t loss:delay N:U:U + {$rrdtool} update {$rrddbpath}\$gw-quality.rrd -t loss:delay:stddev N:U:U:U fi - {$rrdtool} update {$rrddbpath}\$gw-quality.rrd -t loss:delay N:\$loss:\$delay + {$rrdtool} update {$rrddbpath}\$gw-quality.rrd -t loss:delay:stddev N:\$loss:\$delay:\$stddev done EOD; diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index 5ec1870..28e57c3 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -56,6 +56,9 @@ if (!function_exists("dump_rrd_to_xml")) { require("rrd.inc"); } +if (!function_exists("read_altq_config")) { + require("shaper.inc"); +} /* Upgrade functions must be named: * upgrade_XXX_to_YYY @@ -4569,4 +4572,71 @@ function upgrade_143_to_144() { } } +function upgrade_144_to_145() { + // Add standard deviation to the quality rrds + global $config, $g; + + $rrddbpath = "/var/db/rrd"; + $rrdtool = "/usr/local/bin/rrdtool"; + + $awkcmd = "/usr/bin/awk '"; + $awkcmd .= "{\n"; + $awkcmd .= " if (sub(/<\\/v><\\/row>/, \"NaN\") == 0)\n"; + $awkcmd .= " {\n"; + $awkcmd .= " if (/<\\/cdp_prep>/)\n"; + $awkcmd .= " {\n"; + $awkcmd .= " print \" \"\n"; + $awkcmd .= " print \" 0.0000000000e+00 \"\n"; + $awkcmd .= " print \" 0.0000000000e+00 \"\n"; + $awkcmd .= " print \" NaN \"\n"; + $awkcmd .= " print \" 0 \"\n"; + $awkcmd .= " print \" \"\n"; + $awkcmd .= " }\n"; + $awkcmd .= " else if (//)\n"; + $awkcmd .= " {\n"; + $awkcmd .= " print \" \"\n"; + $awkcmd .= " print \" stddev \"\n"; + $awkcmd .= " print \" GAUGE \"\n"; + $awkcmd .= " print \" 120 \"\n"; + $awkcmd .= " print \" 0.0000000000e+00 \"\n"; + $awkcmd .= " print \" 1.0000000000e+05 \\n\"\n"; + $awkcmd .= " print \" \"\n"; + $awkcmd .= " print \" 0 \"\n"; + $awkcmd .= " print \" 0.0000000000e+00 \"\n"; + $awkcmd .= " print \" 0 \"\n"; + $awkcmd .= " print \" \\n\"\n"; + $awkcmd .= " }\n"; + $awkcmd .= " }\n"; + $awkcmd .= " print;\n"; + $awkcmd .= "}'"; + + if ($g['platform'] != $g['product_name']) { + /* restore the databases, if we have one */ + if (restore_rrd()) { + /* Make sure to move the rrd backup out of the way. We will make a new one after converting. */ + @rename("{$g['cf_conf_path']}/rrd.tgz", "{$g['cf_conf_path']}/backup/rrd.tgz"); + } + } + + $databases = return_dir_as_array($rrddbpath, '/-quality\.rrd$/'); + foreach ($databases as $database) { + $xmldump = "{$g['tmp_path']}/{$database}.xml"; + + if (platform_booting()) { + echo "Update RRD database {$database}.\n"; + } + + exec("$rrdtool dump {$rrddbpath}/{$database} | {$awkcmd} > {$xmldump}"); + exec("$rrdtool restore -f {$xmldump} {$rrddbpath}/{$database}"); + @unlink("{$xmldump}"); + } + + if (!platform_booting()) { + enable_rrd_graphing(); + } + /* Let's save the RRD graphs after we run enable RRD graphing */ + /* The function will restore the rrd.tgz so we will save it after */ + exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='{$g['cf_conf_path']}' /etc/rc.backup_rrd.sh"); +} + ?> -- cgit v1.1 From 5045722fd7ed6db29dd1fa0a30bce68f31e051c7 Mon Sep 17 00:00:00 2001 From: Denny Page Date: Sat, 13 Feb 2016 17:23:21 -0800 Subject: Update config version to trigger upgrade of rrd files --- src/etc/inc/globals.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/inc/globals.inc b/src/etc/inc/globals.inc index 3231ac9..69b9d6d 100644 --- a/src/etc/inc/globals.inc +++ b/src/etc/inc/globals.inc @@ -99,7 +99,7 @@ $g = array( "disablecrashreporter" => false, "crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php", "debug" => false, - "latest_config" => "14.4", + "latest_config" => "14.5", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "101", "minimum_ram_warning_text" => "128 MB", -- cgit v1.1 From 81742ea234459c423c7425eb55e65f571419c7d1 Mon Sep 17 00:00:00 2001 From: Denny Page Date: Fri, 19 Feb 2016 12:30:28 -0800 Subject: Add stddev information to the quality graphs. --- src/usr/local/www/status_rrd_graph_img.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/usr/local/www/status_rrd_graph_img.php b/src/usr/local/www/status_rrd_graph_img.php index df3f3c3..ffb2508 100644 --- a/src/usr/local/www/status_rrd_graph_img.php +++ b/src/usr/local/www/status_rrd_graph_img.php @@ -263,6 +263,8 @@ $colorqueuesdropdown = array('000000', '7B7B7B', '999999', 'BBBBBB', 'CCCCCC', ' /* Quality Graph Delay >420, 180-420, 60-180, 20-60, <20, Delay Avg */ $colorqualityrtt = array('990000', 'a83c3c', 'b36666', 'bd9090', 'cccccc', '000000'); +/* Quality Graph Standard Deviation */ +$colorqualitystddev = '55333355'; /* Quality Graph Loss */ $colorqualityloss = 'ee0000'; @@ -1074,29 +1076,36 @@ if ((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdataba --height 200 --width 620 \\ --lower-limit 0 \\ DEF:delayraw=$rrddbpath$curdatabase:delay:AVERAGE:step=$step \\ + DEF:stddevraw=$rrddbpath$curdatabase:stddev:AVERAGE:step=$step \\ DEF:loss=$rrddbpath$curdatabase:loss:AVERAGE:step=$step \\ \"CDEF:delay=delayraw,1000,*\" \\ + \"CDEF:stddev=stddevraw,1000,*\" \\ \"CDEF:loss10=loss,$multiplier,*\" \\ \"CDEF:r0=delay,20,MIN\" \\ \"CDEF:r1=delay,60,MIN\" \\ \"CDEF:r2=delay,180,MIN\" \\ \"CDEF:r3=delay,420,MIN\" \\ - COMMENT:\"\t\t\t\t\tDelay\t\t\t\tPacket loss\\n\" \\ + COMMENT:\"\t\t\t\t\tDelay\t\t\t\tStddev\t\t\t Loss\\n\" \\ AREA:delay#$colorqualityrtt[0]:\"> 420 ms\" \\ - GPRINT:delay:MIN:\"\t\tMin\\: %7.2lf ms\" \\ - GPRINT:loss:MIN:\"\tMin\\: %3.1lf %%\\n\" \\ + GPRINT:delay:MIN:\"\t\t Min\\: %7.2lf ms\" \\ + GPRINT:stddev:MIN:\"\t Min\\: %7.2lf ms\" \\ + GPRINT:loss:MIN:\"\t Min\\: %4.1lf %%\\n\" \\ AREA:r3#$colorqualityrtt[1]:\"180-420 ms\" \\ - GPRINT:delay:AVERAGE:\"\t\tAvg\\: %7.2lf ms\" \\ - GPRINT:loss:AVERAGE:\"\tAvg\\: %3.1lf %%\\n\" \\ + GPRINT:delay:AVERAGE:\"\t\t Avg\\: %7.2lf ms\" \\ + GPRINT:stddev:AVERAGE:\"\t Avg\\: %7.2lf ms\" \\ + GPRINT:loss:AVERAGE:\"\t Avg\\: %4.1lf %%\\n\" \\ AREA:r2#$colorqualityrtt[2]:\"60-180 ms\" \\ - GPRINT:delay:MAX:\"\t\tMax\\: %7.2lf ms\" \\ - GPRINT:loss:MAX:\"\tMax\\: %3.1lf %%\\n\" \\ + GPRINT:delay:MAX:\"\t\t Max\\: %7.2lf ms\" \\ + GPRINT:stddev:MAX:\"\t Max\\: %7.2lf ms\" \\ + GPRINT:loss:MAX:\"\t Max\\: %4.1lf %%\\n\" \\ AREA:r1#$colorqualityrtt[3]:\"20-60 ms\\n\" \\ AREA:r0#$colorqualityrtt[4]:\"< 20 ms\" \\ GPRINT:delay:LAST:\"\t\tLast\\: %7.2lf ms\" \\ - GPRINT:loss:LAST:\"\tLast\: %3.1lf %%\\n\" \\ + GPRINT:stddev:LAST:\"\tLast\\: %7.2lf ms\" \\ + GPRINT:loss:LAST:\"\tLast\: %4.1lf %%\\n\" \\ AREA:loss10#$colorqualityloss:\"Packet loss\\n\" \\ LINE1:delay#$colorqualityrtt[5]:\"Delay average\\n\" \\ + LINE1:stddev#$colorqualitystddev:\"Stddev average\\n\" \\ COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\""; } elseif ((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* graph a spamd statistics graph */ -- cgit v1.1