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:
/usr/bin/rrdtool graph - \
--title="|host_description| - Mailgraph" \
GPRINT:cdefb:" Total\:%8.0lf" \
GPRINT:cdefa:AVERAGE:"Avg msgs/min\:%8.2lf %s" \
GPRINT:cdefa:MAX:"Max msgs/min\:%8.0lf\n" \
GPRINT:cdefe:AVERAGE:"Avg msgs/min\:%8.2lf %s" \
The "VDEF"s were able to be used by applying a patch found here: http://forums.cacti.net/viewtopic.php?t=10904&start=15&postdays=0&postorder=asc&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.