diff options
| author | Jan Wagner <waja@cyconet.org> | 2017-01-06 16:54:29 +0100 |
|---|---|---|
| committer | Jan Wagner <waja@cyconet.org> | 2017-01-06 16:54:29 +0100 |
| commit | 439b93049ddcfa28d7d3b8dd8085770c613aabc3 (patch) | |
| tree | a21e9044fc6cfb19dd1371f131407df91f18f2cd | |
| parent | 3fc149f4990358a91ca945f8b649a4c511722e73 (diff) | |
| download | monitoring-plugins-439b930.tar.gz | |
Fixing shellcheck SC2006
| -rwxr-xr-x | plugins-scripts/check_log.sh | 12 | ||||
| -rwxr-xr-x | plugins-scripts/check_oracle.sh | 64 | ||||
| -rwxr-xr-x | plugins-scripts/check_sensors.sh | 6 |
3 files changed, 41 insertions, 41 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index d28c8d0a..45992687 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
| @@ -60,8 +60,8 @@ | |||
| 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 |
| @@ -180,9 +180,9 @@ fi | |||
| 180 | # The temporary file that the script should use while | 180 | # The temporary file that the script should use while |
| 181 | # processing the log file. | 181 | # processing the log file. |
| 182 | if [ -x /bin/mktemp ]; then | 182 | if [ -x /bin/mktemp ]; then |
| 183 | tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX` | 183 | tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX) |
| 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 |
| @@ -191,10 +191,10 @@ fi | |||
| 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 |
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 96078aca..d4d3aae0 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 |
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index f7428301..5348b175 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
| @@ -2,8 +2,8 @@ | |||
| 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 |
| @@ -41,7 +41,7 @@ case "$1" in | |||
| 41 | exit $STATE_OK | 41 | exit $STATE_OK |
| 42 | ;; | 42 | ;; |
| 43 | *) | 43 | *) |
| 44 | sensordata=`sensors 2>&1` | 44 | sensordata=$(sensors 2>&1) |
| 45 | status=$? | 45 | status=$? |
| 46 | if test ${status} -eq 127; then | 46 | if test ${status} -eq 127; then |
| 47 | text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" | 47 | text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" |
