[rrd-users] Use a long-term average to color code results in short term graphs
jeff at thegilmores.net
Wed Oct 26 01:26:03 CEST 2011
I am developing an interface for displaying electric power use (watts) over time. On a single page (generated through the RRD PHP bindings), I display graphs of various time periods for a single meter.
Each graph uses code like the following to color code the datapoints to indicate if that usage is in a low, medium, high, or extra-high range of expected values (and thanks to Mark Janssen for his example of this!):
This works fine with these hard-coded values for the LIMIT calculations. However, I would like to change the code so that these ranges are not hard coded, but instead are scaled automatically to a moving long-term average (LTA) for this meter, such as the average over last 30 days.
For example, my four ranges could be scaled as follows:
low = from 0 to 60% of LTA
med = from 60% to 140% of LTA
high = from 140% to 200% of LTA
Xhigh = greater than 200% of LTA
I would like all the graphs on the page to use the same range values, even if the period of the graph is shorter or longer than the 30 days used to calculate this LTA.
I assume I would need to call RRDGraph first with a 30 day range and a only PRINT statement to get this LTA value and store it, then use it to generate the real graphs in my PHP code. But I wonder if there is some way to do this in a single graph definition in RRD?
If not, then I need to figure out how to get the values from PRINT statements back to PHP. Normally in command-line RRD, the PRINT statements go to stdout, but it is not clear from the documentation if there is any way for these to get passed back to PHP. Any suggestions?
More information about the rrd-users