Remember your dreams

Remember your dreams
Remember your dreams

Friday, February 28, 2020

Updated Monitor Server Disk Space

Monitoring of potential issues includes knowing when any volumes reach a certain capacity. It can take time to add space or free it up so being notified before an issue crops up is imperative for any DBA.

This is an updated version of the more complicated original version immediately below this link. I like and now use this more simplified version. 


  1. Set THRESH parameter to the percent of how full a volume is before an email is sent.
  2. Update the 2nd line (none|cdrom|qgscanner) to remove volumes you do not care about and do not want to be notified of.


I use cron to check during business hours of disk space issues.
# ----------------------------------------------
# -- Monitor disk space of drives and shares ---
# ----------------------------------------------
5,15,25,35,45,55 8-16 * * 1-5 /oracle/scripts/diskAlert.sh

diskAlert.sh

#!/bin/sh

THRESH=95;
df -PH | grep -vE 'none|cdrom|qgscanner' | awk '{ print $5 " " $1 }' | while read output;
do
  echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [[ $usep -ge $THRESH ]]; then
    echo -e "$(date) Threshold $THRESH% exceeded. \nRunning out of space on \"$partition ($usep%)\" on $(hostname)" |
    mail -s "Alert: `uname -n` low on disk space $usep%" email@company.com
  fi
done


Example of email when volume exceeds thhreshold:

Alert: halfmoon low on disk space 98%

Fri Dec  8 05:40:03 PST 2019 Threshold 95% exceeded.

Running out of space on "sharename.com:/mydrive20/LarryEllison (98%)" on halfmoon

No comments:

Post a Comment

Proactive Oracle DBA

This is a series of posts. I am working this to share some of the many scripts I schedule to automatically run to alert me of any current o...