Baka
Menu

Graphing mail statistics trends

Client-side plugin for graphing mail statistics from mail.log
Supported loglines: postfix, ssmtp, nullmailer, postgrey, amavis, spamd.

Installation:
Client-side:
Download and copy mailgraph.sh to xymon ext directory.
Create new file /etc/xymon/clientlaunch.d/mailgraph.cfg:
Note: read permissions for mail.log file required for xymon user.

client-side mailgraph.cfg
[mailgraph]
	#DISABLED
	ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
	CMD $XYMONCLIENTHOME/ext/mailgraph.sh
	LOGFILE $XYMONCLIENTLOGS/xymonclient.log
	INTERVAL 5m

Server-side:
Add "mailgraph=ncv" to TEST2RRD variable and "mailgraph" to GRAPHS variable in xymonserver.cfg.
Add the line "NCV_mailgraph="runtime:GAUGE,*:ABSOLUTE" to xymonserver.cfg.
Create new file /etc/xymon/graphs.d/mailgraph.cfg:

server-side mailgraph.cfg
[mailgraph]
        TITLE Mailtransport
        YAXIS Mails/Min
        -l 0
        DEF:received=mailgraph.rrd:received:AVERAGE
        CDEF:rreceived=received,60,*
        VDEF:receivedtotal=received,TOTAL
        AREA:rreceived#00009C:received\:
        GPRINT:receivedtotal:%5.0lf
        GPRINT:rreceived:MAX:max\: %5.1lf msg/min
        GPRINT:rreceived:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:sent=mailgraph.rrd:sent:AVERAGE
        CDEF:rsent=sent,60,*
        VDEF:senttotal=sent,TOTAL
        LINE:rsent#009C00:sent    \:
        GPRINT:senttotal:%5.0lf
        GPRINT:rsent:MAX:max\: %5.1lf msg/min
        GPRINT:rsent:AVERAGE:avg\:%5.1lf msg/min\n

        #DEF:deferred=mailgraph.rrd:deferred:AVERAGE
        #CDEF:rdeferred=deferred,60,*
        #VDEF:deferredtotal=deferred,TOTAL
        #LINE:rdeferred#888888:deferred\:
        #GPRINT:deferredtotal:%5.0lf
        #GPRINT:rdeferred:MAX:max\: %5.1lf msg/min
        #GPRINT:rdeferred:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:bounced=mailgraph.rrd:bounced:AVERAGE
        CDEF:rbounced=bounced,60,*
        VDEF:bouncedtotal=bounced,TOTAL
        LINE:rbounced#FF5500:bounced \:
        GPRINT:bouncedtotal:%5.0lf
        GPRINT:rbounced:MAX:max\: %5.1lf msg/min
        GPRINT:rbounced:AVERAGE:avg\:%5.1lf msg/min\n

[mailgraph-rejected]
        TITLE Mais rejected
        YAXIS Mails/Min
        -l 0
        DEF:rejected=mailgraph.rrd:rejected:AVERAGE
        CDEF:rrejected=rejected,60,*
        VDEF:rejectedtotal=rejected,TOTAL
        AREA:rrejected#DD0000:rejected      \:
        GPRINT:rejectedtotal:%7.0lf
        GPRINT:rrejected:MAX:max\: %5.1lf msg/min
        GPRINT:rrejected:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:rejectwarning=mailgraph.rrd:rejectwarning:AVERAGE
        CDEF:rrejectwarning=rejectwarning,60,*
        VDEF:rejectwarningtotal=rejectwarning,TOTAL
        AREA:rrejectwarning#550000:warn_if_reject\::STACK
        GPRINT:rejectwarningtotal:%7.0lf
        GPRINT:rrejectwarning:MAX:max\: %5.1lf msg/min
        GPRINT:rrejectwarning:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:warning=mailgraph.rrd:warning:AVERAGE
        CDEF:rwarning=warning,60,*
        VDEF:warningtotal=warning,TOTAL
        AREA:rwarning#C29B00:warn          \::STACK
        GPRINT:warningtotal:%7.0lf
        GPRINT:rwarning:MAX: max\: %5.1lf msg/min
        GPRINT:rwarning:AVERAGE:avg\:%5.1lf msg/min\n

[mailgraph-local]
        TITLE Mailtransport local
        YAXIS Mails/Min
        -l 0
        DEF:receivedlocal=mailgraph.rrd:receivedlocal:AVERAGE
        CDEF:rreceivedlocal=receivedlocal,60,*
        VDEF:receivedlocaltotal=receivedlocal,TOTAL
        AREA:rreceivedlocal#6699FF:received local\:
        GPRINT:receivedlocaltotal:%5.0lf
        GPRINT:rreceivedlocal:MAX:max\: %5.1lf msg/min
        GPRINT:rreceivedlocal:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:sentlocal=mailgraph.rrd:sentlocal:AVERAGE
        CDEF:rsentlocal=sentlocal,60,*
        VDEF:sentlocaltotal=sentlocal,TOTAL
        LINE2:rsentlocal#005800:sent local    \:
        GPRINT:sentlocaltotal:%5.0lf
        GPRINT:rsentlocal:MAX:max\: %5.1lf msg/min
        GPRINT:rsentlocal:AVERAGE:avg\:%5.1lf msg/min\n

[mailgraph-amavis]
        TITLE Amavis-stats
        YAXIS Mails/Min
        -l 0

        DEF:blockedvirus=mailgraph.rrd:blockedvirus:AVERAGE
        CDEF:rblockedvirus=blockedvirus,60,*
        VDEF:blockedvirustotal=blockedvirus,TOTAL
        AREA:rblockedvirus#CC0000:blocked virus \:
        GPRINT:blockedvirustotal:%5.0lf
        GPRINT:rblockedvirus:MAX:max\: %5.1lf msg/min
        GPRINT:rblockedvirus:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:blockedbanned=mailgraph.rrd:blockedbanned:AVERAGE
        CDEF:rblockedbanned=blockedbanned,60,*
        VDEF:blockedbannedtotal=blockedbanned,TOTAL
        AREA:rblockedbanned#FFDD00:blocked banned\::STACK
        GPRINT:blockedbannedtotal:%5.0lf
        GPRINT:rblockedbanned:MAX:max\: %5.1lf msg/min
        GPRINT:rblockedbanned:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:passedclean=mailgraph.rrd:passedclean:AVERAGE
        CDEF:rpassedclean=passedclean,60,*
        VDEF:passedcleantotal=passedclean,TOTAL
        AREA:rpassedclean#10D0D0:passed clean  \::STACK
        GPRINT:passedcleantotal:%5.0lf
        GPRINT:rpassedclean:MAX:max\: %5.1lf msg/min
        GPRINT:rpassedclean:AVERAGE:avg\:%5.1lf msg/min\n

[mailgraph-spamd]
        TITLE Spamd-stats
        YAXIS Mails/Min
        -l 0
        DEF:nonspam=mailgraph.rrd:nonspam:AVERAGE
        CDEF:rnonspam=nonspam,60,*
        VDEF:nonspamtotal=nonspam,TOTAL
        AREA:rnonspam#009900:non-spam\:
        GPRINT:nonspamtotal:%5.0lf
        GPRINT:rnonspam:MAX:max\: %5.1lf msg/min
        GPRINT:rnonspam:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:spam=mailgraph.rrd:spam:AVERAGE
        CDEF:rspam=spam,60,*
        VDEF:spamtotal=spam,TOTAL
        AREA:rspam#000000:spam    \::STACK
        GPRINT:spamtotal:%5.0lf
        GPRINT:rspam:MAX:max\: %5.1lf msg/min
        GPRINT:rspam:AVERAGE:avg\:%5.1lf msg/min\n


[mailgraph-postgrey]
        TITLE Postgrey-Stats
        YAXIS Mails/Min

        DEF:greylisted=mailgraph.rrd:greylisted:AVERAGE
        CDEF:rgreylisted=greylisted,60,*
        VDEF:greylistedtotal=greylisted,TOTAL
        AREA:rgreylisted#616161:greylisted \:
        GPRINT:greylistedtotal:%5.0lf
        GPRINT:rgreylisted:MAX:max\: %5.1lf msg/min
        GPRINT:rgreylisted:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:passed=mailgraph.rrd:passed:AVERAGE
        CDEF:rpassed=passed,60,*
        VDEF:passedtotal=passed,TOTAL
        LINE2:rpassed#00AA00:passed     \:
        GPRINT:passedtotal:%5.0lf
        GPRINT:rpassed:MAX:max\: %5.1lf msg/min
        GPRINT:rpassed:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:delayed=mailgraph.rrd:delayed:AVERAGE
        CDEF:rdelayed=delayed,60,*
        VDEF:delayedtotal=delayed,TOTAL
        LINE2:rdelayed#0000CC:delayed    \:
        GPRINT:delayedtotal:%5.0lf
        GPRINT:rdelayed:MAX:max\: %5.1lf msg/min
        GPRINT:rdelayed:AVERAGE:avg\:%5.1lf msg/min\n


        DEF:earlyretry=mailgraph.rrd:earlyretry:AVERAGE
        CDEF:rearlyretry=earlyretry,60,*
        VDEF:earlyretrytotal=earlyretry,TOTAL
        LINE2:rearlyretry#FF0000:early-retry\:
        GPRINT:earlyretrytotal:%5.0lf
        GPRINT:rearlyretry:MAX:max\: %5.1lf msg/min
        GPRINT:rearlyretry:AVERAGE:avg\:%5.1lf msg/min\n



[mailgraph-postgrey-passed]
        TITLE Postgrey-Stats
        YAXIS Mails/Min

        DEF:reasontripletfound=mailgraph.rrd:reasontripletfound:AVERAGE
        CDEF:rreasontripletfound=reasontripletfound,60,*
        VDEF:reasontripletfoundtotal=reasontripletfound,TOTAL
        AREA:rreasontripletfound#0000EE:triplet found\:
        GPRINT:reasontripletfoundtotal:%5.0lf
        GPRINT:rreasontripletfound:MAX:max\: %5.1lf msg/min
        GPRINT:rreasontripletfound:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:reasonawl=mailgraph.rrd:reasonawl:AVERAGE
        CDEF:rreasonawl=reasonawl,60,*
        VDEF:reasonawltotal=reasonawl,TOTAL
        AREA:rreasonawl#00AA00:client AWL   \::STACK
        GPRINT:reasonawltotal:%5.0lf
        GPRINT:rreasonawl:MAX:max\: %5.1lf msg/min
        GPRINT:rreasonawl:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:reasonclientwl=mailgraph.rrd:reasonclientwl:AVERAGE
        CDEF:rreasonclientwl=reasonclientwl,60,*
        VDEF:reasonclientwltotal=reasonclientwl,TOTAL
        AREA:rreasonclientwl#DD0000:client WL    \::STACK
        GPRINT:reasonclientwltotal:%5.0lf
        GPRINT:rreasonclientwl:MAX:max\: %5.1lf msg/min
        GPRINT:rreasonclientwl:AVERAGE:avg\:%5.1lf msg/min\n

        DEF:reasonrecipwl=mailgraph.rrd:reasonrecipwl:AVERAGE
        CDEF:rreasonrecipwl=reasonrecipwl,60,*
        VDEF:reasonrecipwltotal=reasonrecipwl,TOTAL
        AREA:rreasonrecipwl#CC00CC:recipient WL \::STACK
        GPRINT:reasonrecipwltotal:%5.0lf
        GPRINT:rreasonrecipwl:MAX:max\: %5.1lf msg/min
        GPRINT:rreasonrecipwl:AVERAGE:avg\:%5.1lf msg/min\n

[mailgraph-loglines]
        TITLE Mailgraph loglines
        YAXIS Lines/Min
        -l 0
        DEF:loglines=mailgraph.rrd:loglines:AVERAGE
        CDEF:rloglines=loglines,60,*
        VDEF:loglinestotal=loglines,TOTAL
        AREA:rloglines#00CECD:processed loglines\:
        GPRINT:loglinestotal:%5.0lf
        GPRINT:rloglines:MAX:max\: %5.1lf lines/min
        GPRINT:rloglines:AVERAGE:avg\:%5.1lf lines/min\n

[mailgraph-runtime]
        TITLE Mailgraph runtime
        YAXIS Seconds
        -l 0
        DEF:runtime=mailgraph.rrd:runtime:AVERAGE
        AREA:runtime#00CECD:runtime\:
        GPRINT:runtime:LAST: \: %3.4lf (cur)
        GPRINT:runtime:MAX: \: %3.4lf (max)
        GPRINT:runtime:MIN: \: %3.4lf (min)
        GPRINT:runtime:AVERAGE: \: %3.4lf (avg)\n

Restart xymon-server.
Define the subgraphs to include in the "trends" column in the host line or .default. line in hosts.cfg.

Example: include all defined subgraphs to trends:

TRENDS:*,mailgraph:mailgraph|mailgraph-rejected|mailgraph-local|mailgraph-amavis|mailgraph-spamd|mailgraph-postgrey|mailgraph-postgrey-passed|mailgraph-loglines|mailgraph-runtime

 

Download

 

Screenshots:

Mailtransport

Rejected mails

Mailtransport local

Amavis

Postgrey

Postgrey passed