data | while read output;

#!/bin/bash
# set -x # Uncomment to debug this script
# set -n # Uncomment to check syntax without any execution
# Shell script to monitor or watch the disk space
####Main Script####

df -H | grep -vE '^Filesystem | none' | awk '{ print $1 " " $5 }' | while read output;
do
echo $output
perc=$(echo $output | awk '{ print $2 }' | cut -d'%' –f2 )
part=$(echo $output | awk '{ print $1 }' )

if [ $perc -ge 90 ]; then
echo "Critical Warning: Filesystem \"$part\" at “$perc”% of capacity” | \
mail -s "Critical Warning: Filesystem \”$part\” at “$perc”% of capacity” 
mail@mail.com
 fi
done

Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all