check hdd space

#!/bin/sh
# check HDD space with email notification
# Sigit Afandhi @ Mei,2014
# Mailto: anti.trust30@yahoo.com.sg

#Remote Controller SSH
target=”192.168.10.5″
email=”kamu@emailmu.com”

ALERT=95    # set alert level 90% is default
SD=`date “+%d %h %Y – %H:%M:%S”`

sub_target=’Warning : Almost out of disk space’

ssh $USER@$target “df -H” | grep -vE ‘Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’ | while read output;
do
usep=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1 )
partition=$(echo $output | awk ‘{ print $2 }’ )

if [ $usep -ge $ALERT ]; then
echo “Running out of space \”$partition ($usep%)\” on $target  Time: $SD” |
mail -s “$sub_target $usep” $email
fi
done

,

Leave a Reply