[rrd-users] value and name both

Simon Hobson linux at thehobsons.co.uk
Thu Nov 17 16:12:33 CET 2011


Shabnam Shahreza wrote:
>But it still gives me the "value" not the "name of the variable 
>carrying that value"... right?
>
>Imagine if the maximum value is 100.05 I want to know also which of 
>the var1,var2,var3,.. has this value....

OK, this is the sort of logic you need :

get max
m=v1,v2,...,vn,max

test if v1 is the one
x1=m,v1,eq,1,0,if

test if v2 is the one
x2=m,v2,eq,2,x1,if

test if vn is the one
xn=m,vn,eq,2,x(n-1),if

print xn

Basically, it's a bit convoluted, but if v1=m then set x1 to 1, else 
set it to 0
Then if v2=m, set x2 to 2, else set it to x1
Repeat until you've done all your variables.
At the end, xn will hold the index for the value that triggered the 
maximum. Print this out in a first run through (as Tobias suggested), 
and use this value externally to dynamically alter the script you use 
when generating the graph.

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.



More information about the rrd-users mailing list