[mrtg] Graphing printer usage

Steve Shipway s.shipway at auckland.ac.nz
Thu Oct 20 03:00:14 CEST 2011


Some comments on your configuration.  The cause of your incorrect values is
(1) and (5).

 

1.       If your samples come every 5min, set Interval:5 (the RRD updates
every 5 min).  You will need to delete old .rrd files when you change this.
The Interval is how long between updates, in your case 5min.

2.       You do not need to set Factor[_]:1 , it does nothing.

3.       Do not use Step[]:300 , it does nothing (the default is 300s=5min)
and it is an experimental directive anyway.

4.       Best practice is to put the Target[] line first for a given set of
directives.

5.       You set Options[_]:gauge,growright at the top but then override
with Options[] for each specific target.  I think you should instead use
Options[^]:gauge,growright which is the prepend target, not the default.

6.       If you can get your script to output a running total of pages
printed rather than a count over the last 5min, then you can remove the
'gauge' option and add 'perminute' instead to give a more accurate
pages-per-minute calculation.

7.       Your script should output 4 lines; the third and fourth lines can
be blank as they are only used in native-mode MRTG.  The first two can be
integers, decimals (if using RRDTool mode), or 'U' (for unknown).

8.       You might like to consider adding a ' / 5' (spaces important) to
the end of your Target[] lines.  This will divide by 5 to get a per-minute
rate which is better for graphing.  This may not work too well if you are
not using RRDTool as Native mode cannot handle decimals correctly.

 

Which frontend are you using for MRTG/RRD?  Alternatively, are you running
MRTG in native mode (.log files)?

 

Steve

 

 

  _____  

Steve Shipway

ITS Unix Services Design Lead

University of Auckland, New Zealand

Floor 1, 58 Symonds Street, Auckland

Phone: +64 (0)9 3737599 ext 86487

DDI: +64 (0)9 924 6487

Mobile: +64 (0)21 753 189

Email:  <mailto:s.shipway at auckland.ac.nz> s.shipway at auckland.ac.nz

P Please consider the environment before printing this e-mail 

 

 

From: mrtg-bounces+s.shipway=auckland.ac.nz at lists.oetiker.ch
[mailto:mrtg-bounces+s.shipway=auckland.ac.nz at lists.oetiker.ch] On Behalf Of
Chris Goralski
Sent: Thursday, 20 October 2011 12:47 p.m.
To: mrtg at lists.oetiker.ch
Subject: [mrtg] Graphing printer usage

 

Hi,

 

I've recently been working on a project which focuses on gathering printer
meter readings using snmp and placing this data into a mysql db.  This all
works fine.  I do this every 5 minutes. 

 

I've since installed MRTG and am wanting to graph the number of print jobs
during this 5 minute period.

 

I've created a PHP script which is set as the target in mrtg.cfg.   The
printer name can be passed to the script as a command line option which
makes it particularly good in this sense.   The script queries mysql and
calculates the number of pages printed in the last 5 minutes.  This data is
then output in the form:

5     

0

 

(Just the two lines)  The 5 represents say, 5 pages in total and the 0
represents 0 b/w pages.

 

I'll post my mrtg.cfg file below.

 

 

# Global configuration

WorkDir: /var/www/mrtg/printers

MaxBytes[_]: 20000

Options[_]: gauge,growright

Refresh: 300

Interval: 60

Factor[_]: 1

 

# E0_ColLaser

MaxBytes[E0_ColLaser]: 1500

AbsMax[E0_ColLaser]: 3000

Options[E0_ColLaser]: growright, nopercent, noinfo, withzeroes, integer,
perhour, unknaszero

Step[E0_ColLaser]: 300

Target[E0_ColLaser]: `php /var/www/mrtg/scripts/get_meters_from_db.php
E0_ColLaser`

Title[E0_ColLaser]: Meters - E0_ColLaser

PageTop[E0_ColLaser]: <h1>Meters - E0_ColLaser</h1>

YLegend[E0_ColLaser]: Jobs in the past 5 minutes

ShortLegend[E0_ColLaser]: Pages / 5 Mins

LegendI[E0_ColLaser]: Total Prints / 5 Mins

LegendO[E0_ColLaser]: Colour Prints / 5 Mins

 

# E2_ColLaser

MaxBytes[E2_ColLaser]: 1500

AbsMax[E2_ColLaser]: 3000

Options[E2_ColLaser]: growright, nopercent, noinfo, withzeroes, integer,
perhour, unknaszero

Step[E2_ColLaser]: 300

Target[E2_ColLaser]: `php /var/www/mrtg/scripts/get_meters_from_db.php
E2_ColLaser`

Title[E2_ColLaser]: Meters - E2_ColLaser

PageTop[E2_ColLaser]: <h1>Meters - E2_ColLaser</h1>

YLegend[E2_ColLaser]: Jobs in the past 5 minutes

ShortLegend[E2_ColLaser]: Pages / 5 Mins

LegendI[E2_ColLaser]: Total Prints / 5 Mins

LegendO[E2_ColLaser]: Colour Prints / 5 Mins

 

 

NB:  My printers print at 25 pages per minute.   I've used 25*60 to get a
pages per hour figure and hopefully set the global interval at 60 minutes.

 

The figures I'm getting are completely wrong.  For example, I've printed at
the most 2 or 3 pages and yet my graph shows the following values and the
scale has a max value of 36?

 


Total Prints / 5 Mins

35 Pages / 5 Mins

0 Pages / 5 Mins 

0 Pages / 5 Mins 


Colour Prints / 5 Mins

11 Pages / 5 Mins 

0 Pages / 5 Mins 

0 Pages / 5 Mins 

 

 

Please, any assistance in understanding:

1)       What output I need to provide from my script so that MRTG can use
it as input data 

2)      Configure MRTG to simply graph the integer value for pages printed
per 5 minute interval.

 

 

 

Cheers,

Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20111020/fcf7e985/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4928 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/mrtg/attachments/20111020/fcf7e985/attachment-0001.bin 


More information about the mrtg mailing list