diff options
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 8542555..41e9dce 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -192,6 +192,7 @@ case "$cmd" in | |||
192 | fi | 192 | fi |
193 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 193 | result=`sqlplus -s ${3}/${4}@${2} << EOF |
194 | set pagesize 0 | 194 | set pagesize 0 |
195 | set numf '9999999.99' | ||
195 | select (1-(pr.value/(dbg.value+cg.value)))*100 | 196 | select (1-(pr.value/(dbg.value+cg.value)))*100 |
196 | from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg | 197 | from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg |
197 | where pr.name='physical reads' | 198 | where pr.name='physical reads' |
@@ -205,9 +206,10 @@ EOF` | |||
205 | exit $STATE_CRITICAL | 206 | exit $STATE_CRITICAL |
206 | fi | 207 | fi |
207 | 208 | ||
208 | buf_hr=`echo $result | awk '{print int($1)}'` | 209 | buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` |
209 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 210 | result=`sqlplus -s ${3}/${4}@${2} << EOF |
210 | set pagesize 0 | 211 | set pagesize 0 |
212 | set numf '9999999.99' | ||
211 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 | 213 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 |
212 | from v\\$librarycache lc; | 214 | from v\\$librarycache lc; |
213 | EOF` | 215 | EOF` |
@@ -218,7 +220,7 @@ EOF` | |||
218 | exit $STATE_CRITICAL | 220 | exit $STATE_CRITICAL |
219 | fi | 221 | fi |
220 | 222 | ||
221 | lib_hr=`echo $result | awk '{print int($1)}'` | 223 | lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` |
222 | 224 | ||
223 | if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then | 225 | if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then |
224 | echo "${2} CRITICAL - Cache Hit Rates: $lib_hr% Lib -- $buf_hr% Buff" | 226 | echo "${2} CRITICAL - Cache Hit Rates: $lib_hr% Lib -- $buf_hr% Buff" |
@@ -239,6 +241,7 @@ EOF` | |||
239 | fi | 241 | fi |
240 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 242 | result=`sqlplus -s ${3}/${4}@${2} << EOF |
241 | set pagesize 0 | 243 | set pagesize 0 |
244 | set numf '9999999.99' | ||
242 | select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc | 245 | select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc |
243 | from ( | 246 | from ( |
244 | select tablespace_name,sum(bytes)/1024/1024 total | 247 | select tablespace_name,sum(bytes)/1024/1024 total |
@@ -254,18 +257,18 @@ EOF` | |||
254 | exit $STATE_CRITICAL | 257 | exit $STATE_CRITICAL |
255 | fi | 258 | fi |
256 | 259 | ||
257 | ts_free=`echo $result | awk '{print int($1)}'` | 260 | ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` |
258 | ts_total=`echo $result | awk '{print int($2)}'` | 261 | ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` |
259 | ts_pct=`echo $result | awk '{print int($3)}'` | 262 | ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` |
260 | if [ $ts_free -eq 0 -a $ts_total -eq 0 -a $ts_pct -eq 0 ] ; then | 263 | if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then |
261 | echo "No data returned by Oracle - tablespace $5 not found?" | 264 | echo "No data returned by Oracle - tablespace $5 not found?" |
262 | exit $STATE_UNKNOWN | 265 | exit $STATE_UNKNOWN |
263 | fi | 266 | fi |
264 | if [ $ts_pct -ge ${6} ] ; then | 267 | if [ "$ts_pct" -ge ${6} ] ; then |
265 | echo "${2} : ${5} CRITICAL - $ts_pct% used [ $ts_free / $ts_total MB available ]" | 268 | echo "${2} : ${5} CRITICAL - $ts_pct% used [ $ts_free / $ts_total MB available ]" |
266 | exit $STATE_CRITICAL | 269 | exit $STATE_CRITICAL |
267 | fi | 270 | fi |
268 | if [ $ts_pct -ge ${7} ] ; then | 271 | if [ "$ts_pct" -ge ${7} ] ; then |
269 | echo "${2} : ${5} WARNING - $ts_pct% used [ $ts_free / $ts_total MB available ]" | 272 | echo "${2} : ${5} WARNING - $ts_pct% used [ $ts_free / $ts_total MB available ]" |
270 | exit $STATE_WARNING | 273 | exit $STATE_WARNING |
271 | fi | 274 | fi |