diff options
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 7e2f6f99..998899b9 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -37,6 +37,8 @@ print_usage() { | |||
37 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" | 37 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" |
38 | echo " $PROGNAME --db <ORACLE_SID>" | 38 | echo " $PROGNAME --db <ORACLE_SID>" |
39 | echo " $PROGNAME --login <ORACLE_SID>" | 39 | echo " $PROGNAME --login <ORACLE_SID>" |
40 | echo " $PROGNAME --cache <USER> <PASS> <INST> <CRITICAL> <WARNING>" | ||
41 | echo " $PROGNAME --tablespace <USER> <PASS> <INST> <TABLESPACE> <CRITICAL> <WARNING>" | ||
40 | echo " $PROGNAME --oranames <Hostname>" | 42 | echo " $PROGNAME --oranames <Hostname>" |
41 | echo " $PROGNAME --help" | 43 | echo " $PROGNAME --help" |
42 | echo " $PROGNAME --version" | 44 | echo " $PROGNAME --version" |
@@ -56,6 +58,14 @@ print_help() { | |||
56 | echo " filesystem for sgadefORACLE_SID.dbf" | 58 | echo " filesystem for sgadefORACLE_SID.dbf" |
57 | echo "--login=SID" | 59 | echo "--login=SID" |
58 | echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" | 60 | echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" |
61 | echo "--cache" | ||
62 | echo " Check local database for library and buffer cache hit ratios" | ||
63 | echo " ---> Requires Oracle user/password and SID specified." | ||
64 | echo " ---> Requires select on v_$sysstat and v_$librarycache" | ||
65 | echo "--tablespace" | ||
66 | echo " Check local database for tablespace capacity in ORACLE_SID" | ||
67 | echo " ---> Requires Oracle user/password specified." | ||
68 | echo " ---> Requires select on dba_data_files and dba_free_space" | ||
59 | echo "--oranames=Hostname" | 69 | echo "--oranames=Hostname" |
60 | echo " Check remote Oracle Names server" | 70 | echo " Check remote Oracle Names server" |
61 | echo "--help" | 71 | echo "--help" |
@@ -191,6 +201,71 @@ case "$cmd" in | |||
191 | exit $STATE_CRITICAL | 201 | exit $STATE_CRITICAL |
192 | fi | 202 | fi |
193 | ;; | 203 | ;; |
204 | --cache) | ||
205 | if [ ${5} -gt ${6} ] ; then | ||
206 | echo "UNKNOWN - Warning level is less then Crit" | ||
207 | exit $STATE_UNKNOWN | ||
208 | fi | ||
209 | result=`sqlplus -s ${2}/${3}@${4} << EOF | ||
210 | set pagesize 0 | ||
211 | |||
212 | select (1-(pr.value/(dbg.value+cg.value)))*100 \ | ||
213 | from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg \ | ||
214 | where pr.name = 'physical reads' \ | ||
215 | and dbg.name='db block gets' \ | ||
216 | and cg.name='consistent gets'; ` | ||
217 | |||
218 | buf_hr=`echo $result | awk '{print int($1)}'` | ||
219 | result=`sqlplus -s ${2}/${3}@${4} << EOF | ||
220 | set pagesize 0 | ||
221 | |||
222 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 \ | ||
223 | from v\\$librarycache lc ; ` | ||
224 | |||
225 | lib_hr=`echo $result | awk '{print int($1)}'` | ||
226 | |||
227 | if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then | ||
228 | echo "${3} : ${4} CRITICAL - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff" | ||
229 | exit $STATE_CRITICAL | ||
230 | fi | ||
231 | if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then | ||
232 | echo "${3} : ${4} WARNING - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff" | ||
233 | exit $STATE_WARNING | ||
234 | fi | ||
235 | echo "${3} : ${4} OK - Cache Hit Rates: $lib_hr % Lib -- $buf_hr % Buff" | ||
236 | |||
237 | exit $STATE_OK | ||
238 | ;; | ||
239 | --tablespace) | ||
240 | if [ ${6} -lt ${7} ] ; then | ||
241 | echo "UNKNOWN - Warning level is more then Crit" | ||
242 | exit $STATE_UNKNOWN | ||
243 | fi | ||
244 | result=`sqlplus -s ${2}/${3}@${4} << EOF | ||
245 | set pagesize 0 | ||
246 | |||
247 | select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc \ | ||
248 | from ( \ | ||
249 | select tablespace_name,sum(bytes)/1024/1024 total \ | ||
250 | from dba_data_files group by tablespace_name) A, \ | ||
251 | ( select tablespace_name,sum(bytes)/1024/1024 free \ | ||
252 | from dba_Free_space group by tablespace_name) B \ | ||
253 | where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}'; ` | ||
254 | |||
255 | ts_free=`echo $result | awk '{print int($1)}'` | ||
256 | ts_total=`echo $result | awk '{print int($2)}'` | ||
257 | ts_pct=`echo $result | awk '{print int($3)}'` | ||
258 | if [ $ts_pct -ge ${6} ] ; then | ||
259 | echo "${4} : ${5} CRITICAL - $ts_pct% used [ $ts_free / $ts_total MB available ]" | ||
260 | exit $STATE_CRITICAL | ||
261 | fi | ||
262 | if [ $ts_pct -ge ${7} ] ; then | ||
263 | echo "${4} : ${5} WARNING - $ts_pct% used [ $ts_free / $ts_total MB available ]" | ||
264 | exit $STATE_WARNING | ||
265 | fi | ||
266 | echo "${4} : ${5} OK - $ts_pct% used [ $ts_free / $ts_total MB available ]" | ||
267 | exit $STATE_OK | ||
268 | ;; | ||
194 | *) | 269 | *) |
195 | print_usage | 270 | print_usage |
196 | exit $STATE_UNKNOWN | 271 | exit $STATE_UNKNOWN |