diff options
Diffstat (limited to 'plugins-scripts/check_oracle.sh')
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 96078ac..d4d3aae 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -8,8 +8,8 @@ | |||
8 | 8 | ||
9 | PATH="@TRUSTED_PATH@" | 9 | PATH="@TRUSTED_PATH@" |
10 | export PATH | 10 | export PATH |
11 | PROGNAME=`basename $0` | 11 | PROGNAME=$(basename $0) |
12 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 12 | PROGPATH=$(echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
13 | REVISION="@NP_VERSION@" | 13 | REVISION="@NP_VERSION@" |
14 | 14 | ||
15 | . $PROGPATH/utils.sh | 15 | . $PROGPATH/utils.sh |
@@ -135,8 +135,8 @@ export ORACLE_HOME PATH LD_LIBRARY_PATH | |||
135 | 135 | ||
136 | case "$cmd" in | 136 | case "$cmd" in |
137 | --tns) | 137 | --tns) |
138 | tnschk=` tnsping $2` | 138 | tnschk=$(tnsping $2) |
139 | tnschk2=` echo $tnschk | grep -c OK` | 139 | tnschk2=$(echo $tnschk | grep -c OK) |
140 | if [ ${tnschk2} -eq 1 ] ; then | 140 | if [ ${tnschk2} -eq 1 ] ; then |
141 | tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} | 141 | tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} |
142 | echo "OK - reply time ${tnschk3} from $2" | 142 | echo "OK - reply time ${tnschk3} from $2" |
@@ -165,7 +165,7 @@ case "$cmd" in | |||
165 | }' | 165 | }' |
166 | ;; | 166 | ;; |
167 | --db) | 167 | --db) |
168 | pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"` | 168 | pmonchk=$(ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$") |
169 | if [ ${pmonchk} -ge 1 ] ; then | 169 | if [ ${pmonchk} -ge 1 ] ; then |
170 | echo "${2} OK - ${pmonchk} PMON process(es) running" | 170 | echo "${2} OK - ${pmonchk} PMON process(es) running" |
171 | exit $STATE_OK | 171 | exit $STATE_OK |
@@ -181,25 +181,25 @@ case "$cmd" in | |||
181 | fi | 181 | fi |
182 | ;; | 182 | ;; |
183 | --login) | 183 | --login) |
184 | loginchk=`sqlplus dummy/user@$2 < /dev/null` | 184 | loginchk=$(sqlplus dummy/user@$2 < /dev/null) |
185 | loginchk2=` echo $loginchk | grep -c ORA-01017` | 185 | loginchk2=$(echo $loginchk | grep -c ORA-01017) |
186 | if [ ${loginchk2} -eq 1 ] ; then | 186 | if [ ${loginchk2} -eq 1 ] ; then |
187 | echo "OK - dummy login connected" | 187 | echo "OK - dummy login connected" |
188 | exit $STATE_OK | 188 | exit $STATE_OK |
189 | else | 189 | else |
190 | loginchk3=` echo "$loginchk" | grep "ORA-" | head -1` | 190 | loginchk3=$(echo "$loginchk" | grep "ORA-" | head -1) |
191 | echo "CRITICAL - $loginchk3" | 191 | echo "CRITICAL - $loginchk3" |
192 | exit $STATE_CRITICAL | 192 | exit $STATE_CRITICAL |
193 | fi | 193 | fi |
194 | ;; | 194 | ;; |
195 | --connect) | 195 | --connect) |
196 | connectchk=`sqlplus $2 < /dev/null` | 196 | connectchk=$(sqlplus $2 < /dev/null) |
197 | connectchk2=` echo $connectchk | grep -c ORA-` | 197 | connectchk2=$(echo $connectchk | grep -c ORA-) |
198 | if [ ${connectchk2} -eq 0 ] ; then | 198 | if [ ${connectchk2} -eq 0 ] ; then |
199 | echo "OK - login successful" | 199 | echo "OK - login successful" |
200 | exit $STATE_OK | 200 | exit $STATE_OK |
201 | else | 201 | else |
202 | connectchk3=` echo "$connectchk" | grep "ORA-" | head -1` | 202 | connectchk3=$(echo "$connectchk" | grep "ORA-" | head -1) |
203 | echo "CRITICAL - $connectchk3" | 203 | echo "CRITICAL - $connectchk3" |
204 | exit $STATE_CRITICAL | 204 | exit $STATE_CRITICAL |
205 | fi | 205 | fi |
@@ -219,29 +219,29 @@ and dbg.name='db block gets' | |||
219 | and cg.name='consistent gets'; | 219 | and cg.name='consistent gets'; |
220 | EOF` | 220 | EOF` |
221 | 221 | ||
222 | if [ -n "`echo $result | grep ORA-`" ] ; then | 222 | if [ -n "$(echo $result | grep ORA-)" ] ; then |
223 | error=` echo "$result" | grep "ORA-" | head -1` | 223 | error=$(echo "$result" | grep "ORA-" | head -1) |
224 | echo "CRITICAL - $error" | 224 | echo "CRITICAL - $error" |
225 | exit $STATE_CRITICAL | 225 | exit $STATE_CRITICAL |
226 | fi | 226 | fi |
227 | 227 | ||
228 | buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` | 228 | buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}') |
229 | buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` | 229 | buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}') |
230 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 230 | result=`sqlplus -s ${3}/${4}@${2} << EOF |
231 | set pagesize 0 | 231 | set pagesize 0 |
232 | set numf '9999999.99' | 232 | set numf '9999999.99' |
233 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 | 233 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 |
234 | from v\\$librarycache lc; | 234 | from v\\$librarycache lc; |
235 | EOF` | 235 | EOF` |
236 | 236 | ||
237 | if [ -n "`echo $result | grep ORA-`" ] ; then | 237 | if [ -n "$(echo $result | grep ORA-)" ] ; then |
238 | error=` echo "$result" | grep "ORA-" | head -1` | 238 | error=$(echo "$result" | grep "ORA-" | head -1) |
239 | echo "CRITICAL - $error" | 239 | echo "CRITICAL - $error" |
240 | exit $STATE_CRITICAL | 240 | exit $STATE_CRITICAL |
241 | fi | 241 | fi |
242 | 242 | ||
243 | lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` | 243 | lib_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}') |
244 | lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` | 244 | lib_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}') |
245 | 245 | ||
246 | if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then | 246 | if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then |
247 | echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" | 247 | echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" |
@@ -273,16 +273,16 @@ from dba_free_space group by tablespace_name) B | |||
273 | ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; | 273 | ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; |
274 | EOF` | 274 | EOF` |
275 | 275 | ||
276 | if [ -n "`echo $result | grep ORA-`" ] ; then | 276 | if [ -n "$(echo $result | grep ORA-)" ] ; then |
277 | error=` echo "$result" | grep "ORA-" | head -1` | 277 | error=$(echo "$result" | grep "ORA-" | head -1) |
278 | echo "CRITICAL - $error" | 278 | echo "CRITICAL - $error" |
279 | exit $STATE_CRITICAL | 279 | exit $STATE_CRITICAL |
280 | fi | 280 | fi |
281 | 281 | ||
282 | ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` | 282 | ts_free=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}') |
283 | ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` | 283 | ts_total=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}') |
284 | ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` | 284 | ts_pct=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}') |
285 | ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` | 285 | ts_pctx=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}') |
286 | if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then | 286 | if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then |
287 | echo "No data returned by Oracle - tablespace $5 not found?" | 287 | echo "No data returned by Oracle - tablespace $5 not found?" |
288 | exit $STATE_UNKNOWN | 288 | exit $STATE_UNKNOWN |