[mrtg] MRTG Script error

Alex van den Bogaerdt alex at ergens.op.het.net
Tue Apr 22 11:44:57 CEST 2008

On Tue, Apr 22, 2008 at 07:52:53AM +0000, SYED JAHANZAiB ~!~ AA Internet Cable. Network Services wrote:

> But when i set it in MRTG , it shows me follwing error and donot updatedisk Graph.

> 2008-04-21 17:04:38 -- 2008-04-21 17:04:02: WARNING: Problem with External get '/usr/local/mrtg-2/bin/disk.sh':
>    Expected a Number for 'out' but got ''

> What could be the error ???

If it works from the command line but not from MRTG, it is likely
that your PATH setting is wrong when you run MRTG.

For instance:  awk is located in /usr/bin/awk but when MRTG is running
the PATH does not contain /usr/bin/.

Solution #1:
* Always use full paths:  write '/usr/bin/awk', not just 'awk'.
* Same for the other utilities you use.

Solution #2:
* Make sure PATH does contain all necessary directories:
* Your script should contain the following line:
* PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/you/bin
* Make sure you change the command so that it applies to your system.

In my opinion, solution #1 is the better one.

Remark about your script:  in almost all cases, you need not combine
'grep' and 'awk' and 'sed'.

Some examples:

wrong: grep 'x' | awk '{print $1}' 
good:  awk '/x/ {print $1}'

wrong: grep 'x' | sed 's/x/y/g'
good:  sed -n '/x/s/x/y/gp'

wrong: grep 'x' | awk '{print $1}' | sed 's/x/y/g'
good:  awk '/x/{gsub("x","y",$1);print $1}'


More information about the mrtg mailing list