summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplugins-scripts/check_oracle.sh70
1 files changed, 37 insertions, 33 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index 3064db90..1de8fa07 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -31,8 +31,8 @@ print_usage() {
31 echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" 31 echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>"
32 echo " $PROGNAME --db <ORACLE_SID>" 32 echo " $PROGNAME --db <ORACLE_SID>"
33 echo " $PROGNAME --login <ORACLE_SID>" 33 echo " $PROGNAME --login <ORACLE_SID>"
34 echo " $PROGNAME --cache <USER> <PASS> <INST> <CRITICAL> <WARNING>" 34 echo " $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>"
35 echo " $PROGNAME --tablespace <USER> <PASS> <INST> <TABLESPACE> <CRITICAL> <WARNING>" 35 echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>"
36 echo " $PROGNAME --oranames <Hostname>" 36 echo " $PROGNAME --oranames <Hostname>"
37 echo " $PROGNAME --help" 37 echo " $PROGNAME --help"
38 echo " $PROGNAME --version" 38 echo " $PROGNAME --version"
@@ -48,13 +48,13 @@ print_help() {
48 echo "--tns=SID/IP Address" 48 echo "--tns=SID/IP Address"
49 echo " Check remote TNS server" 49 echo " Check remote TNS server"
50 echo "--db=SID" 50 echo "--db=SID"
51 echo " Check local database (search /bin/ps for PMON process and check" 51 echo " Check local database (search /bin/ps for PMON process) and check"
52 echo " filesystem for sgadefORACLE_SID.dbf" 52 echo " filesystem for sgadefORACLE_SID.dbf"
53 echo "--login=SID" 53 echo "--login=SID"
54 echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" 54 echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password"
55 echo "--cache" 55 echo "--cache"
56 echo " Check local database for library and buffer cache hit ratios" 56 echo " Check local database for library and buffer cache hit ratios"
57 echo " ---> Requires Oracle user/password and SID specified." 57 echo " ---> Requires Oracle user/password and SID specified."
58 echo " ---> Requires select on v_$sysstat and v_$librarycache" 58 echo " ---> Requires select on v_$sysstat and v_$librarycache"
59 echo "--tablespace" 59 echo "--tablespace"
60 echo " Check local database for tablespace capacity in ORACLE_SID" 60 echo " Check local database for tablespace capacity in ORACLE_SID"
@@ -203,33 +203,33 @@ case "$cmd" in
203 echo "UNKNOWN - Warning level is less then Crit" 203 echo "UNKNOWN - Warning level is less then Crit"
204 exit $STATE_UNKNOWN 204 exit $STATE_UNKNOWN
205 fi 205 fi
206 result=`sqlplus -s ${2}/${3}@${4} << EOF 206 result=`sqlplus -s ${3}/${4}@${2} << EOF
207 set pagesize 0 207set pagesize 0
208 208select (1-(pr.value/(dbg.value+cg.value)))*100
209select (1-(pr.value/(dbg.value+cg.value)))*100 \ 209from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg
210from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg \ 210where pr.name='physical reads'
211where pr.name = 'physical reads' \ 211and dbg.name='db block gets'
212 and dbg.name='db block gets' \ 212and cg.name='consistent gets';
213 and cg.name='consistent gets'; ` 213EOF`
214 214
215 buf_hr=`echo $result | awk '{print int($1)}'` 215 buf_hr=`echo $result | awk '{print int($1)}'`
216 result=`sqlplus -s ${2}/${3}@${4} << EOF 216 result=`sqlplus -s ${3}/${4}@${2} << EOF
217 set pagesize 0 217set pagesize 0
218 218select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
219select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 \ 219from v\\$librarycache lc;
220from v\\$librarycache lc ; ` 220EOF`
221 221
222 lib_hr=`echo $result | awk '{print int($1)}'` 222 lib_hr=`echo $result | awk '{print int($1)}'`
223 223
224 if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then 224 if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then
225 echo "${3} : ${4} CRITICAL - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff" 225 echo "${4} : ${2} CRITICAL - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff"
226 exit $STATE_CRITICAL 226 exit $STATE_CRITICAL
227 fi 227 fi
228 if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then 228 if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then
229 echo "${3} : ${4} WARNING - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff" 229 echo "${4} : ${2} WARNING - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff"
230 exit $STATE_WARNING 230 exit $STATE_WARNING
231 fi 231 fi
232 echo "${3} : ${4} OK - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff" 232 echo "${4} : ${2} OK - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff"
233 233
234 exit $STATE_OK 234 exit $STATE_OK
235 ;; 235 ;;
@@ -238,29 +238,33 @@ from v\\$librarycache lc ; `
238 echo "UNKNOWN - Warning level is more then Crit" 238 echo "UNKNOWN - Warning level is more then Crit"
239 exit $STATE_UNKNOWN 239 exit $STATE_UNKNOWN
240 fi 240 fi
241 result=`sqlplus -s ${2}/${3}@${4} << EOF 241 result=`sqlplus -s ${3}/${4}@${2} << EOF
242 set pagesize 0 242set pagesize 0
243 243select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc
244select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc \ 244from (
245from ( \ 245select tablespace_name,sum(bytes)/1024/1024 total
246select tablespace_name,sum(bytes)/1024/1024 total \ 246from dba_data_files group by tablespace_name) A,
247from dba_data_files group by tablespace_name) A, \ 247( select tablespace_name,sum(bytes)/1024/1024 free
248( select tablespace_name,sum(bytes)/1024/1024 free \ 248from dba_free_space group by tablespace_name) B
249from dba_Free_space group by tablespace_name) B \ 249where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}';
250where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}'; ` 250EOF`
251 251
252 ts_free=`echo $result | awk '{print int($1)}'` 252 ts_free=`echo $result | awk '{print int($1)}'`
253 ts_total=`echo $result | awk '{print int($2)}'` 253 ts_total=`echo $result | awk '{print int($2)}'`
254 ts_pct=`echo $result | awk '{print int($3)}'` 254 ts_pct=`echo $result | awk '{print int($3)}'`
255 if [ $ts_free -eq 0 -a $ts_total -eq 0 -a $ts_pct -eq 0 ] ; then
256 echo "No data returned by Oracle - tablespace $5 not found?"
257 exit $STATE_UNKNOWN
258 fi
255 if [ $ts_pct -ge ${6} ] ; then 259 if [ $ts_pct -ge ${6} ] ; then
256 echo "${4} : ${5} CRITICAL - $ts_pct% used [ $ts_free / $ts_total MB available ]" 260 echo "${2} : ${5} CRITICAL - $ts_pct% used [ $ts_free / $ts_total MB available ]"
257 exit $STATE_CRITICAL 261 exit $STATE_CRITICAL
258 fi 262 fi
259 if [ $ts_pct -ge ${7} ] ; then 263 if [ $ts_pct -ge ${7} ] ; then
260 echo "${4} : ${5} WARNING - $ts_pct% used [ $ts_free / $ts_total MB available ]" 264 echo "${2} : ${5} WARNING - $ts_pct% used [ $ts_free / $ts_total MB available ]"
261 exit $STATE_WARNING 265 exit $STATE_WARNING
262 fi 266 fi
263 echo "${4} : ${5} OK - $ts_pct% used [ $ts_free / $ts_total MB available ]" 267 echo "${2} : ${5} OK - $ts_pct% used [ $ts_free / $ts_total MB available ]"
264 exit $STATE_OK 268 exit $STATE_OK
265 ;; 269 ;;
266*) 270*)