Getting averages for a month from rrd files.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Getting averages for a month from rrd files.

Post 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
Nagios XI 5.8.1
https://outsideit.net
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Getting averages for a month from rrd files.

Post 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.
Former Nagios employee
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Getting averages for a month from rrd files.

Post 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:

Code: Select all

0x0
average - 87
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'
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Getting averages for a month from rrd files.

Post 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
Nagios XI 5.8.1
https://outsideit.net
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Getting averages for a month from rrd files.

Post 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
:D
Former Nagios employee
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Getting averages for a month from rrd files.

Post by WillemDH »

This thread can be closed.
Nagios XI 5.8.1
https://outsideit.net
Locked