create shell script to monitor swap.
#!/bin/bash
cd
. ./.profile
SWAP_THR=70
uname -a | awk '{print $2}'| read HOST
MAIL_GROUP='vikasthakur232@gmail.com'
df -h swap | awk '{print $5}' | tail -1 | sed 's/.$//'| while read output; do
SWAP_VAR=$(echo $output)
if [ $SWAP_VAR -gt $SWAP_THR ] ; then
MESSAGE=${MESSAGE}"Current Swap utilization is $SWAP_VAR percent on $HOME.\n "
echo -e $MESSAGE | mailx -s "SWAP status on $HOST." $MAIL_GROUP
fi
done
No comments:
Post a Comment