Question : oracle shell script

I have a shell script that checks table spaces sizes and the returns the output for monitoring in Nagios. It also uses auto extend. Problem is is that it times out when it does its calculations. I dont know oracle well, so i was wondering if someone who knows oracle could look at this script and tell me if there is a way to return the results of the check faster. The code is attached

Thanks,

Answer : oracle shell script

I will try to be more clear and give you a working example.
I hope you know how to add new alarms in Nagios.

Example how to monitor system tablespace with Nagios.
Create a script who will be runned from root's or the db-owners crontab.
I'll use root in my example.

In this case I will fetch size of TS SYSTEM, SYSAUX, INDX etc and spool it to a file.
Later on Nagios will look in this file.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
#!/bin/sh
BULK=`/opt/dbname/oracle/product/10.2.0/bin/sqlplus -s dbuser/dbpasswd < /dev/null 2>&1
 
Create a Nagios-script /opt/nrpe/libexec
#!/bin/sh
#SYSTEM
#Program is runned via nagios
 
CH_DATE=`ls -l /tmp/ts_size.lst|awk '{print $6,$7,$8}'`
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
ECHO=`which echo`
EXPR=`which expr`
AWK=`which awk`
CAT=`which cat`
GREP=`which grep`
LOGFILE="/tmp/ts_size.lst"
MIN_SIZE=1000 #1Gb
TS="SYSTEM"
 
SIZE=`$CAT $LOGFILE|$GREP $TS|$AWK '{print $2}'`
 
if [ "$SIZE" -lt "$MIN_SIZE" ]
then 
        $ECHO "TABLESPACE TO SMALL: $SIZE MB ,$CH_DATE"
        exit $STATE_WARNING
else 
        $ECHO "FILESIZE OK: $SIZE MB ,$CH_DATE"
        exit $STATE_OK
fi 
#eof
 
Add the new alarm in Nagios.
Nagios will give you a warning when tablespace has less than ~1Gb left.
In Nagios you will also see when the last check was done "$CH_DATE"
 
Regards.
Open in New Window Select All
Random Solutions  
 
programming4us programming4us