[rrd-users] Get DS:MAX without MAX RRA

Matt Elias m_elias at fastmail.fm
Thu Nov 4 05:07:25 CET 2010


So after writing up a perl script to parse rrdtool fetch data I found 
out here http://oss.oetiker.ch/rrdtool/forum.en.html#nabble-td1072180 
that a rrdtool graph with only DEF and PRINT elements will spit out 
those print strings without actually creating the graph file. So I'm 
parsing those PRINT string dumps to get my min/max values. Then after 
modifying/correcting Steve's suggestion formula my humidity line and 
right axis stay steady while my Y axis manually  scales  to the min and 
max temperature (manual, auto scaling). To get the correct formula I had 
to calculate through some simple values and I ended up with:

     my $rascale = 100/($max - $min);
     my $rashift = -1 * $min * $rascale;

to calculate the scale and offset shift and:

     "--right-axis", "$rascale:$rashift",
     "DEF:Hum=$rrd/Weather.rrd:OutHum:AVERAGE",
     "CDEF:sHum=Hum,100,/,$max,$min,-,*,$min,+",

to setup rrdtool graph.

thanks for the help Steve,
Matt


On 11/3/2010 3:17 AM, Steve Shipway wrote:
> Why not do it in two steps?
>
> First, make a call to RRDs::fetch to obtain the min and max values of the value you want to graph over the time period in question.
> Second, use these values to calculate a round number to use as min/max.
> Third, use your preferred temperature min/max to calculate an appropriate scaleshift for the humidity; if the temp is from A to B, then set scaleshift for the second axis to (100/(B-A)):-A and have the second value display as (X/100*(B-A)+A)
>
> This should achieve what you want.  Of course, you cant do it from rrdcgi, but if you're generating the graph programmatically from the libraries it shouldnt be a problem.
>
> Steve
>
> Steve Shipway
> University of Auckland ITS
> UNIX Systems Design Lead
> s.shipway at auckland.ac.nz
> Ph: +64 9 373 7599 ext 86487
>
>
> ________________________________________
> From: rrd-users-bounces+s.shipway=auckland.ac.nz at lists.oetiker.ch [rrd-users-bounces+s.shipway=auckland.ac.nz at lists.oetiker.ch] on behalf of Matt Elias [m_elias at fastmail.fm]
> Sent: Wednesday, 3 November 2010 4:21 p.m.
> To: rrd-users at lists.oetiker.ch
> Subject: [rrd-users] Get DS:MAX without MAX RRA
>
> I would like to display two data definitions on one graph, temperature
> and humidity. I would like to get the main Y axis (temperature) scale to
> remain automatic (or manually set a little lower than the min and a
> little higher than the max) and the right axis (humidity) scale at the
> same scale (ie 0 - 100). My initial thoughts are that if I can get the
> graph's min and max temperature values, then maybe I can use that to
> scale the Y axis and use a formula to scale the humidty values
> accordingly so that they match the right axis' 0-100 scale. The min and
> max values I need are similar to the MAX and MIN values that are
> displayed in the GPRINT paramenters:
>
>           "LINE1:Temp#32CD32:Temperature C",
>           "GPRINT:Temp:MAX:  Max\\: %5.1lf %s",
>           "GPRINT:Temp:AVERAGE:Avg\\: %5.1lf %s",
>           "GPRINT:Temp:MIN:Min\\: %5.1lf %s",
>           "GPRINT:Temp:LAST:Last\\: %5.1lf %s\\l",
>
> If something like this is not doable from within RRDtool, then I may log
> additional data to a log file and have my graph generating perl script
> use that log file to manipulate the Y axis scales.
>
> Matt
>
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users



More information about the rrd-users mailing list