shell script to alert cpu memory and disk usage help please

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

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

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

will try this
hopefully this works thanx a lot bro

will update tomoro

this worked ahamed
can you help me to script for hign physical memory usage