#!/bin/sh
# set -x
# Shell script to monitor or watch the disk space
# It will print out volumes, if the (free available) percentage of space is >= 70%.
# -------------------------------------------------------------------------
# Set admin email so that you can get email.ADMIN="root"
# set alert level 70% is default
ALERT=70
# Exclude list of unwanted monitoring, if several partions then use "|" to separate the partitions.
# An example: EXCLUDE_LIST="/dev/hdd1|/dev/hdc5"
EXCLUDE_LIST="/junk"
#
# Files with all the hostnames
Systems[1]="file1"
Systems[2]="file2"
#
# -------------------------------------------------------------------------
#
function main_prog() {
while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1)
partition=$(echo $output | awk '{print $2}')
if [ $usep -ge $ALERT ] ; then
echo $(hostname)" : \"$partition ($usep%)\" "
fi
done
}
#-------------------------------------------------------------------------
# Check to see if Host File exists
for FILE in ${Systems[@]}
do
if [ -f $FILE ];
then
echo "Using $FILE file"
else
echo "File $FILE does not exists. Exiting."
exit 1
fi
done
for SERVER in `cat "${Systems[@]}"`
do
ssh ${SERVER} df -H | grep -vE "^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}" | awk '{print $5 " " $6}' | main_prog
done