While it is easy to do this with RRDTool, to do it in MRTG is a little more
complex.

 

Lets's assume that the OIDs are OID1 (for kVA) and OID2 (for kVAR).

 

You could use this:

 

Target[xxxx]: OID1&OID2:community@device

Option[xxxx]: gauge

 

This would collect the two values into the two metrics of the RRD for
graphing separately.  You would then need to use something like rrdcgi to
construct a custom graphing function to build a graph with a third line,
calculated by the RPN expression:  

 

CDEF:w=ds0,ds0,*,ds1,ds1,*,-,SQRT,1000,/

Note that we divide by 1000 to get the value in W rather than kW so that the
automatic labels work better.  However, this requires you to create a fairly
complex rrdcgi page with a custom graph, and it may not work well with your
chosen web interface.  Note that, if you are using Routers as your MRTG/RRD
frontend, you can use the routers.cgi*Extension API to embed the output of
another script (such as rrdcgi) within the framework.

 

Another way to do it would be to have a really complex Target line, so that
the w value is calculated and stored at polling time:

 

Target[xxxx]: ( sqrt ( ( OID1&pseudoZero:community@device *
OID1&pseudoZero:community@device ) \

     - ( OID2&pseudoZero:community@device * OID2&pseudoZero:community@device
) )  ) \

     / 1000

 

This will cause things to crash if kVAR > kVA of course, and will not store
the source values (though a separate Target can collect these if you wish).
Note that the spaces around the operators are all significant.

 

You cannot do it with a postprocessing function, as these only take a single
metric as a parameter.

 

Probably the best way to do it would be with a custom collection script, but
this would be non-trivial as it would need to take the community and device
name parameters and perform the SNMP lookup itself.  Whether or not you can
do this will depend on your coding ability.

 

Steve

 

Steve Shipway

T: +64 9 3737 599 ext 86487

E:  <mailto:[email protected]> [email protected]

(GNU Terry Pratchett)

 

From: mrtg [mailto:[email protected]]
On Behalf Of Nick price
Sent: Wednesday, 21 October 2015 2:58 a.m.
To: [email protected]
Subject: [mrtg] maths in mrtg

 

For my incoming mains power supply I have a monitor box that gives me kVA
and kVAR values via SNMP  I need to get kW into a graph.

 

I need to do the following maths  kW=(kVA^2-kVAR^2)^0.5 how do I get mrtg to
do this

 

Many thanks in advance

 

Nick

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
mrtg mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/mrtg

Reply via email to