diff options
author | Jan Wagner <waja@cyconet.org> | 2017-01-06 16:43:22 (GMT) |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2017-01-06 16:43:22 (GMT) |
commit | 5f3232f00d07dac166b48acd6d0c92ec1ff64901 (patch) | |
tree | e497009ea444f6dabd021ad127b1500d3a8e4dff | |
parent | 439b93049ddcfa28d7d3b8dd8085770c613aabc3 (diff) | |
download | monitoring-plugins-5f3232f00d07dac166b48acd6d0c92ec1ff64901.tar.gz |
Fixing shellcheck SC2086
-rwxr-xr-x | plugins-scripts/check_log.sh | 54 | ||||
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 206 | ||||
-rwxr-xr-x | plugins-scripts/check_sensors.sh | 30 |
3 files changed, 145 insertions, 145 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index 4599268..8f76b1b 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
@@ -60,11 +60,11 @@ | |||
60 | 60 | ||
61 | PATH="@TRUSTED_PATH@" | 61 | PATH="@TRUSTED_PATH@" |
62 | export PATH | 62 | export PATH |
63 | PROGNAME=$(basename $0) | 63 | PROGNAME=$(basename "$0") |
64 | PROGPATH=$(echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,') | 64 | PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
65 | REVISION="@NP_VERSION@" | 65 | REVISION="@NP_VERSION@" |
66 | 66 | ||
67 | . $PROGPATH/utils.sh | 67 | . "$PROGPATH"/utils.sh |
68 | 68 | ||
69 | print_usage() { | 69 | print_usage() { |
70 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" | 70 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" |
@@ -73,7 +73,7 @@ print_usage() { | |||
73 | } | 73 | } |
74 | 74 | ||
75 | print_help() { | 75 | print_help() { |
76 | print_revision $PROGNAME $REVISION | 76 | print_revision "$PROGNAME" "$REVISION" |
77 | echo "" | 77 | echo "" |
78 | print_usage | 78 | print_usage |
79 | echo "" | 79 | echo "" |
@@ -87,7 +87,7 @@ print_help() { | |||
87 | 87 | ||
88 | if [ $# -lt 1 ]; then | 88 | if [ $# -lt 1 ]; then |
89 | print_usage | 89 | print_usage |
90 | exit $STATE_UNKNOWN | 90 | exit "$STATE_UNKNOWN" |
91 | fi | 91 | fi |
92 | 92 | ||
93 | # Grab the command line arguments | 93 | # Grab the command line arguments |
@@ -100,19 +100,19 @@ while test -n "$1"; do | |||
100 | case "$1" in | 100 | case "$1" in |
101 | --help) | 101 | --help) |
102 | print_help | 102 | print_help |
103 | exit $STATE_OK | 103 | exit "$STATE_OK" |
104 | ;; | 104 | ;; |
105 | -h) | 105 | -h) |
106 | print_help | 106 | print_help |
107 | exit $STATE_OK | 107 | exit "$STATE_OK" |
108 | ;; | 108 | ;; |
109 | --version) | 109 | --version) |
110 | print_revision $PROGNAME $REVISION | 110 | print_revision "$PROGNAME" "$REVISION" |
111 | exit $STATE_OK | 111 | exit "$STATE_OK" |
112 | ;; | 112 | ;; |
113 | -V) | 113 | -V) |
114 | print_revision $PROGNAME $REVISION | 114 | print_revision "$PROGNAME" "$REVISION" |
115 | exit $STATE_OK | 115 | exit "$STATE_OK" |
116 | ;; | 116 | ;; |
117 | --filename) | 117 | --filename) |
118 | logfile=$2 | 118 | logfile=$2 |
@@ -149,7 +149,7 @@ while test -n "$1"; do | |||
149 | *) | 149 | *) |
150 | echo "Unknown argument: $1" | 150 | echo "Unknown argument: $1" |
151 | print_usage | 151 | print_usage |
152 | exit $STATE_UNKNOWN | 152 | exit "$STATE_UNKNOWN" |
153 | ;; | 153 | ;; |
154 | esac | 154 | esac |
155 | shift | 155 | shift |
@@ -157,22 +157,22 @@ done | |||
157 | 157 | ||
158 | # If the source log file doesn't exist, exit | 158 | # If the source log file doesn't exist, exit |
159 | 159 | ||
160 | if [ ! -e $logfile ]; then | 160 | if [ ! -e "$logfile" ]; then |
161 | echo "Log check error: Log file $logfile does not exist!" | 161 | echo "Log check error: Log file $logfile does not exist!" |
162 | exit $STATE_UNKNOWN | 162 | exit "$STATE_UNKNOWN" |
163 | elif [ ! -r $logfile ] ; then | 163 | elif [ ! -r "$logfile" ] ; then |
164 | echo "Log check error: Log file $logfile is not readable!" | 164 | echo "Log check error: Log file $logfile is not readable!" |
165 | exit $STATE_UNKNOWN | 165 | exit "$STATE_UNKNOWN" |
166 | fi | 166 | fi |
167 | 167 | ||
168 | # If the old log file doesn't exist, this must be the first time | 168 | # If the old log file doesn't exist, this must be the first time |
169 | # we're running this test, so copy the original log file over to | 169 | # we're running this test, so copy the original log file over to |
170 | # the old diff file and exit | 170 | # the old diff file and exit |
171 | 171 | ||
172 | if [ ! -e $oldlog ]; then | 172 | if [ ! -e "$oldlog" ]; then |
173 | cat $logfile > $oldlog | 173 | cat "$logfile" > "$oldlog" |
174 | echo "Log check data initialized..." | 174 | echo "Log check data initialized..." |
175 | exit $STATE_OK | 175 | exit "$STATE_OK" |
176 | fi | 176 | fi |
177 | 177 | ||
178 | # The old log file exists, so compare it to the original log now | 178 | # The old log file exists, so compare it to the original log now |
@@ -184,20 +184,20 @@ if [ -x /bin/mktemp ]; then | |||
184 | else | 184 | else |
185 | tempdiff=$(/bin/date '+%H%M%S') | 185 | tempdiff=$(/bin/date '+%H%M%S') |
186 | tempdiff="/tmp/check_log.${tempdiff}" | 186 | tempdiff="/tmp/check_log.${tempdiff}" |
187 | touch $tempdiff | 187 | touch "$tempdiff" |
188 | chmod 600 $tempdiff | 188 | chmod 600 "$tempdiff" |
189 | fi | 189 | fi |
190 | 190 | ||
191 | diff $logfile $oldlog | grep -v "^>" > $tempdiff | 191 | diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff" |
192 | 192 | ||
193 | # Count the number of matching log entries we have | 193 | # Count the number of matching log entries we have |
194 | count=$(grep -c "$query" $tempdiff) | 194 | count=$(grep -c "$query" "$tempdiff") |
195 | 195 | ||
196 | # Get the last matching entry in the diff file | 196 | # Get the last matching entry in the diff file |
197 | lastentry=$(grep "$query" $tempdiff | tail -1) | 197 | lastentry=$(grep "$query" "$tempdiff" | tail -1) |
198 | 198 | ||
199 | rm -f $tempdiff | 199 | rm -f "$tempdiff" |
200 | cat $logfile > $oldlog | 200 | cat "$logfile" > "$oldlog" |
201 | 201 | ||
202 | if [ "$count" = "0" ]; then # no matches, exit with no error | 202 | if [ "$count" = "0" ]; then # no matches, exit with no error |
203 | echo "Log check ok - 0 pattern matches found" | 203 | echo "Log check ok - 0 pattern matches found" |
@@ -207,4 +207,4 @@ else # Print total matche count and the last entry we found | |||
207 | exitstatus=$STATE_CRITICAL | 207 | exitstatus=$STATE_CRITICAL |
208 | fi | 208 | fi |
209 | 209 | ||
210 | exit $exitstatus | 210 | exit "$exitstatus" |
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index d4d3aae..0e751f3 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -8,11 +8,11 @@ | |||
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 |
16 | 16 | ||
17 | 17 | ||
18 | print_usage() { | 18 | print_usage() { |
@@ -29,7 +29,7 @@ print_usage() { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | print_help() { | 31 | print_help() { |
32 | print_revision $PROGNAME $REVISION | 32 | print_revision "$PROGNAME" "$REVISION" |
33 | echo "" | 33 | echo "" |
34 | print_usage | 34 | print_usage |
35 | echo "" | 35 | echo "" |
@@ -87,47 +87,47 @@ esac | |||
87 | case "$cmd" in | 87 | case "$cmd" in |
88 | --help) | 88 | --help) |
89 | print_help | 89 | print_help |
90 | exit $STATE_OK | 90 | exit "$STATE_OK" |
91 | ;; | 91 | ;; |
92 | -h) | 92 | -h) |
93 | print_help | 93 | print_help |
94 | exit $STATE_OK | 94 | exit "$STATE_OK" |
95 | ;; | 95 | ;; |
96 | --version) | 96 | --version) |
97 | print_revision $PROGNAME $REVISION | 97 | print_revision "$PROGNAME" "$REVISION" |
98 | exit $STATE_OK | 98 | exit "$STATE_OK" |
99 | ;; | 99 | ;; |
100 | -V) | 100 | -V) |
101 | print_revision $PROGNAME $REVISION | 101 | print_revision "$PROGNAME" "$REVISION" |
102 | exit $STATE_OK | 102 | exit "$STATE_OK" |
103 | ;; | 103 | ;; |
104 | esac | 104 | esac |
105 | 105 | ||
106 | # Hunt down a reasonable ORACLE_HOME | 106 | # Hunt down a reasonable ORACLE_HOME |
107 | if [ -z "$ORACLE_HOME" ] ; then | 107 | if [ -z "$ORACLE_HOME" ] ; then |
108 | # Adjust to taste | 108 | # Adjust to taste |
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 SID ORACLE_HOME junk; | 113 | while read SID ORACLE_HOME junk; |
114 | do | 114 | do |
115 | if [ "$SID" = "$2" -o "$SID" = "*" ] ; then | 115 | if [ "$SID" = "$2" -o "$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 |
123 | # Last resort | 123 | # Last resort |
124 | [ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle | 124 | [ -z "$ORACLE_HOME" -a -d "$PROGPATH"/oracle ] && ORACLE_HOME=$PROGPATH/oracle |
125 | 125 | ||
126 | if [ "$cmd" != "--db" ]; then | 126 | if [ "$cmd" != "--db" ]; then |
127 | if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then | 127 | if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then |
128 | echo "Cannot determine ORACLE_HOME for sid $2" | 128 | echo "Cannot determine ORACLE_HOME for sid $2" |
129 | exit $STATE_UNKNOWN | 129 | exit "$STATE_UNKNOWN" |
130 | fi | 130 | fi |
131 | fi | 131 | fi |
132 | PATH=$PATH:$ORACLE_HOME/bin | 132 | PATH=$PATH:$ORACLE_HOME/bin |
133 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib | 133 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib |
@@ -135,81 +135,81 @@ 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" |
143 | exit $STATE_OK | 143 | exit "$STATE_OK" |
144 | else | 144 | else |
145 | echo "No TNS Listener on $2" | 145 | echo "No TNS Listener on $2" |
146 | exit $STATE_CRITICAL | 146 | exit "$STATE_CRITICAL" |
147 | fi | 147 | fi |
148 | ;; | 148 | ;; |
149 | --oranames) | 149 | --oranames) |
150 | namesctl status $2 | awk ' | 150 | namesctl status "$2" | awk ' |
151 | /Server has been running for:/ { | 151 | /Server has been running for:/ { |
152 | msg = "OK: Up" | 152 | msg = "OK: Up" |
153 | for (i = 6; i <= NF; i++) { | 153 | for (i = 6; i <= NF; i++) { |
154 | msg = msg " " $i | 154 | msg = msg " " $i |
155 | } | 155 | } |
156 | status = '$STATE_OK' | 156 | status = '"$STATE_OK"' |
157 | } | 157 | } |
158 | /error/ { | 158 | /error/ { |
159 | msg = "CRITICAL: " $0 | 159 | msg = "CRITICAL: " $0 |
160 | status = '$STATE_CRITICAL' | 160 | status = '"$STATE_CRITICAL"' |
161 | } | 161 | } |
162 | END { | 162 | END { |
163 | print msg | 163 | print msg |
164 | exit status | 164 | exit status |
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" |
172 | #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then | 172 | #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then |
173 | #if [ ${pmonchk} -eq 1 ] ; then | 173 | #if [ ${pmonchk} -eq 1 ] ; then |
174 | #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` | 174 | #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` |
175 | #echo "${2} OK - running since ${utime}" | 175 | #echo "${2} OK - running since ${utime}" |
176 | #exit $STATE_OK | 176 | #exit $STATE_OK |
177 | #fi | 177 | #fi |
178 | else | 178 | else |
179 | echo "${2} Database is DOWN" | 179 | echo "${2} Database is DOWN" |
180 | exit $STATE_CRITICAL | 180 | exit "$STATE_CRITICAL" |
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 |
206 | ;; | 206 | ;; |
207 | --cache) | 207 | --cache) |
208 | if [ ${5} -gt ${6} ] ; then | 208 | if [ "${5}" -gt "${6}" ] ; then |
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 |
@@ -219,48 +219,48 @@ 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" |
248 | exit $STATE_CRITICAL | 248 | exit "$STATE_CRITICAL" |
249 | fi | 249 | fi |
250 | if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then | 250 | if [ "$buf_hr" -le "${6}" -o "$lib_hr" -le "${6}" ] ; then |
251 | echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" | 251 | echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" |
252 | exit $STATE_WARNING | 252 | exit "$STATE_WARNING" |
253 | fi | 253 | fi |
254 | echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" | 254 | echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" |
255 | 255 | ||
256 | exit $STATE_OK | 256 | exit "$STATE_OK" |
257 | ;; | 257 | ;; |
258 | --tablespace) | 258 | --tablespace) |
259 | if [ ${6} -lt ${7} ] ; then | 259 | if [ "${6}" -lt "${7}" ] ; then |
260 | echo "UNKNOWN - Warning level is more then Crit" | 260 | echo "UNKNOWN - Warning level is more then Crit" |
261 | exit $STATE_UNKNOWN | 261 | exit "$STATE_UNKNOWN" |
262 | fi | 262 | fi |
263 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 263 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
264 | set pagesize 0 | 264 | set pagesize 0 |
265 | set numf '9999999.99' | 265 | 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 | 266 | select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc |
@@ -273,10 +273,10 @@ 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)}') |
@@ -285,20 +285,20 @@ EOF` | |||
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" |
289 | fi | 289 | fi |
290 | if [ "$ts_pct" -ge ${6} ] ; then | 290 | if [ "$ts_pct" -ge "${6}" ] ; then |
291 | echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" | 291 | echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" |
292 | exit $STATE_CRITICAL | 292 | exit "$STATE_CRITICAL" |
293 | fi | 293 | fi |
294 | if [ "$ts_pct" -ge ${7} ] ; then | 294 | if [ "$ts_pct" -ge "${7}" ] ; then |
295 | echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" | 295 | echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" |
296 | exit $STATE_WARNING | 296 | exit "$STATE_WARNING" |
297 | fi | 297 | fi |
298 | echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" | 298 | echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" |
299 | exit $STATE_OK | 299 | exit "$STATE_OK" |
300 | ;; | 300 | ;; |
301 | *) | 301 | *) |
302 | print_usage | 302 | print_usage |
303 | exit $STATE_UNKNOWN | 303 | exit "$STATE_UNKNOWN" |
304 | esac | 304 | esac |
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index 5348b17..9a6cf5d 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
@@ -2,43 +2,43 @@ | |||
2 | 2 | ||
3 | PATH="@TRUSTED_PATH@" | 3 | PATH="@TRUSTED_PATH@" |
4 | export PATH | 4 | export PATH |
5 | PROGNAME=$(basename $0) | 5 | PROGNAME=$(basename "$0") |
6 | PROGPATH=$(echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,') | 6 | PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
7 | REVISION="@NP_VERSION@" | 7 | REVISION="@NP_VERSION@" |
8 | 8 | ||
9 | . $PROGPATH/utils.sh | 9 | . "$PROGPATH"/utils.sh |
10 | 10 | ||
11 | print_usage() { | 11 | print_usage() { |
12 | echo "Usage: $PROGNAME" [--ignore-fault] | 12 | echo "Usage: $PROGNAME" [--ignore-fault] |
13 | } | 13 | } |
14 | 14 | ||
15 | print_help() { | 15 | print_help() { |
16 | print_revision $PROGNAME $REVISION | 16 | print_revision "$PROGNAME" "$REVISION" |
17 | echo "" | 17 | echo "" |
18 | print_usage | 18 | print_usage |
19 | echo "" | 19 | echo "" |
20 | echo "This plugin checks hardware status using the lm_sensors package." | 20 | echo "This plugin checks hardware status using the lm_sensors package." |
21 | echo "" | 21 | echo "" |
22 | support | 22 | support |
23 | exit $STATE_OK | 23 | exit "$STATE_OK" |
24 | } | 24 | } |
25 | 25 | ||
26 | case "$1" in | 26 | case "$1" in |
27 | --help) | 27 | --help) |
28 | print_help | 28 | print_help |
29 | exit $STATE_OK | 29 | exit "$STATE_OK" |
30 | ;; | 30 | ;; |
31 | -h) | 31 | -h) |
32 | print_help | 32 | print_help |
33 | exit $STATE_OK | 33 | exit "$STATE_OK" |
34 | ;; | 34 | ;; |
35 | --version) | 35 | --version) |
36 | print_revision $PROGNAME $REVISION | 36 | print_revision "$PROGNAME" "$REVISION" |
37 | exit $STATE_OK | 37 | exit "$STATE_OK" |
38 | ;; | 38 | ;; |
39 | -V) | 39 | -V) |
40 | print_revision $PROGNAME $REVISION | 40 | print_revision "$PROGNAME" "$REVISION" |
41 | exit $STATE_OK | 41 | exit "$STATE_OK" |
42 | ;; | 42 | ;; |
43 | *) | 43 | *) |
44 | sensordata=$(sensors 2>&1) | 44 | sensordata=$(sensors 2>&1) |
@@ -49,10 +49,10 @@ case "$1" in | |||
49 | elif test ${status} -ne 0; then | 49 | elif test ${status} -ne 0; then |
50 | text="WARNING - sensors returned state $status" | 50 | text="WARNING - sensors returned state $status" |
51 | exit=$STATE_WARNING | 51 | exit=$STATE_WARNING |
52 | elif echo ${sensordata} | egrep ALARM > /dev/null; then | 52 | elif echo "${sensordata}" | egrep ALARM > /dev/null; then |
53 | text="SENSOR CRITICAL - Sensor alarm detected!" | 53 | text="SENSOR CRITICAL - Sensor alarm detected!" |
54 | exit=$STATE_CRITICAL | 54 | exit=$STATE_CRITICAL |
55 | elif echo ${sensordata} | egrep FAULT > /dev/null \ | 55 | elif echo "${sensordata}" | egrep FAULT > /dev/null \ |
56 | && test "$1" != "-i" -a "$1" != "--ignore-fault"; then | 56 | && test "$1" != "-i" -a "$1" != "--ignore-fault"; then |
57 | text="SENSOR UNKNOWN - Sensor reported fault" | 57 | text="SENSOR UNKNOWN - Sensor reported fault" |
58 | exit=$STATE_UNKNOWN | 58 | exit=$STATE_UNKNOWN |
@@ -63,8 +63,8 @@ case "$1" in | |||
63 | 63 | ||
64 | echo "$text" | 64 | echo "$text" |
65 | if test "$1" = "-v" -o "$1" = "--verbose"; then | 65 | if test "$1" = "-v" -o "$1" = "--verbose"; then |
66 | echo ${sensordata} | 66 | echo "${sensordata}" |
67 | fi | 67 | fi |
68 | exit $exit | 68 | exit "$exit" |
69 | ;; | 69 | ;; |
70 | esac | 70 | esac |