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"
```

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.

Thanks!