[rrd-users] Re: How do I print totals

Alex van den Bogaerdt alex at slot.hollandcasino.nl
Wed Jul 25 01:25:46 MEST 2001


Clarence Hart wrote:

> I would like to print the total amount of pages printed over a period of 
> time.  On my graph it displays peaks and valleys as normal and at the bottom I 
> display "MIN, MAX, AVG, LAST"....
> 	
> 	But how in the heck to I display "TOTAL"???

You are displaying "pages/sec" right now.  How do you get from there
to "pages"? Easy, multiply by "sec".  You end up with "(pages/sec)*sec"
which computes to "pages".

The only thing now to figure out is how many seconds you are graphing.
This is easy, as long as you keep certain things in mind.

1) Always end on a multiple of (step_time * PDPs per CDP).  If your
   step time is 300 seconds and you are graphing 400 pixels, each
   pixel should display 300 seconds, or 600 seconds, or 900 and so on.
   This means the amount of time must be (400*300=)120000 seconds, or 
   240000, or 360000 and so on.  The end time must be n*300, or n*600
   or n*900 and so on.

   For instance: right now it is "Wed Jul 25 01:05:56 CEST 2001", which
   is 996015956 seconds since the epoch.  This cannot be divided by 300
   (nor by 600 or any other multiple of 300) without having a remainder.
   996015900 can be divided by 300.  It cannot be divided by 600 or any
   other multiple of 300.  996015600 can be divided by 600.  So, if I
   would graph 2 PDPs per CDP (600 seconds per pixel), I need to set the
   end time to 996015600.
   
2) Always start on a multiple of (step_time * PDPs per CDP).  The same
   computations as for (1) are applicable.

3) Now you know for sure how many seconds will be graphed.  Use this
   number to multiply the AVERAGE number by.

For instance, you could use integer division and multiplication from
a bash script.  A similar program can be written in perl, if you know
how to program perl. (program is not tested but should work after
completing the rrdtool command.  use at own risk, YMMV etcetera.)

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

PIX=400			# width of the graph
STEPS=3			# PDPs per CDP
STEPSIZE=300		# duration of one PDP
CDP=$((STEPSIZE*STEPS))	# seconds shown per pixel
NOW=`date +%s`		# current time in seconds since epoch format
NOW=$((NOW/CDP))	# divide followed ...
NOW=$((NOW*CDP))	# ... by multiply.
DURATION=$((PIX*CDP))	# total time span of graph

rrdtool graph picture.png --start end-$DURATION --end $NOW --width $PIX \
     --img-format PNG ...
 ... DEF:pagespersecond=myprinter.rrd:pagecounter:AVERAGE \
     CDEF:total=pagespersecond,$DURATION \
     GPRINT:total:"During this interval %6.0lf pages have been printed\n"
---cut here---


HTH
-- 
   __________________________________________________________________
 / 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 |
+----------------------------------------------------------------------+
| Technical questions sent directly to me will be nuked. Use the list. | 
+----------------------------------------------------------------------+
| http://faq.mrtg.org/                                                 |
| http://rrdtool.eu.org  --> tutorial                                  |
+----------------------------------------------------------------------+

--
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