shell script for nas disk space monitoring
bin/bash
# Shell Script to monitor NAS backup disk space
# Shell script will mount NAS using mount command and look for total used
# disk space. If NAS is running out of disk space an email alert will be sent to
# admin.
# -------------------------------------------------------------------------
# Copyright (c) 2004 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
#!/bin/bash
#*** SET ME FIRST ***#
NASUSER="Your-User-Name"
NASPASS="Your-Password"
NASIP="nas.yourcorp.com"
NASROOT="/username"
NASMNTPOINT="/mnt/nas"
EMAILID="[EMAIL PROTECTED]"
GETNASIP=$(host ${NASIP} | awk '{ print $4}')
# Default warning limit is set to 17GiB
LIMIT="17"
# Failsafe
[ ! -d ${NASMNTPOINT} ] && mkdir -p ${NASMNTPOINT}
mount | grep //${GETNASIP}/${NASUSER}
# if not mounted, just mount nas
[ $? -eq 0 ] && : || mount -t cifs //${NASIP}/${NASUSER} -o
username=${NASUSER},password=${NASPASS} ${NASMNTPOINT}
cd ${NASMNTPOINT}
# get NAS disk space
SPACE=$(du -hs|cut -d'G' -f1)
cd /
umount ${NASMNTPOINT}
# compare and send an email
if [ $SPACE -ge $LIMIT ]
then
logger "Warning: NAS Running Out Of Disk Space [${SPACE} G]"
mail -s 'NAS Server Disk Space' ${EMAILID} <<EOF
NAS server [ mounted at $(hostname) ] is running out of disk space!!!
Current allocation ${SPACE}G @ $(date)
EOF
else
logger "$(basename $0) ~ NAS server ${NASIP} has sufficent disk space for
backup!"
fi
"Do not worry about anything; instead
PRAY ABOUT EVERYTHING."
Philippians 4:6
Best Regards
Dinesh Jadhav - 9224661100
Redhat Certified Engineer
---------------------------------
Get an email ID as [EMAIL PROTECTED] or [EMAIL PROTECTED] Click here.
[Non-text portions of this message have been removed]