[mrtg] MRTG Script error
Steve Shipway
s.shipway at auckland.ac.nz
Wed Apr 23 00:20:26 CEST 2008
> ################################
> #disk.sh
> #!/bin/bash
> Kbr=`iostat -x |grep sda | awk '{print $7}' |sed "s/[.]//"`
> Kbw=`iostat -x |grep sda | awk '{print $6}' |sed "s/[.]//"`
> echo $Kbr
> echo $Kbw
> ################################
1) The #! Line should always be first in the script for maximum
portability
2) You should always either explicitly set PATH or else give the full
path of the commands iostat, grep, awk, sed etc else you have potential
PATH problems and security issues.
3) The grep|awk|sed pipeline is needlessly complex (as has been
previously mentioned)
4) You need to output FOUR lines for a MRTG plugin, although the last 2
can be blank. Technically, line 3 should contain the device uptime, and
line four contain the device name.
5) You should probably change that sed to something like s/\.\d*// I
think, if you're trying to cut off the trailing decimals. However, if
you're running MRTG with RRDTool, there's no need to do this as you can
use decimals.
Steve
More information about the mrtg
mailing list