Page 1 of 1
Getting averages for a month from rrd files.
Posted: Thu Apr 03, 2014 3:57 am
by WillemDH
Hello,
I'm a complete newbie with
rrdtool. is it possible to get the average value of a rrd file with
rrdtool? For example I have for each server a SRV_CPU.rrd. Could I get the average CPU from this rrd file for a time interval of a month? How would I do this?
I made a feature request for this to get the average value of a service.
http://tracker.nagios.com/view.php?id=521
But as my management wants to see this earlier than you guys will be able to implement this, I was thinking about trying this myself. But is this possible with the Nagios rrd files in /usr/local/nagios/share/perfdata?
Grtz
Willem
Re: Getting averages for a month from rrd files.
Posted: Thu Apr 03, 2014 4:27 pm
by tmcdonald
I'm not extremely well-versed in rrdtool, but I think this is close to what you want:
rrdtool fetch /usr/local/nagios/share/perfdata/<HOST>/<SERVICE>.rrd AVERAGE -30d
Should give you the last 30 days. Going to be a lot of lines, just to warn you.
Re: Getting averages for a month from rrd files.
Posted: Thu Apr 03, 2014 4:49 pm
by abrist
Alright, you can do this with
rrdtool and the PRINT command:
cd into an rrd folder located in:
cd /usr/local/nagios/share/perfdata/<host>/
To get a one month average of ping times:
Code: Select all
rrdtool graph dummy -s -1month -e start+1month DEF:test=_HOST_.rrd:1:AVERAGE PRINT:test:AVERAGE:'average - %.0lf'
Output:
The breakdown of the command above:
Code: Select all
rrdtool graph <dummy filename> -s <start time> -e <endtime> DEF:<var name(anything you want)>=<rrd>:<datasource name>:AVERAGE PRINT:<var name>:AVERAGE:'average - %.0lf'
Re: Getting averages for a month from rrd files.
Posted: Fri Apr 04, 2014 2:31 am
by WillemDH
Hello,
This seems to work as expected!
Code: Select all
rrdtool graph dummy -s -1month -e start+1month DEF:test=SRV_CPU.rrd:1:AVERAGE PRINT:test:AVERAGE:'average - %.0lf'
0x0
average - 11
Now I just need to write a bash script that wil loop through all hosts in /usr/local/nagios/share/perfdata and if it finds SRV_CPU, write the value to a file. Can you please leave the thread open for a while in case I would need some help..
Thanks you very much all for the help. (again)
Willem
Re: Getting averages for a month from rrd files.
Posted: Fri Apr 04, 2014 9:14 am
by tmcdonald
WillemDH wrote:Can you please leave the thread open for a while in case I would need some help..

Sure thing. And thank you Andy for proving my statement:
tmcdonald wrote:I'm not extremely well-versed in rrdtool

Re: Getting averages for a month from rrd files.
Posted: Sat Sep 05, 2015 1:49 pm
by WillemDH
This thread can be closed.