2016
April
Standard

Linux partition space alert script

A simple bash script to send email if /local mount point is used more than 90%:

# cat /root/disk.sh 
#!/bin/bash
CURRENT=$(df /local | grep /local | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -s '!!!Disk Space Alert ORACLE oracle.belomor.nl!!!' [email protected] -c [email protected] -c [email protected] -c [email protected] << EOF
Oracle partition remaining free space is critically low. Used: $CURRENT%
EOF
fi

##############

hourly run script:

# crontab -l | grep disk
@hourly /root/disk.sh
# date

Fri Apr  1 14:31:27 AZT 2016

more