Difference between revisions of "Linux Filesystem Alerting Script"
Jump to navigation
Jump to search
(Created page with "This convoluted beauty does a df -h on both a Production and Standby Filesystem (oracle datafile and backup directories) and warns when the threshold of 85% is exceeded and al...") |
|||
Line 1: | Line 1: | ||
This convoluted beauty does a df -h on both a Production and Standby Filesystem (oracle datafile and backup directories) and warns when the threshold of 85% is exceeded and alerts when 95% threshold is exceeded. | This convoluted beauty does a df -h on both a Production and Standby Filesystem (oracle datafile and backup directories) and warns when the threshold of 85% is exceeded and alerts when 95% threshold is exceeded. | ||
+ | <blockquote><pre> | ||
############################################################################ | ############################################################################ | ||
#!/bin/ksh | #!/bin/ksh | ||
Line 179: | Line 180: | ||
fi | fi | ||
+ | </pre></blockquote> |
Latest revision as of 22:03, 8 November 2019
This convoluted beauty does a df -h on both a Production and Standby Filesystem (oracle datafile and backup directories) and warns when the threshold of 85% is exceeded and alerts when 95% threshold is exceeded.
############################################################################ #!/bin/ksh # # Description : This script does a df -h on oracle and backup directories # on both prod and dr servers. Sends a daily report as # well as alerting when thresholds are exceeded. # # 13/12/2017 # nm # # ############################################################################ MAIL_LIST1="warningalerts@email.com" MAIL_LIST2="criticalalerts@email.com" LOG=/oracle/logs/filesystem_alert.log rm $LOG sd=`date +"%H"` # PRINT <PROD_SID> FILESYSTEM USAGE diskstat_backup_pr=`df -h | grep /backup | awk '{print "<PROD_SID> " $6 " " $5 " Used"}'` diskstat_oracle_pr=`df -h | grep /oracle$ | awk '{print "<PROD_SID> " $6 " " $5 " Used"}'` diskstat_oradata1_pr=`df -h | grep /oradata1 | awk '{print "<PROD_SID> " $6 " " $5 " Used"}'` diskstat_oradata2_pr=`df -h | grep /oradata2 | awk '{print "<PROD_SID> " $6 " " $5 " Used"}'` diskstat_oradata3_pr=`df -h | grep /oradata3 | awk '{print "<PROD_SID> " $6 " " $5 " Used"}'` # PRINT <DR_SID> FILESYSTEM USAGE DR_diskstat_backup_pr=`ssh mobbodbp1 df -h | grep /backup | awk '{print "<DR_SID> " $6 " " $5 " Used"}'` DR_diskstat_oracle_pr=`ssh mobbodbp1 df -h | grep /oracle$ | awk '{print "<DR_SID> " $6 " " $5 " Used"}'` DR_diskstat_oradata1_pr=`ssh mobbodbp1 df -h | grep /oradata1 | awk '{print "<DR_SID> " $6 " " $5 " Used"}'` DR_diskstat_oradata2_pr=`ssh mobbodbp1 df -h | grep /oradata2 | awk '{print "<DR_SID> " $6 " " $5 " Used"}'` DR_diskstat_oradata3_pr=`ssh mobbodbp1 df -h | grep /oradata3 | awk '{print "<DR_SID> " $6 " " $5 " Used"}'` # COMPUTE <PROD_SID> FILESYSTEM USAGE diskstat_backup=`df -h | grep /backup | awk '{sub(/%/,"",$5); print $5}'` diskstat_oracle=`df -h | grep /oracle$ | awk '{sub(/%/,"",$5); print $5}'` diskstat_oradata1=`df -h | grep /oradata1 | awk '{sub(/%/,"",$5); print $5}'` diskstat_oradata2=`df -h | grep /oradata2 | awk '{sub(/%/,"",$5); print $5}'` diskstat_oradata3=`df -h | grep /oradata3 | awk '{sub(/%/,"",$5); print $5}'` # COMPUTE <DR_SID> FILESYSTEM USAGE DR_diskstat_backup=`ssh mobbodbp1 df -h | grep /backup | awk '{sub(/%/,"",$5); print $5}'` DR_diskstat_oracle=`ssh mobbodbp1 df -h | grep /oracle$ | awk '{sub(/%/,"",$5); print $5}'` DR_diskstat_oradata1=`ssh mobbodbp1 df -h | grep /oradata1 | awk '{sub(/%/,"",$5); print $5}'` DR_diskstat_oradata2=`ssh mobbodbp1 df -h | grep /oradata2 | awk '{sub(/%/,"",$5); print $5}'` DR_diskstat_oradata3=`ssh mobbodbp1 df -h | grep /oradata3 | awk '{sub(/%/,"",$5); print $5}'` # ALERTS ON <PROD_SID> # Alert on /backup if [ $diskstat_backup -gt 85 ]; then echo "WARNING: $diskstat_backup_pr" >> $LOG elif [ $diskstat_backup -gt 95 ]; then echo "CRITICAL: $diskstat_backup_pr" >> $LOG else echo "OKAY: $diskstat_backup_pr" >> $LOG fi # Alert on /oracle if [ $diskstat_oracle -gt 85 ]; then echo "WARNING: $diskstat_oracle_pr" >> $LOG elif [ $diskstat_oracle -gt 95 ]; then echo "CRITICAL: $diskstat_oracle_pr" >> $LOG else echo "OKAY: $diskstat_oracle_pr" >> $LOG fi # Alert on /oradata1 if [ $diskstat_oradata1 -gt 85 ]; then echo "WARNING: $diskstat_oradata1_pr" >> $LOG elif [ $diskstat_oradata1 -gt 95 ]; then echo "CRITICAL: $diskstat_oradata1_pr" >> $LOG else echo "OKAY: $diskstat_oradata1_pr" >> $LOG fi # Alert on /oradata2 if [ $diskstat_oradata2 -gt 85 ]; then echo "WARNING: $diskstat_oradata2_pr" >> $LOG elif [ $diskstat_oradata2 -gt 95 ]; then echo "CRITICAL: $diskstat_oradata2_pr" >> $LOG else echo "OKAY: $diskstat_oradata2_pr" >> $LOG fi # Alert on /oradata3 if [ $diskstat_oradata3 -gt 85 ]; then echo "WARNING: $diskstat_oradata3_pr" >> $LOG elif [ $diskstat_oradata3 -gt 95 ]; then echo "CRITICAL: $diskstat_oradata3_pr" >> $LOG else echo "OKAY: $diskstat_oradata3_pr" >> $LOG fi #ALERTS ON <DR_SID> # Alert on /backup if [ $DR_diskstat_backup -gt 85 ]; then echo "WARNING: $DR_diskstat_backup_pr" >> $LOG elif [ $DR_diskstat_backup -gt 95 ]; then echo "CRITICAL: $diskstat_backup_pr" >> $LOG else echo "OKAY: $DR_diskstat_backup_pr" >> $LOG fi # Alert on /oracle if [ $DR_diskstat_oracle -gt 85 ]; then echo "WARNING: $DR_diskstat_oracle_pr" >> $LOG elif [ $DR_diskstat_oracle -gt 95 ]; then echo "CRITICAL: $DR_diskstat_oracle_pr" >> $LOG else echo "OKAY: $DR_diskstat_oracle_pr" >> $LOG fi # Alert on /oradata1 if [ $DR_diskstat_oradata1 -gt 85 ]; then echo "WARNING: $DR_diskstat_oradata1_pr" >> $LOG elif [ $DR_diskstat_oradata1 -gt 95 ]; then echo "CRITICAL: $DR_diskstat_oradata1_pr" >> $LOG else echo "OKAY: $DR_diskstat_oradata1_pr" >> $LOG fi # Alert on /oradata2 if [ $DR_diskstat_oradata2 -gt 85 ]; then echo "WARNING: $DR_diskstat_oradata2_pr" >> $LOG elif [ $DR_diskstat_oradata2 -gt 95 ]; then echo "CRITICAL: $DR_diskstat_oradata2_pr" >> $LOG else echo "OKAY: $DR_diskstat_oradata2_pr" >> $LOG fi # Alert on /oradata3 if [ $DR_diskstat_oradata3 -gt 85 ]; then echo "WARNING: $DR_diskstat_oradata3_pr" >> $LOG elif [ $DR_diskstat_oradata3 -gt 95 ]; then echo "CRITICAL: $DR_diskstat_oradata3_pr" >> $LOG else echo "OKAY: $DR_diskstat_oradata3_pr" >> $LOG fi #Grep the Logfile for Alerts if grep 'CRITICAL' $LOG; then mail -a $LOG -s "CRITICAL: <PROD_SID>/<DR_SID> FILESYSTEM STATUS" $MAIL_LIST2 < $LOG fi if [ $sd -eq 8 ]; then mail -a $LOG -s "DAILY CHECK: <PROD_SID>/<DR_SID> FILESYSTEM STATUS" $MAIL_LIST1 < $LOG fi