The last_update command stores a timestamp when the rrdfile was
modified (so it should be very similar to the mtime of the file, under
normal circumstances). But you don't want this, you want the
timestamp of the last "slot" in the RRA, right?
How about this:
#!/bin/sh
FILE=$1
DURATION=$2
T=/tmp/rrd.$$
rrdtool info $FILE > $T
LAST=`awk '/last_update/{print $3}' $T`
ROWS=`awk '/rra.3..rows/{print $3}' $T`
PDP=`awk '/rra.3..pdp/{print $3}' $T`
STEP=`awk '/step/{print $3}' $T`
LENGTH=`echo "$PDP * $ROWS * $STEP" | bc `
#echo $LAST $ROWS $PDP
rrdtool fetch $FILE AVERAGE -s -$LENGTH | tail -n +3 > $T
FIRST=`head -n 1 $T | sed 's/:.*//'`
LAST=`tail -n 1 $T | sed 's/:.*//'`
echo $FIRST $LAST
rm $T
On Tue, Jul 27, 2010 at 16:14, Stevens, Weston J
<[email protected]> wrote:
> But say the last recorded CDP in the month RRA was a day ago, the last_update
> and the last timestamp would be separated by a day using that method.
>
> -----Original Message-----
> From: Jesse Becker [mailto:[email protected]]
> Sent: Tuesday, July 27, 2010 12:57 PM
> To: Stevens, Weston J
> Cc: [email protected]
> Subject: Re: [Ganglia-general] Parsing rrdtool dump output using Perl
>
> You could instead use rrdinfo to get the last_update timestamp. The starting
> timestamp for the "month" RRA can then be computed. Using the default RRA
> definitions, it should be something like:
>
> last_updated - 2459520 (=15*244*672)
>
>
> On Tue, Jul 27, 2010 at 15:32, Stevens, Weston J
> <[email protected]> wrote:
>> Say for default Ganglia for example I wanted to grab the first and last
>> timestamps for the month RRA so I can run a bounds check on begin/end time
>> inputs. Ideally I'd like to get all this information by simply specifying
>> the RRD granularity in seconds, without having to also specify the length of
>> the RRD to get the last timestamp in a command line. Using rrdtool dump,
>> what would be a good regex or anything else like Perl XML support that could
>> do this for me? Or a completely different and better way to do it?
>>
>>
>>
>> ----------------------------------------------------------------------
>> -------- The Palm PDK Hot Apps Program offers developers who use the
>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
>> of $1 Million in cash or HP Products. Visit us here for more details:
>> http://ad.doubleclick.net/clk;226879339;13503038;l?
>> http://clk.atdmt.com/CRS/go/247765532/direct/01/
>> _______________________________________________
>> Ganglia-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ganglia-general
>>
>
>
>
> --
> Jesse Becker
> Every cloud has a silver lining, except for the mushroom-shaped ones, which
> come lined with strontium-90.
>
--
Jesse Becker
Every cloud has a silver lining, except for the mushroom-shaped ones,
which come lined with strontium-90.
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Ganglia-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-general