#!/bin/sh
# set -x
# Shell script to monitor or watch the disk space
# -------------------------------------------------------------------------
# Set admin email so that you can get email.
MAIL_LIST="xxxx@gmail.com"
# set alert level 90% is default
ALERT=80
#
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#
for lv1 in `df -h | grep -vE "^Filesystem|tmpfs|cdrom"|grep G|sed 's/ //g'|sed 's/G/G,/g'|sed 's/%/,/g'|cut -d, -f4-`
do
#echo $lv1
usep=`echo $lv1| cut -d',' -f1`
partition=`echo $lv1|cut -d',' -f2`
if [ $usep -ge $ALERT ] ; then
echo "Running out of space partitoin ${partition} used% (${usep}%) on server $(hostname)"|mail -s "Alert: Almost out of disk space $usep%" $MAIL_LIST
fi
done
# set -x
# Shell script to monitor or watch the disk space
# -------------------------------------------------------------------------
# Set admin email so that you can get email.
MAIL_LIST="xxxx@gmail.com"
# set alert level 90% is default
ALERT=80
#
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#
for lv1 in `df -h | grep -vE "^Filesystem|tmpfs|cdrom"|grep G|sed 's/ //g'|sed 's/G/G,/g'|sed 's/%/,/g'|cut -d, -f4-`
do
#echo $lv1
usep=`echo $lv1| cut -d',' -f1`
partition=`echo $lv1|cut -d',' -f2`
if [ $usep -ge $ALERT ] ; then
echo "Running out of space partitoin ${partition} used% (${usep}%) on server $(hostname)"|mail -s "Alert: Almost out of disk space $usep%" $MAIL_LIST
fi
done
No comments:
Post a Comment