It's good to be forewarned when one of your volumes or diskspace is running low before it actually runs out (100% used). I have seen many databases hang when any one of the volumes fills up for what ever reason. This script runs continuously in the background and checks for available disks space based on a threshold limit you set in the script.
Your system administrator will have their own method, but as the DBA you may want to know in advance of the system administrator and not have access to their tools.
First off I would like to thank Andy Denslow for the original check_diskspace code. I have made some modifications over time.
There are two scripts: run_check_diskspace.sh and check_diskspace.sh.
run_check_diskspace.sh is executed in the backgroup and every 30 minutes will call check_diskspace.sh.
check_diskspace.sh will perform the df -k command and if the threshold is met or passed will send you an email.
You can edit the sleep parameter to the disired time interval you wish to check. 1800 secs = 30 minutes.
Run in cron may be more desired.
First run_check_diskspace.sh
# ------------------------------------
# run_check_diskspace.sh
# ------------------------------------
#!/usr/bin/sh
x=0
while [ x -lt 1 ] ; do
/u01/app/oracle/scripts/monitor/check_diskspace.sh
sleep 1800
done
Now for check_diskspace.sh
# ------------------------------------
# check_diskspace.sh
# ------------------------------------
#!/bin/sh
############################
# This script is used to check the disk
# space of local filesystems and send
# alerts when the threshhold has been reached
#
# Original Base Code: Andy Denslow 1995
# Updated: Howard Hackworth 2004
############################
# -- At what point do we send page?
PAGELIMIT=95
# -- At what point do we send email warning of low diskspace?
LIMIT=85
## -- Uncomment the following one line for use with pager
# PAGER='1234567@somelocation.net'
# -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# -- Who do I send email to?
MAIL='howard_hackworth@sgxpharma.com'
TEMP=/tmp/diskspace.tmp
df -kl | sed "s/%/ /g" | sed "/Filesystem/d" | sed "/cdrom/d" >$TEMP
cat $TEMP while read LINE
do
SIZE=`echo $LINE | awk '{print $5}'`
if [ "$SIZE" -gt $LIMIT ]; then
SYSTEM=`echo $LINE | awk '{print $6}'`
echo "DISKSPACE WARNING *** `hostname`: $SYSTEM is $SIZE% full" | /usr/bin/mailx -s \
"Diskspace Warning `hostname`: $SYSTEM is $SIZE% full" $MAIL
elif [ "$SIZE" -gt "$PAGELIMIT" ]; then
## -- Uncomment for use with a pager instead of email:
## --
# echo "DISKSPACE CRITICAL *** `hostname`: $SYSTEM is $SIZE% full" | /usr/bin/mailx -s # "CRITICAL Diskspace ALERT! `hostname`: $SYSTEM is $SIZE% full" $PAGER
##
echo "`hostname`:$SYSTEM is $SIZE% full" | /usr/bin/mailx -s \
"CRITICAL Diskspace ALERT! `hostname`: $SYSTEM is $SIZE% full" $MAIL
fi
done
rm $TEMP
# -- end check_diskspace.sh
# ----------------------------
To execute run from the command line the following command:
/scripts/monitor% ./run_check_diskspace.sh &
I also include this in my dbora script as follows:
su - $ORA_OWNER -c nohup /u01/app/oracle/scripts/monitor/run_check_diskspace.sh &
This is an example of the email you will receive when the disk threshold is reached.
Subject: Diskspace Warning hostname.yourdomain.com: /u02 is 91% full
DISKSPACE WARNING *** hostname.yourdomain.com: /u02 is 91% full
Remember your dreams
Subscribe to:
Post Comments (Atom)
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...
-
Oracle 12.1.0.2.0 RMAN-04006: error from auxiliary database: ORA-12514: TNS:listener does not currently know of service requested i...
-
How to get Oracle's runInstaller to run on Linux or Unix environment using from Windows using Cygwin as an xterm emulator. Download an...
-
A great security measure is to monitor who is trying to unsuccessfully log into your database. Whether it's an innocent developer who fo...
No comments:
Post a Comment