robo
September 22, 2011, 4:18pm
1
Hi all
can any one help me to script monitoring
CPU load avg when reaches threshold value
and disk usage if it exceeds some %
tried using awk but when df -h out put is in two different lines awk doesnt work for the particular output in two different line ( output for df -h is in two lines when the filesystem is in lvm or the path is larger )
can you paste the awk code yo tried? may be we can help to modify it...
--ahamed
robo
September 22, 2011, 4:28pm
3
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ if( $4 < 10 ) print $5 " warning " $1 }'
root@bt:~# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda4 15G 7.6G 5.8G 57% /
none 1.1G 349k 1.1G 1% /dev
none 1.1G 25k 1.1G 1% /dev/shm
none 1.1G 99k 1.1G 1% /var/run
none 1.1G 0 1.1G 0% /var/lock
none 1.1G 0 1.1G 0% /lib/init/rw
/dev/sda7 61G 36G 25G 60% /media/Utils
/dev/sda5 17G 3.1G 14G 19% /media/Dev
/dev/sda6 38G 12G 26G 32% /media/New Volume
/dev/sda1 32G 15G 17G 47% /media
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ if( 100-$5 < 10 ) print $6 " warning " $1 }'
this will check if available is < 10 and report the warning. What is the exact condition you want to check?
--ahamed
robo
September 22, 2011, 4:48pm
5
ahamed101:
root@bt:~# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda4 15G 7.6G 5.8G 57% /
none 1.1G 349k 1.1G 1% /dev
none 1.1G 25k 1.1G 1% /dev/shm
none 1.1G 99k 1.1G 1% /var/run
none 1.1G 0 1.1G 0% /var/lock
none 1.1G 0 1.1G 0% /lib/init/rw
/dev/sda7 61G 36G 25G 60% /media/Utils
/dev/sda5 17G 3.1G 14G 19% /media/Dev
/dev/sda6 38G 12G 26G 32% /media/New Volume
/dev/sda1 32G 15G 17G 47% /media
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ if( 100-$5 < 10 ) print $6 " warning " $1 }'
this will check if available is < 10 and report the warning. What is the exact condition you want to check?
--ahamed
yeah this works if the output is
like
/dev/sda5 17G 3.1G 14G 19% /media/Dev
/dev/sda6 38G 12G 26G 32% /media/New Volume
/dev/sda1 32G 15G 17G 47% /media
but where as if the out put is something like
/dev/mapper/vol00-lvabcdef
17G 3.1G 14G 19% /media/Dev
/dev/sda6 38G 12G 26G 32% /media/New Volume
/dev/sda1 32G 15G 17G 47% /media
this mismatches $5 and $6 so the out put varies
Try this...
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{if(NF<2){x=$0;getline;$0=x" "$0}} { if( 100-$5 < 10 ) print $6 " warning " $1 }'
--ahamed
robo
September 22, 2011, 5:02pm
7
will try this
hopefully this works thanx a lot bro
will update tomoro
robo
September 27, 2011, 3:13pm
8
this worked ahamed
can you help me to script for hign physical memory usage