Rrd tricks: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
(Created page with "On Mon, Mar 10, 2008 at 04:03:57PM +0100, Felix Castillo Sanchez wrote: > > I'm trying to reconstruct the nice graph showed in the "Gallery" showing > filesystem utilization and...") |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Predicted trends ( straight line) == | |||
https://lists.oetiker.ch/pipermail/rrd-users/2008-March/013819.html | |||
<pre> | |||
On Mon, Mar 10, 2008 at 04:03:57PM +0100, Felix Castillo Sanchez wrote: | On Mon, Mar 10, 2008 at 04:03:57PM +0100, Felix Castillo Sanchez wrote: | ||
> | > | ||
Line 5: | Line 10: | ||
> | > | ||
> Can somebody tell me how to draw the lines for the future? | > Can somebody tell me how to draw the lines for the future? | ||
</pre> | |||
You may find it easier to do much of the work outside of rrd. But I'm | You may find it easier to do much of the work outside of rrd. But I'm | ||
Line 35: | Line 41: | ||
You'll probably want to lock down the vertical graph limits to keep the | You'll probably want to lock down the vertical graph limits to keep the | ||
line from extending them too far. | line from extending them too far. | ||
==Replace nan with previous value== | |||
From the rrdtool mailing list | |||
Samuel asks: | |||
<pre> | |||
> I want to know how with a CDEF or in a configuration directly | |||
> stored in RRD files how can I replace nan value by the last real value. | |||
</pre> | |||
Steve responds: | |||
CDEF:newds=ds,UN,PREV,ds,IF | |||
IE, if the value of 'ds' is unknown, then use its previous value, else use its original value. | |||
This is the function done by MRTG in native mode, or with Routers2 and the 'unknasprev' option. | |||
== Volume transferred over a period of time == | |||
http://www.vandenbogaerdt.nl/rrdtool/total.php | |||
<pre> | |||
rrdtool graph /var/www/cacti-0.8.7b/z-greycup_bandwidth/www.client.ca.png \ | |||
--start `date --date='Sun Nov 27 2011 08:00:00 GMT-5' +%s` \ | |||
--end `date --date='Mon Nov 28 2011 06:00:00 GMT-5' +%s` \ | |||
--title "www.client.ca Data Transfered" \ | |||
DEF:ds0=www.client.ca.rrd:traffic_in:AVERAGE \ | |||
DEF:ds1=www.client.ca.rrd:traffic_out:AVERAGE \ | |||
LINE:ds0#00FF00:"In\l" \ | |||
LINE:ds1#FF0000:"Out\l" \ | |||
VDEF:ds0average=ds0,AVERAGE \ | |||
VDEF:ds1average=ds1,AVERAGE \ | |||
CDEF:ds0modified=ds0,UN,ds0average,ds0,IF \ | |||
CDEF:ds1modified=ds1,UN,ds1average,ds1,IF \ | |||
VDEF:ds0total=ds0modified,TOTAL \ | |||
VDEF:ds1total=ds1modified,TOTAL \ | |||
COMMENT:"Start\: Sun Nov 27 2011 08\:00\:00 GMT-5\l" \ | |||
COMMENT:"End\: Mon Nov 28 2011 06\:00\:00 GMT-5\l" \ | |||
GPRINT:ds0total:"Total In\:%12.2lf%s \l" \ | |||
GPRINT:ds1total:"Total Out\:%12.2lf%s \l" | |||
</pre> | |||
== Resources == | |||
* http://rrdtool.vandenbogaerdt.nl/ - good notes explanations and tutorials | |||
[[Category:Script]] |
Latest revision as of 05:48, 6 April 2021
Predicted trends ( straight line)
https://lists.oetiker.ch/pipermail/rrd-users/2008-March/013819.html
On Mon, Mar 10, 2008 at 04:03:57PM +0100, Felix Castillo Sanchez wrote: > > I'm trying to reconstruct the nice graph showed in the "Gallery" showing > filesystem utilization and predicted trends. > > Can somebody tell me how to draw the lines for the future?
You may find it easier to do much of the work outside of rrd. But I'm drawing some similar lines. I haven't done all the work to make the dates come out nice, though.
Something like:
[...] "DEF:scratch=$rrd_file:scratch:AVERAGE", # Calculate slope "VDEF:slope=scratch,LSLSLOPE", "VDEF:int=scratch,LSLINT", # Graph trend line "CDEF:trend=scratch,POP,slope,COUNT,*,int,+", "LINE:trend#00FF00", # Find regions where trend is less than 0 "CDEF:sub=trend,NEGINF,1,LIMIT", "VDEF:first_sub=sub,FIRST", "GPRINT:first_sub:Predicted empty %F:strftime", # Vertical line at that point "VRULE:first_sub#FF0000:exhaustion point", [...]
Note that in my case I'm looking for when the graph hits zero, not when it hits 100.
You'll probably want to lock down the vertical graph limits to keep the line from extending them too far.
Replace nan with previous value
From the rrdtool mailing list
Samuel asks:
> I want to know how with a CDEF or in a configuration directly > stored in RRD files how can I replace nan value by the last real value.
Steve responds:
CDEF:newds=ds,UN,PREV,ds,IF
IE, if the value of 'ds' is unknown, then use its previous value, else use its original value.
This is the function done by MRTG in native mode, or with Routers2 and the 'unknasprev' option.
Volume transferred over a period of time
http://www.vandenbogaerdt.nl/rrdtool/total.php
rrdtool graph /var/www/cacti-0.8.7b/z-greycup_bandwidth/www.client.ca.png \ --start `date --date='Sun Nov 27 2011 08:00:00 GMT-5' +%s` \ --end `date --date='Mon Nov 28 2011 06:00:00 GMT-5' +%s` \ --title "www.client.ca Data Transfered" \ DEF:ds0=www.client.ca.rrd:traffic_in:AVERAGE \ DEF:ds1=www.client.ca.rrd:traffic_out:AVERAGE \ LINE:ds0#00FF00:"In\l" \ LINE:ds1#FF0000:"Out\l" \ VDEF:ds0average=ds0,AVERAGE \ VDEF:ds1average=ds1,AVERAGE \ CDEF:ds0modified=ds0,UN,ds0average,ds0,IF \ CDEF:ds1modified=ds1,UN,ds1average,ds1,IF \ VDEF:ds0total=ds0modified,TOTAL \ VDEF:ds1total=ds1modified,TOTAL \ COMMENT:"Start\: Sun Nov 27 2011 08\:00\:00 GMT-5\l" \ COMMENT:"End\: Mon Nov 28 2011 06\:00\:00 GMT-5\l" \ GPRINT:ds0total:"Total In\:%12.2lf%s \l" \ GPRINT:ds1total:"Total Out\:%12.2lf%s \l"
Resources
- http://rrdtool.vandenbogaerdt.nl/ - good notes explanations and tutorials