diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-11-05 22:28:35 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-11-05 22:32:48 +0100 |
commit | ec913afbdad7c2f726dbfdb9aa3a7285fea2774d (patch) | |
tree | 894218ea9f213a58d1adda3a0a1fdc6febc7fe97 /plugins-scripts/check_oracle.sh | |
parent | 6131659fe307fcbe16beb028c2e4d1c877646f13 (diff) | |
download | monitoring-plugins-ec913af.tar.gz |
Shellcheck fixes for check_oracle
Diffstat (limited to 'plugins-scripts/check_oracle.sh')
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 59981386..db824bef 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -47,7 +47,7 @@ print_help() { | |||
47 | echo "--cache" | 47 | echo "--cache" |
48 | echo " Check local database for library and buffer cache hit ratios" | 48 | echo " Check local database for library and buffer cache hit ratios" |
49 | echo " ---> Requires Oracle user/password and SID specified." | 49 | echo " ---> Requires Oracle user/password and SID specified." |
50 | echo " ---> Requires select on v_$sysstat and v_$librarycache" | 50 | echo " ---> Requires select on v_\$sysstat and v_\$librarycache" |
51 | echo "--tablespace" | 51 | echo "--tablespace" |
52 | echo " Check local database for tablespace capacity in ORACLE_SID" | 52 | echo " Check local database for tablespace capacity in ORACLE_SID" |
53 | echo " ---> Requires Oracle user/password specified." | 53 | echo " ---> Requires Oracle user/password specified." |
@@ -109,14 +109,14 @@ if [ -z "$ORACLE_HOME" ] ; then | |||
109 | for oratab in /var/opt/oracle/oratab /etc/oratab | 109 | for oratab in /var/opt/oracle/oratab /etc/oratab |
110 | do | 110 | do |
111 | [ ! -f $oratab ] && continue | 111 | [ ! -f $oratab ] && continue |
112 | ORACLE_HOME=`IFS=: | 112 | ORACLE_HOME=$(IFS=: |
113 | while read -r SID ORACLE_HOME junk; | 113 | while read -r SID ORACLE_HOME _; |
114 | do | 114 | do |
115 | if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then | 115 | if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then |
116 | echo "$ORACLE_HOME"; | 116 | echo "$ORACLE_HOME"; |
117 | exit; | 117 | exit; |
118 | fi; | 118 | fi; |
119 | done < $oratab` | 119 | done < $oratab) |
120 | [ -n "$ORACLE_HOME" ] && break | 120 | [ -n "$ORACLE_HOME" ] && break |
121 | done | 121 | done |
122 | fi | 122 | fi |
@@ -209,7 +209,7 @@ case "$cmd" in | |||
209 | echo "UNKNOWN - Warning level is less then Crit" | 209 | echo "UNKNOWN - Warning level is less then Crit" |
210 | exit "$STATE_UNKNOWN" | 210 | exit "$STATE_UNKNOWN" |
211 | fi | 211 | fi |
212 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF | 212 | result=$(sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
213 | set pagesize 0 | 213 | set pagesize 0 |
214 | set numf '9999999.99' | 214 | set numf '9999999.99' |
215 | select (1-(pr.value/(dbg.value+cg.value)))*100 | 215 | select (1-(pr.value/(dbg.value+cg.value)))*100 |
@@ -217,7 +217,8 @@ from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg | |||
217 | where pr.name='physical reads' | 217 | where pr.name='physical reads' |
218 | and dbg.name='db block gets' | 218 | 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 | ||
222 | if echo "$result" | grep -q 'ORA-' ; then | 223 | if echo "$result" | grep -q 'ORA-' ; then |
223 | error=$(echo "$result" | grep "ORA-" | head -1) | 224 | error=$(echo "$result" | grep "ORA-" | head -1) |
@@ -227,12 +228,13 @@ EOF` | |||
227 | 228 | ||
228 | buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}') | 229 | buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}') |
229 | buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}') | 230 | buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}') |
230 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF | 231 | result=$(sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
231 | set pagesize 0 | 232 | set pagesize 0 |
232 | set numf '9999999.99' | 233 | set numf '9999999.99' |
233 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 | 234 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 |
234 | from v\\$librarycache lc; | 235 | from v\\$librarycache lc; |
235 | EOF` | 236 | EOF |
237 | ) | ||
236 | 238 | ||
237 | if echo "$result" | grep -q 'ORA-' ; then | 239 | if echo "$result" | grep -q 'ORA-' ; then |
238 | error=$(echo "$result" | grep "ORA-" | head -1) | 240 | error=$(echo "$result" | grep "ORA-" | head -1) |
@@ -260,7 +262,7 @@ EOF` | |||
260 | echo "UNKNOWN - Warning level is more then Crit" | 262 | echo "UNKNOWN - Warning level is more then Crit" |
261 | exit "$STATE_UNKNOWN" | 263 | exit "$STATE_UNKNOWN" |
262 | fi | 264 | fi |
263 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF | 265 | result=$(sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
264 | set pagesize 0 | 266 | set pagesize 0 |
265 | set numf '9999999.99' | 267 | set numf '9999999.99' |
266 | select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc | 268 | select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc |
@@ -271,7 +273,8 @@ LEFT OUTER JOIN | |||
271 | ( select tablespace_name,sum(bytes)/1024/1024 free | 273 | ( select tablespace_name,sum(bytes)/1024/1024 free |
272 | from dba_free_space group by tablespace_name) B | 274 | from dba_free_space group by tablespace_name) B |
273 | ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; | 275 | ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; |
274 | EOF` | 276 | EOF |
277 | ) | ||
275 | 278 | ||
276 | if echo "$result" | grep -q 'ORA-' ; then | 279 | if echo "$result" | grep -q 'ORA-' ; then |
277 | error=$(echo "$result" | grep "ORA-" | head -1) | 280 | error=$(echo "$result" | grep "ORA-" | head -1) |