[mrtg] Re: trying to use external script for graphing

Alex van den Bogaerdt alex at ergens.op.het.net
Mon Dec 13 22:57:25 MET 2004

On Mon, Dec 13, 2004 at 10:56:43AM -0500, John Barbieri wrote:

> im trying to use an external script to do graphing. when i run the 
> script manually, i get output from the script, but nothing appears on 
> the graphing.

Usually this is one of two problems.  I'll describe them, and tell you
how to spot them:

Problem #1:  You are graphing it as a normal counter and the increase
is less than one per second.  Less than one meaning zero.  The graph
_is_ created as is to be expected, it just shows zeros.

Problem #2:  You are using programs in your script that cannot be
found when the script is run from cron (cron->mrtg->yourscript)

Have a close look at the first three lines of your MRTG log file.
Each time MRTG runs, these lines will change.  The first line should
show the numbers that the script produced.  The next two contain the
computed rate, before normalization.

Make sure you know when MRTG ran, then copy the first line of your
mrtg log file (head -1 yourmrtg.log >> /tmp/sometmpfile)
Do this a couple of times.

After doing this for two or three times, the file /tmp/sometmpfile
contains a number of lines:

timestamp value1 value2
timestamp value1 value2
timestamp value1 value2

Compute the rate like rateup would do:

rate = (this.value1 - prev.value1) / (this.timestamp - prev.timestamp)

If this produces a number smaller than one, you know it is problem #1.

Solution/workaround for #1:  multiply the target by a number, or use
the "perminute" or even "perhour" option.

If OTOH the values look strange (possibly -1, or 4294967295) and don't
change, it will be problem #2.  This can happen when the PATH setting
inside your cron environment differs from the one on your command line.

Solution for #2: make sure to use absolute paths for ALL external commands,
such as "grep -> /bin/grep", "wc -l -> /usr/bin/wc -l" and so on.


Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the mrtg mailing list