[rrd-users] Getting last RRA update time

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Thu Dec 22 11:02:51 CET 2011

```> If I have the following RRAs with a poll interval of 300 seconds:
>
> RRA:MAX:0.5:1:576 - No consolidation for ~2 days
> RRA:MAX:0.5:6:672 - 30m CF for ~2 weeks
> RRA:MAX:0.5:24:744 - 2h CF for ~2 months
> RRA:MAX:0.5:288:732 - 24h CF for ~2 years
>
> Each RRA is going to be filled when there is sufficient data to create
> the data point (based on the steps) (i.e. it is going to take 24h to
> fill a single data point in the bottom RRA).

Not just any 24h. And that's also the basis of my answer to you.

> Is there anyway to determine, at graph generation the date and time
> that the data point was last updated, e.g.

rrdtool graph does not have the information, rrdtool info does. You need to call both. There will be a small chance that you run rrdtool update inbetween calls to rrdtool info and rrdtool graph. You can avoid being affected by this if you run rrdtool graph with a specific end time, not 'now'.

What you can do is:
* get the current time
* get the last update time
* get the amount of seconds per RRA row (e.g. 288*300=86400)
* compute the update time from this, e.g. an integer division followed by a multiplication: \$last_update/86400*86400
* rrdtool graph using the time you collected as end time, use the information collected in the previous step to inform your users

Please notice I said: integer division.  The outcome of dividing by 86400 followed by multiplying by 86400 will not be the same in such a case, except in slightly more than 0.1 percent of the cases.

Current time is 1324548058
Divide by 86400 and get 15330
Multiply by 86400 and get 1324512000

This timestamp will be the end time for the last entry in the RRA with steps=288

HTH
Alex

```

More information about the rrd-users mailing list