[rrd-developers] Re: How to exactly get last measured value?

Alex van den Bogaerdt alex at ergens.op.het.net
Sun Apr 13 13:52:03 MEST 2003


On Sat, Apr 12, 2003 at 07:27:13PM +0200, Michal Foksa wrote:

>   - I work little front end for rrdtool. Data are collected with MRTG.
>   I need to read last measured value from rrd. But I dont know how to
>   exactly get last measured value.

Last measured value?  Have a look at the output of "rrdtool info".

I think you mean to say "last calculated rate" which is something
entirely different.

RRDtool will, when a new value is given to it, look at the timestamp.
It will compute a rate (see faq.mrtg.org) and this rate *may* go into
an RRA.

Each row in an RRA covers a certain amount of time.  The row will be
filled with a rate (or with "unknown") when the timestamp in the update
command is at or after the end of the interval.

Example:

intervals:
   [...]
1  11:20 UTC to 11:25 UTC.  
2  11:25 UTC to 11:30 UTC.  
3  11:30 UTC to 11:35 UTC.  
4  11:35 UTC to 11:40 UTC.  
   [...]

An update with a timestamp of 11:32 will result in intervals 1 and 2
being set.  Intervals 3 and 4 are not completed yet.

Ask for the last update time (using "rrdtool info" or "rrdtool last"),
compute the last computed row in the RRA (using modulo) and query for
that rate.

1) rrdtool info
    - collect useful information such as
         "last_update = 1050231657"
         "step = 3600"
         "rra[0].pdp_per_row = 1"
2) compute last computed rate
    - step size is 3600
    - RRA steps per row is 1
    - time per row is 1*3600 is 3600
    - Each row spans time range n*3600 to (n+1)*3600
    - Last update at 1050231657 is inside interval 1050231600 to 1050235200
      but this interval has not yet been completed (the end is after "now")
    - Last computed rate is in the interval before this: 1050228000 to 1050231600
3) fetch rate from last computed interval
    - time per interval is 3600, last computed interval ends at 1050231600
    - rrdtool fetch ....   --end 1050231600 --start end-3600

The end time of the last updated row in an RRA can be computed as follows:

   rra_step = $step * $pdp_per_row
   endtime = $last_update - ( $last_update modulo $rra_step)

>   - is possible open pipeline to rrdtool ( in C languge ) and give its
>   commands? More commands in one pipeline ( Ex.: fetch, graph, update,
>   .... ). I use popen, it first starts shell and shell interprets
>   argument, and so on. It is slowly and not very secure.

Look at "rrdtool -".  See the manual.

HTH
Alex
-- 
Much of what looks like rudeness in hacker circles is not intended to give
offence. Rather, it's the product of the direct, cut-through-the-bullshit
communications style that is natural to people who are more concerned about
solving problems than making others feel warm and fuzzy.

http://www.tuxedo.org/~esr/faqs/smart-questions.html

--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-developers mailing list