[mrtg] Combining temp and voltages but a little complex...

Steve Shipway s.shipway at auckland.ac.nz
Thu May 1 00:19:41 CEST 2008

>I'd like to combine voltage readings and temp readings 
>in the same graph if at all possible.

This is possible if you use the routers2 frontend (which of course means
you need to be using MRTG with RRDTool).  However, you have the problem
that an RRDTool graph only has ONE scale, which means you need to graph
both values on the same scale.

>The other half of my problem is how the values get 
>returned, I need to do a little math with them to get 
>them looking right..

For your temperature, there is a special function in routers2 (since
v2.16) for converting DegC to DegF (since I heard Americans still use
DegF).  If you collect the data as C and store it like this, then have

Routers.cgi*Options[temp]: c2fi 

It will convert the value from C to F (by F=c*9/5+32) before plotting
it.  A similar c2fo option exists for converting the 'out' value,
although you probably are using option 'noo' to have only one line on
the graph.

For the voltage, you could use

Factor[volt]: -0.01

Which will convert -5201 to 52.01 before displaying.

The main difference between using Factor and having the calculation on
the Target line is that the data is stored in the RRD AFTER the Target
calculation, but the Factor (and the c2fi option) are only used at
Display time.  

In both cases, you should have the Options[]:gauge set as the values are

However, you may need to adjust the RRD file for voltage, since by
default the min/max range will be 0->MaxBytes[] and (if you use Factor)
you will want to store negative values.

To get both on the same graph, using routers2, you would need something

Router.cgi*Graph[temp]: combined nototal noaverage
Router.cgi*Graph[volts]: combined 
Routers.cgi*YLabel[combined]: degF or Volts

but you'd probably also need to tune some other settings and you may
find that the single scale makes it hard to read.


More information about the mrtg mailing list