Graphing Mailgraph RRDs

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Post Reply
Posts: 19
Joined: Fri Mar 02, 2007 8:44 pm

Graphing Mailgraph RRDs

#1 Post by srhuston » Wed Mar 07, 2007 1:44 pm

I've seen the posts and suggestions on "integrating" Mailgraph with Cacti, many of which rely on changing the log watching script to just put the numbers somewhere that snmpd can get to them and pulling them off that way. However, I have a year's worth of data already in RRDs, and I'd like to keep access to it. So far, I've been mostly successful. Copying the RRD by hand (temporarily), I was able to get mostly accurate graphs with this setup:

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="|host_description| - Mailgraph" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--units-exponent=0 \
--vertical-label="msgs/min" \
--slope-mode \
DEF:a="/usr/share/cacti/rra/mailgraph.rrd":sent:AVERAGE \
DEF:b="/usr/share/cacti/rra/mailgraph.rrd":recv:AVERAGE \
CDEF:cdefa=a,60,* \
VDEF:cdefb=a,TOTAL \
CDEF:cdefe=b,60,* \
VDEF:cdeff=b,TOTAL \
AREA:cdefa#002A8F:"Sent"  \
GPRINT:cdefb:"    Total\:%8.0lf"  \
GPRINT:cdefa:AVERAGE:"Avg msgs/min\:%8.2lf %s"  \
GPRINT:cdefa:MAX:"Max msgs/min\:%8.0lf\n"  \
LINE2:cdefe#00BD27:"Received"  \
GPRINT:cdeff:"Total\:%8.0lf"  \
GPRINT:cdefe:AVERAGE:"Avg msgs/min\:%8.2lf %s"  \
GPRINT:cdefe:MAX:"Max msgs/min\:%8.0lf\n" 
The "VDEF"s were able to be used by applying a patch found here: ... highlight=
That does away with a lot of the math involved in the original mailgraph.cgi rrdgraph calls, since that math was to get the totals from the RRA (and I think impossible to recreate in cacti, at least I could find no way to get the right time numbers for every graph automatically).

The reason I say "mostly" accurate, and the only problem I have, is with the "Max msgs/min" GPRINTs. In mailgraph.cgi, there are four DEFs; one for each dataset with the consolidation AVERAGE, and one each with MAX. The average ones are used for the graph lines, and the first two GPRINTs, while the MAX one is used only for the max msgs/min item.

Is there some way to get this data out of the RRA within Cacti? I was able to get it if I wanted to graph the data, but I couldn't seem to find a way to get it out for just printing the number (Cacti wants to just use the already retrieved dataset and use the MAX consolidation on the GPRINT, which gives the wrong value). As it is, it's telling me the max msgs/min over the average, but not the true max reported in the RRA.

Once I get this last bit figured out, I'll be uploading the templates and instructions for others who want to use Mailgraph's RRDs as external data sources too.


Posts: 19
Joined: Fri Mar 02, 2007 8:44 pm

#2 Post by srhuston » Thu Mar 08, 2007 9:32 pm

Nobody? Mods, would this do better in the "Help: General" category maybe? I figured someone would've chimed in with either an answer, or a "can't happen" by now :P

(Not to say I'm ungrateful for the help I've received otherwise here - one of the more useful forums I've found in a long time)

Post Reply