From 3339d6164c2333f1a6f529fe346466e90d94194e Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 10 Feb 2015 17:46:44 +0545 Subject: Support mail report of mbuf usage graph Forum report: https://forum.pfsense.org/index.php?topic=82571.0 --- config/mailreport/mail_reports.inc | 51 +++++++++++++++++++++++++++-- config/mailreport/mail_reports_generate.php | 2 +- config/mailreport/mailreport.xml | 2 +- pkg_config.10.xml | 2 +- pkg_config.8.xml | 2 +- pkg_config.8.xml.amd64 | 2 +- 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/config/mailreport/mail_reports.inc b/config/mailreport/mail_reports.inc index 6dddf7cd..669b1541 100644 --- a/config/mailreport/mail_reports.inc +++ b/config/mailreport/mail_reports.inc @@ -286,7 +286,7 @@ function mail_report_generate_graph($database, $style, $graph, $start, $end) { /* this should never happen */ if($end < $start) { - log_error("start $start is smaller than end $end"); + log_error("start $start is greater than end $end"); $end = $now; } @@ -392,7 +392,7 @@ function mail_report_generate_graph($database, $style, $graph, $start, $end) { $speedlimit = ($upstream + $downstream); - /* Set default colors explicity, the theme can then override them below. + /* Set default colors explicitly, the theme can then override them below. This prevents missing colors in themes from crashing the graphs. */ $colortrafficup = array("666666", "CCCCCC"); $colortrafficdown = array("990000", "CC0000"); @@ -402,6 +402,7 @@ function mail_report_generate_graph($database, $style, $graph, $start, $end) { $colorstates = array('990000','a83c3c','b36666','bd9090','cccccc','000000'); $colorprocessor = array('990000','a83c3c','b36666','bd9090','cccccc','000000'); $colormemory = array('990000','a83c3c','b36666','bd9090','cccccc','000000'); + $colormbuf = 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'); @@ -718,7 +719,7 @@ function mail_report_generate_graph($database, $style, $graph, $start, $end) { $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; } elseif((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { - /* define graphcmd for packets stats */ + /* define graphcmd for wireless stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end "; $graphcmd .= "--vertical-label \"snr/channel/rate\" "; @@ -927,6 +928,50 @@ function mail_report_generate_graph($database, $style, $graph, $start, $end) { $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; } + elseif((strstr($curdatabase, "-mbuf.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { + /* define graphcmd for mbuf usage stats */ + $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; + $graphcmd .= "--start $start --end $end "; + $graphcmd .= "--vertical-label \"utilization, percent\" "; + $graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee "; + $graphcmd .= "--title \"`hostname` - {$prettydb} clusters - {$hperiod} - {$havg} average\" "; + $graphcmd .= "--height 200 --width 620 "; + $graphcmd .= "DEF:\"current=$rrddbpath$curdatabase:current:AVERAGE\" "; + $graphcmd .= "DEF:\"cache=$rrddbpath$curdatabase:cache:AVERAGE\" "; + $graphcmd .= "DEF:\"total=$rrddbpath$curdatabase:total:AVERAGE\" "; + $graphcmd .= "DEF:\"max=$rrddbpath$curdatabase:max:AVERAGE\" "; + $graphcmd .= "LINE2:\"current#{$colormbuf[0]}:current\" "; + $graphcmd .= "LINE2:\"cache#{$colormbuf[1]}:cache\" "; + $graphcmd .= "LINE2:\"total#{$colormbuf[2]}:total\" "; + $graphcmd .= "LINE2:\"max#{$colormbuf[3]}:max\" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"\t\t minimum average maximum current\\n\" "; + $graphcmd .= "COMMENT:\"Current. \" "; + $graphcmd .= "GPRINT:\"current:MIN:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"current:AVERAGE:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"current:MAX:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"current:LAST:%7.2lf %S \" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"Cache. \" "; + $graphcmd .= "GPRINT:\"cache:MIN:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"cache:AVERAGE:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"cache:MAX:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"cache:LAST:%7.2lf %S \" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"Total. \" "; + $graphcmd .= "GPRINT:\"total:MIN:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"total:AVERAGE:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"total:MAX:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"total:LAST:%7.2lf %S \" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"Max. \" "; + $graphcmd .= "GPRINT:\"max:MIN:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"max:AVERAGE:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"max:MAX:%7.2lf %s \" "; + $graphcmd .= "GPRINT:\"max:LAST:%7.2lf %S \" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "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-$curgraph.png "; diff --git a/config/mailreport/mail_reports_generate.php b/config/mailreport/mail_reports_generate.php index c31909c9..55a23283 100644 --- a/config/mailreport/mail_reports_generate.php +++ b/config/mailreport/mail_reports_generate.php @@ -2,7 +2,7 @@ Portions Copyright (C) 2007-2011 Seth Mos diff --git a/config/mailreport/mailreport.xml b/config/mailreport/mailreport.xml index 803e205b..1c6880bd 100644 --- a/config/mailreport/mailreport.xml +++ b/config/mailreport/mailreport.xml @@ -37,7 +37,7 @@ ]]> mailreport - 2.1 + 2.2 Status: Email Reports /usr/local/bin/ diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 55e6b24f..fd75e618 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -1176,7 +1176,7 @@ mailreport Allows you to setup periodic e-mail reports containing command output, log file contents, and RRD graphs. Network Management - 2.1 + 2.2 Stable 2.2 https://packages.pfsense.org/packages/config/mailreport/mailreport.xml diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 11982156..f4c0161d 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -1586,7 +1586,7 @@ mailreport Allows you to setup periodic e-mail reports containing command output, log file contents, and RRD graphs. Network Management - 2.1 + 2.2 Stable 2.0 https://packages.pfsense.org/packages/config/mailreport/mailreport.xml diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index cb63afc2..985e3c85 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -1573,7 +1573,7 @@ mailreport Allows you to setup periodic e-mail reports containing command output, log file contents, and RRD graphs. Network Management - 2.1 + 2.2 Stable 2.0 https://packages.pfsense.org/packages/config/mailreport/mailreport.xml -- cgit v1.2.3