0

I want to calculate the percentage of usage of some features of my host, by RRD queries.(I have Cacti installed and Cacti stores the monitoring data in RRD).

For example if there is 1 GB total swap memory and now I have used 250 MB, the return value of my query should be 0.25 or as another example, if the total bandwidth of network is 200 and now 100 is used, the desired return value is 0.50

My questions are:

1) can RRD tell me these total values (total memory of host or total network bandwidth)?
2) Which query syntax can returns such percentages as described in examples?

If my questions are not obvious, I can describe more. if anyone can point me to some good documentation on RRD to figure this out myself or if anyone can give me a good start it would be greatly appreciated.

aircraft
  • 25,146
  • 28
  • 91
  • 166
masoumeh
  • 468
  • 1
  • 5
  • 15

1 Answers1

1

For calculations in rrdtool you can use CDEF expressions when drawing graphs or in rrdtool xport commands.

CDEF:perc=x,200,/

The expressions are based on reversed polish notation and documented in man rrdgraph_data.

In this example:

  • perc is the name of the new computed field
  • stuff after = is an expression in reversed polish notation meaning x/200
geekQ
  • 29,027
  • 11
  • 62
  • 58
Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23
  • @TobiOetiker Could you please also point to a place in documentation, where it is explained, so we can also find solutions for other similar cases? – geekQ Jul 17 '14 at 15:00
  • @geekQ: See the [RPN page (rrdgraph_rpn)](http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html) in the [rrdtool documentation](http://oss.oetiker.ch/rrdtool/doc/index.en.html). – DarkDust Mar 20 '16 at 11:59
  • And Tobi also has a [nice RPN tutorial](https://oss.oetiker.ch/rrdtool/tut/rpntutorial.en.html). – DarkDust Mar 20 '16 at 12:00