[rrd-users] how to collect+graph: time of motion detection

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Sat Jun 18 17:57:48 CEST 2011


> Here's a beginner's question, I did quite a bit of experimenting and
> searching but could not find the solution yet.
>
> The scenario: every time motion is detected in a room, the date+time is
> recorded.
> I would like to store+visualize this data using rrdtool.

Indeed a beginner's question. You are trying to hammer a nail using a
screwdriver. Maybe it will work but you would do better if you'd use the
right tool for the job.

RRDtool is great in storing and graphing rates over time. But that is not
what you are trying to do. This is probably why you are unable to find
examples.

> Thanks in advance for any suggestions!

Accept that RRDtool works with rates. Work from there, or select another
tool.

"Work from there": for instance: record each activity as "one per second",
"during one second".  Then graph 604800 seconds together, multiply the
rate by 604800 and display the average. That should be the number of
events per week.
Updating as one per second during one second involves two updates: zero at
the second before the event, time n-1, and one at the event time itself,
time n. Thus you need to make another choice: do I just update at "n-1"
and ignore error messages from rrdtool in the case there happen to be 2
events in a row, or you do keep track (outside rrdtool) of it. Hmm... and
what if there are two events in the same second? For instance at
hh:mm:ss:51 and at hh:mm:(ss+1):49 ?  Or, without rounding, at hh:mm:ss:00
and at hh:mm:ss:59 ?

Trying to show how much events happen during each day of the week, during
e.g. a year, involves in an extra hack of showing one week on the X-axis
of RRDtool, but showing data for 52 weeks (or 53). It can probably be
done. That does not mean you should try.

"select another tool": i have no suggestions on ready to use programs.
Look for them, or roll your own. Use one of the available "normal"
databases, and a separate graphing program. With some clever db design you
will be able to achieve what you want, with only a few selects at graph
time, and an insert at event time.

Even if you have to build everything yourself from scratch, you will need
less time and effort in the end.

Maybe others will not agree with me, and maybe I am too pessimistic, or
maybe I did not quite understand all you are trying to do. Everybody feel
free to voice your opinion.

\Back to vacation mode now!

Cheers,
Alex




More information about the rrd-users mailing list