|
|
| Author |
Message |
JasperJ
Joined: 16 Aug 2008 Posts: 3
|
Posted: Tue Aug 19, 2008 4:17 pm Post subject: [HOWTO] Use VDEF items |
|
|
Hi,
I've figured out something that I consider fairly cool.
When you graph something like fan speeds, you'll often find that the values of each fan will stay within a very narrow band, but they won't necessarily be terribly close together, so you can't simply use an appropriately set scale to see everything usefully, and the graph will not be terribly informative:
http://www.insaneoc.com/graphs/graph_370.html
To solve this, I decided that I wanted to graph the *difference* between the given data point and the average value of the sensor over time. In other words, how much more or less is it now than it usually is?
Here's the result, and this is how I accomplished it.
http://www.insaneoc.com/graphs/graph_413.html
With some help from a friend, I figured out that what I wanted from RRDtool was VDEF:average_datasource=datasource,AVERAGE. VDEFs are like CDEFs, except they work on the entire dataset, rather than just each value individually. In the case of the VDEF above, it first puts the entire datasource (probably just the portion that coincides with the graph you're making. I think) on the stack, and then AVERAGE, obviously, takes that and returns a single value representing the average of the datasource. Note that VDEFs exist from RRDtool 1.2 onward only.
Now, cacti does not support VDEFs in any direct way, so this was a bit tricky. I figured out that when you make a cacti CDEF, the strings in that CDEF get passed pretty much verbatim to RRDtool, though. So what I ended up doing in order to draw a LINE2 respresenting the difference between the average of the dataset as a whole and the current value was the following:
First, insert one graph item with type COMMENT, and apply the CDEF "Make average, stick in avgCURRENT_DATA_SOURCE". This CDEF consists solely of a single Custom String: CURRENT_DATA_SOURCE VDEF:avgCURRENT_DATA_SOURCE=CURRENT_DATA_SOURCE,AVERAGE
Assuming for the moment that the current data source is named 'a' by cacti, this translates into a piece of RRDtool commandline like:
CDEF:cdefa=a VDEF:avga=avg,AVERAGE
Because the item is a COMMENT, the cdefa that is produced is not used in the rest of the graph definition, but we *have* defined a variable "avga".
The next step is simple: Add a LINE2 and apply the CDEF "graph diff with avgCURRENT_DATA_SOURCE", which consists of CURRENT_DATA_SOURCE,avgCURRENT_DATA_SOURCE,- .
Because cacti uses the same data source identifier for both the COMMENT and LINE2 items, avgCURRENT_DATA_SOURCE will work across the two items.
Other graphs that use this trick:
http://www.insaneoc.com/graphs/graph_414.html
http://www.insaneoc.com/graphs/graph_415.html
| Description: |
|
| Filesize: |
31 KB |
| Viewed: |
1023 Time(s) |

|
| Description: |
|
| Filesize: |
8.72 KB |
| Viewed: |
1023 Time(s) |

|
| Description: |
|
| Filesize: |
7.49 KB |
| Viewed: |
1023 Time(s) |

|
| Description: |
|
| Filesize: |
27.77 KB |
| Viewed: |
1023 Time(s) |

|
| Description: |
| Fan speeds - Deviation from average. |
|
| Filesize: |
49.19 KB |
| Viewed: |
1023 Time(s) |

|
Last edited by JasperJ on Wed Aug 20, 2008 3:22 am; edited 1 time in total |
|
| Back to top |
|
 |
mgb Cacti User
Joined: 21 Jun 2004 Posts: 102 Location: North of the Netherlands
|
Posted: Wed Aug 20, 2008 1:04 am Post subject: |
|
|
Very impessive,
I'm going to try this out on some of my temp graphs i have. This will be more useful than the current graphs we are seeing.
Thanx
|
|
| Back to top |
|
 |
koe
Joined: 11 Oct 2007 Posts: 6
|
Posted: Wed Sep 03, 2008 11:16 am Post subject: HOW TO VDEF total |
|
|
Hi JasperJ
Thanks for your tips with VDEF.
I'm trying to use the VDEF TOTAL in the graph template to obtain the total data accumulated for a determinated time range ( the area of the graph! ) but I can not do it !
Could you help me? How can I build a graph template with VDEF TOTAL?
Thanks.
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12206 Location: Muenster, Germany
|
Posted: Wed Sep 03, 2008 1:07 pm Post subject: |
|
|
Wow, that's indeed cool. It's like a "rrdtool graph injection" vulnerability
We should fix this security issue asap
But it does not really replace a full VDEF support. This is still to come
Reinhard
|
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|