Hi Buddies,
The following is shell scripts which was borrowed from linux box for load average check. it runs good.
(this structure is simple, when load average is too high, it will send alert to user)
#!/usr/bin/ksh
# Set threshold for 1, 5 and 15 minture load avarage
# configured for 12-processors system
max_1=48
max_5=36
max_15=24
# Set the string which appears before the load average in the uptime command
load_text='load average: '
#Email list
mail_to='abc@abc.com'
alert=n
up=`uptime`
# Parse out the current load average from the uptime command
load_1=`echo $up | /usr/xpg4/bin/awk -F "$load_text" '{ print $2 }' | cut -d, -f1 | cut -d. -f1`
load_5=`echo $up | /usr/xpg4/bin/awk -F "$load_text" '{ print $2 }' | cut -d, -f2 | cut -d. -f1`
load_15=`echo $up | /usr/xpg4/bin/awk -F "$load_text" '{ print $2 }' | cut -d, -f3 | cut -d. -f1`
# Set alert=y if any of the average are above their thresholds
if [ $load_1 -ge $max_1 ]
then
alert=y
elif [ $load_5 -ge $max_5 ]
then
alert=y
elif [ $load_15 -ge $max_15 ]
then
alert=y
fi
# Send mail if the alert threshold was reached
if [ ! $alert = n ]
then
mail -s "High load on procede02" $mail_to < `uptime`
fi
---
Now we use it in solaris 9, get some errors like
$./monitor_load_average.sh
./monitor_load_average.sh[43]: 9:32am up 3 day(s), 6:30, 9 users, load average: 0.32, 0.58, 0.55: cannot open
Can any expert give me a hand to debug it? (why have [43]..? why can not open? ..I think this is a syntax problem in AWK..)
Thank you very much in advance
Jerry