Popular Posts

Jan 31, 2018

File system utilization report in mail


File system utilization report in mail

Issue :
Very often file systems are filled with application logs and other data,This space filling makes the server to panic for the servers which do not have proper monitoring in place.

Goal :
Deploy a  script to monitor the file systems usage with a defined threshold and to notify the support team and application team to clear the space.

Solution :
A script has been created to monitor the File System usage with a threshold of 85%, This script will run in cron every 30 minutes and send a mail to mentioned mail ID's if any of the File System is more than 85%

#!/bin/ksh
#disk_usage.sh - Monitor the disk usage and alert the support/applicaiton team
################################
#       Begin               
#       Author : Roselin John
#       Version 0.1
# -
# -
# -
# -
# -
################################

HOST=`uname -n`
> /root/scripts/disk_log
> /root/scripts/disk_log.txt
df -k | sed '1d' | awk '{ if ($5> 85) {print "Filesystem", $6, "on Server '$HOST' is", $5, "used, Please clear space"}}' > /root/scripts/disk_log
if [ -s /root/root_scripts/disk_log ] ; then
unix2dos /root/root_scripts/disk_log /root/scripts/disk_log.txt
mailx -s "Disk Monitor Alert" judi@gmail.com < /root/scripts/disk_log.txt
fi


Update the below entry in cron
30 * * * * /root/scripts/disk_usage.sh 2>&1

File System Monitoring
File System Monitoring script
Monitor File system changes
filesystem usage

No comments:

Post a Comment

Popular Posts