Code

check_oracle does not need a valid ORACLE_HOME if called with --db. Thanks to Jason...
[nagiosplug.git] / plugins-scripts / check_oracle.sh
index 99564917a9831950e9b0161e35f806ab43885f76..56962e37ccc0093b29d0aea68eb45e63fde51145 100755 (executable)
@@ -118,9 +118,11 @@ fi
 # Last resort
 [ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle
 
-if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then
-       echo "Cannot determine ORACLE_HOME for sid $2"
-       exit $STATE_UNKNOWN
+if [ "$cmd" != "--db" ]; then
+       if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then
+               echo "Cannot determine ORACLE_HOME for sid $2"
+               exit $STATE_UNKNOWN
+       fi
 fi
 PATH=$PATH:$ORACLE_HOME/bin
 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
@@ -244,13 +246,14 @@ EOF`
     result=`sqlplus -s ${3}/${4}@${2} << EOF
 set pagesize 0
 set numf '9999999.99'
-select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc
+select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
 from (
 select tablespace_name,sum(bytes)/1024/1024 total
-from dba_data_files group by tablespace_name) A,
+from dba_data_files group by tablespace_name) A
+LEFT OUTER JOIN
 ( select tablespace_name,sum(bytes)/1024/1024 free
 from dba_free_space group by tablespace_name) B
-where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}';
+ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
 EOF`
 
     if [ -n "`echo $result | grep ORA-`" ] ; then