[mrtg] Re: Incorrect SWAP and RAM values?
Dener Fernandes
df.listas at uol.com.br
Wed Feb 25 17:55:47 MET 2004
Hi,
I'm using these modest shell scripts that use TOP:
------------------------------
1)
#!/bin/sh
# cpu.sh
cpubusy=0
cpulivre=`/usr/local/bin/top -d2 | head -26 | tail -1 | awk -F" "
'{print $3}' |
sed -e 's/%//'`
echo $cpulivre | cut -d . -f1
cpubusy=`echo "100 - $cpulivre" | bc`
echo $cpubusy | cut -d . -f1
uptime | awk '{print $3, $4, $5}'
#uptime | sed 's:^.* up \(.*\), [0-9][0-9]* users.*$:\1:'
uname -n
exit 0
--------------------------------
2)
#!/bin/sh
# mem.sh
memlivre=0
swaplivre=0
#
linha=`/usr/local/bin/top -d1 | head -4 | tail -1`
memlivre=`echo $linha | awk -F" " '{print $4}' | sed -e 's/M//'`
swaplivre=`echo $linha | awk -F" " '{print $10}' | sed -e 's/G//'`
#
memlivre=`echo "1024 * $memlivre" | bc`
swaplivre=`echo "1048576 * $swaplivre" | bc`
#
echo $memlivre
echo $swaplivre | cut -d . -f1
#
# grava informagco complementar para o MRTG:
uptime | awk -F" " '{print $3, $4, $5}'
uname -n
#
exit 0
--------------------------------
Watch out for the output units of top ( Megabytes or Gigabytes). Then
you have to adjust the filter line above!
And the Target line inside MRTG's cfg file is:
Target[10.xxx.xxx.xxx.cpu]: `rsh -l mrtg hostname /usr/local/sbin/cpu.sh`
They work just fine in solaris 8 and Linux Mandrake 9.1.
Hope this can help!
Dêner Fernandes
--
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