Leif Neland
Leif Neland

Reputation: 1518

RRD Time since last non-change of counter

I have a RRD DCOUNTER, which gets its data from the water meter: so many units since start of the program which looks at the meter.

So the input might be 2,3,4,5,5,5,5,8,12,13,13,14,14,14,14,14 That means the flow is 1,1,1,0,0,0,0,3,4,1,0,1,0,0,0,0,0

I want a graph showing minutes since last rest 0,1,2,0,1,2,3,0,0,0,0,0,0,1,2,3,4,5

If the flow is never zero, there must be a leak. Hopefully the graph should rise steadily from bedtime to wakeup, and from leaving to work to coming back.

Ideas?

Upvotes: 0

Views: 114

Answers (1)

Steve Shipway
Steve Shipway

Reputation: 4072

First, you set up your input data source as a COUNTER type, so that you will be storing the changes, IE the flow.

Now, you can define a calculated datasource (for graphs etc) that counts the minutes since the last zero, using something like:

IF ( flow == 0 ) THEN timesincerest = 0 ELSE timesincerest = previous value of timesincerest + 1 END

In RPN, that would be:

timesincerest = flow, 0, GT, PREV(timesincerest), STEPWIDTH, +, 0, IF

This will give you a count of the number of seconds since the last reset.

Upvotes: 0

Related Questions