summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_oracle.sh
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-11-05 22:28:35 +0100
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-11-05 22:32:48 +0100
commitec913afbdad7c2f726dbfdb9aa3a7285fea2774d (patch)
tree894218ea9f213a58d1adda3a0a1fdc6febc7fe97 /plugins-scripts/check_oracle.sh
parent6131659fe307fcbe16beb028c2e4d1c877646f13 (diff)
downloadmonitoring-plugins-ec913af.tar.gz
Shellcheck fixes for check_oracle
Diffstat (limited to 'plugins-scripts/check_oracle.sh')
-rwxr-xr-xplugins-scripts/check_oracle.sh23
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
122fi 122fi
@@ -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
213set pagesize 0 213set pagesize 0
214set numf '9999999.99' 214set numf '9999999.99'
215select (1-(pr.value/(dbg.value+cg.value)))*100 215select (1-(pr.value/(dbg.value+cg.value)))*100
@@ -217,7 +217,8 @@ from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg
217where pr.name='physical reads' 217where pr.name='physical reads'
218and dbg.name='db block gets' 218and dbg.name='db block gets'
219and cg.name='consistent gets'; 219and cg.name='consistent gets';
220EOF` 220EOF
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
231set pagesize 0 232set pagesize 0
232set numf '9999999.99' 233set numf '9999999.99'
233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 234select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
234from v\\$librarycache lc; 235from v\\$librarycache lc;
235EOF` 236EOF
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
264set pagesize 0 266set pagesize 0
265set numf '9999999.99' 267set numf '9999999.99'
266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc 268select 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
272from dba_free_space group by tablespace_name) B 274from dba_free_space group by tablespace_name) B
273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; 275ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
274EOF` 276EOF
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)