[rrd-users] Bar graph by hour, day, month

Simon Hobson linux at thehobsons.co.uk
Mon Sep 29 18:03:14 CEST 2014


bsuarez at free.fr wrote:

> My water meter delivers one pulse per liter consumed. I have a script that counts the pulses (raspberry and piface).
> 
> Periodically I want to store in the RRD database  the number of pulses.
> The first solution is to periodically store the number of impusions since the last backup.
> The second solution is to periodically store the total impusions since the start of counting

Counter or Derive will work. See http://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html where they are explained and see the "NOTE on COUNTER vs DERIVE".
Alternatively, you could use Absolute and reset the counter each time - then you don't need to worry about storing the total.

> For graphs, displaying data on last 5 minutes, last hour, last day, last month should be enough.

Assuming by "last week" you mean "previous 7 days ending now" rather than "previous calendar week" then it shouldn't be too hard. Decide what resolution you want, and how much data to store at each resolution, then RRD will "just do it". However, to get "one bar per day" you may have to force RRD tool to use a specific consolidation while graphing (that's not hard) if there is higher resolution data available.
Eg, supposing you had "2 hour" consolidations for the last 14 days, by default if you plot a graph over the last week then RRD will use that 2 hourly data and draw you a "wiggly line". If you tell graph to use another consolidation which has only one sample/day then it will oblige by drawing a "wiggly line" which looks very much like a bar chart.



More information about the rrd-users mailing list