[mrtg] MRTG Script error ... Now Slightly OT

Steve Shipway s.shipway at auckland.ac.nz
Wed Apr 23 02:45:12 CEST 2008


Keeping this in the mailing list because it has a relevance to people
writing plugins using vmstat or iostat output parsing.

> I actually tried this out.. ( with the corrected paths ). On a Fedora
> Core 7 / 8 machine it produces the same output every time I run it.

Yes, it would do, unless you run it at large time intervals.

When you run iostat (or vmstat) with no numerical parameters, you get
the average *since system boot*.

If you run it with numbers, eg:

iostat -x 2 3

Then you will get three sets of figures at 2-sec intervals.  The first
is the average since boot, and the second and third are the averages
over the preceding 2-sec intervals.

So, you need to have something more like:

/usr/bin/iostat -x 10 2 | /bin/awk 'BEGIN{r=0}/sda/{r=$6}END{print r}'

which will give you an average of a 10-sec interval at the current point
in time as a decimal, ready for RRDTool.  You will now need to be
careful about your plugin timeout settings.  A sample period of less
than 10 sec is probably not good because you will get too much
spikiness.

Steve



More information about the mrtg mailing list