[rrd-users] How to get Average for defined time only
Alex van den Bogaerdt
alex at vandenbogaerdt.nl
Thu Jan 21 10:49:15 CET 2010
----- Original Message -----
From: "Vinod Sharma" <vk.kaushik2006 at gmail.com>
To: <rrd-users at lists.oetiker.ch>
Sent: Thursday, January 21, 2010 8:10 AM
Subject: [rrd-users] How to get Average for defined time only
>I am creating daily graphs using RRDTool from the logs of my application. I
> am using below settings to do the same.
> rrdtool graph - \
> --start=end -7d \
> --end=midnight \
> --imgformat=PNG \
> --width=1048 \
> --base=1000 \
> --height=266 \
> --logarithmic \
> --interlaced \
> DEF:A=test.rrd:data:AVERAGE \
> CDEF:A=f,POP,LTIME,86400,%,3600,/,FLOOR,DUP,23,LT,*,6,GT,INF,UNKN,IF \
> AREA:A#7FFFD4: Day Time \
> LINE2:f#DDA0DD:data AVERAGE
This shouldn't work. You are redefining "A", and you use undefined "f". You
didn't use copy/paste.
Timestamps in RRDtool define the end of a period. You do no want the data
with timestamp 7am. You do want the data with timestamp 10pm.
> Currently I am displaying the day time as shown in above example but I
> to get the output average of day time data only i.e. 7AM to 10 PM. Can
> anyone please suggest how can I get the average of day time data only and
> skip other data.
I suggest you try the following (you may need to adjust this, I did it from
memory without any testing whatsoever)
B is a copy of A, but only if the time is right.
25201 (7*3600) is not to be included. 79200 (22*3600) is to be included.
Using 25201 and 79200 (or any other appropriate timestamps) instead of
7,3600,* and similar saves some CPU cycles.
C is infinite if B has finite data, and unknown if B is not finite.
"LTIME,86400,%" should provide wall clock time.
"25201,79200,LIMIT" may not provide accurate results if your intervals are
larger than one hour or if your local time is not a whole number of hours
away from UTC. If timestamps 25201 and 25200 belong to the same interval,
you will not get accurate output.
Comparing an unknown or infinite number always results in false, thus
"DUP,EQ" should be a good alternative for "ISFINITE". In this case you could
also use UN and reverse A and UNKN, this should work because you have no
infinite numbers as input.
I seem to recall that unknown data does not influence the average, so I
believe you should get the average of the defined range between 7am and
10pm. Try it, and please report back if it works.
More information about the rrd-users