[rrd-users] Logging the real min and max is possible

Alex van den Bogaerdt alex at slot.hollandcasino.nl
Fri Aug 25 00:59:05 MEST 2000


The discussion seems to have ended.
It did help me to understand one vital part:
Minima and maxima are collected in the cdp_prep part and this makes
it possible to do the following:
- define a step time of 1
- define the RRAs with steps==60
This will keep the data per minute but it makes it possible to get
the real minimum and maximum in each step, not an averaged one.

I have created a small bash script that shows this.  It was created
on a linux system and it needs the "join" program.  The table that
should be created is also included so if your OS does not include
this program (or bash, or tail)

The script creates the following files in the current directory:
   output.html
   picture.png
   test.rrd
   a
   b
   c
   d

---cut here---
#!/bin/bash

# Create a database, starting at Thu Aug 24 14:00:00 MET DST
# which is 12:00:00 UTC, seconds since epoch==967118400
# Actually, start it one second before so we can update @ 14:00
#
# The parameters are:
#    step size ==   1      needed for min/max
#    heartbeat == 600      need updates every 10 minutes or better
#    minimum   ==   0      PRI with 30 channels,  0 is the minimum
#    maximum   ==  30      PRI with 30 channels, 30 is the minimum
#    xff       == 0.5      a common value
#    step      ==  60      1 minute min/max/lst/avg values
#    rows      ==  10      10 of those, enough for the example
rrdtool create test.rrd \
   --start 967118399 \
   --step 1 \
   DS:x:GAUGE:600:0:30 \
   RRA:MIN:0.5:60:10 \
   RRA:MAX:0.5:60:10 \
   RRA:LAST:0.5:60:10 \
   RRA:AVERAGE:0.5:60:10

# enter number of modems in use at several points in time
# Due to the nature of RRDtool we have to insert the value at the
# *next* event.
#
# The initial # is unknown.
#  @ 967118400 the # is known to be 2, remember and write the U
#  @ 967118420 the # increases to 3, remember and write the 2
#  @ 967118530 the # increases to 4, remember and write the 3
#  @ 967118555 the # decreases to 3     etcetera
#  @ 967118590 the # decreases to 2
#  @ 967118630 the # increases to 3
#  @ 967118720 the # decreases to 2
#  @ 967118721 the # increases to 3
#  @ 967118761 the # decreases to 0 (probably a problem!)
#  @ 967118900 a timer expires and the value is written to the database
#              this means that no trigger was received in a long time
#
rrdtool update test.rrd \
  967118400:U 967118420:2 967118530:3 967118555:4 967118590:3 \
  967118630:2 967118720:3 967118721:2 967118761:3 967118900:0

#
# fetch the values
echo '---time--- ------MIN-------' > a
echo '---time--- ------MAX-------' > b
echo '---time--- ------LAST------' > c
echo '---time--- ----AVERAGE-----' > d
rrdtool fetch test.rrd MIN --start 967118460 --end 967118880 |tail +3 >> a
rrdtool fetch test.rrd MAX --start 967118460 --end 967118880 |tail +3 >> b
rrdtool fetch test.rrd LAST --start 967118460 --end 967118880 |tail +3 >> c
rrdtool fetch test.rrd AVERAGE --start 967118460 --end 967118880 |tail +3 >> d
echo -n '<body><pre>'
join a b | join - c | join - d
echo -n '</pre>'
rrdtool graph picture.png --start 967118400 --end 967118880 -a PNG \
   --imginfo '<img src="%s" WIDTH="%lu" HEIGHT="%lu" ALT="picture.png">' \
   --x-grid MINUTE:1:MINUTE:1:MINUTE:1:0:%H\:%M \
   DEF:a=test.rrd:x:MIN \
   DEF:b=test.rrd:x:MAX \
   DEF:d=test.rrd:x:AVERAGE \
   AREA:b#FF0000:max \
   AREA:a#00C000:min \
   LINE2:d#0000FF:avg | grep -v '^[0-9]*x[0-9]*$'
echo '</body>'
exit

Input:
  967118400:U 967118420:2 967118530:3 967118555:4 967118590:3 \
  967118630:2 967118720:3 967118721:2 967118761:3 967118900:0
Result:
---time--- ----MIN--------- ----MAX--------- ----LAST-------- ----AVERAGE-----
967118400: NaN NaN NaN NaN
967118460: 2.0000000000e+00 3.0000000000e+00 3.0000000000e+00 2.6666666667e+00
967118520: 3.0000000000e+00 3.0000000000e+00 3.0000000000e+00 3.0000000000e+00
967118580: 3.0000000000e+00 4.0000000000e+00 3.0000000000e+00 3.4166666667e+00
967118640: 2.0000000000e+00 3.0000000000e+00 3.0000000000e+00 2.3333333333e+00
967118700: 3.0000000000e+00 3.0000000000e+00 3.0000000000e+00 3.0000000000e+00
967118760: 2.0000000000e+00 3.0000000000e+00 3.0000000000e+00 2.9833333333e+00
967118820: 0.0000000000e+00 3.0000000000e+00 0.0000000000e+00 5.0000000000e-02
967118880: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
---cut here---

-- 
   __________________________________________________________________
 / alex at slot.hollandcasino.nl                  alex at ergens.op.het.net \
| work                                                         private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+
| http://faq.mrtg.org/                                                 |
| http://rrdtool.eu.org  --> tutorial                                  |
+----------------------------------------------------------------------+
---cut here---

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



More information about the rrd-users mailing list