Skip to content

Commit

Permalink
Patch by Christoph Schug applied to replace two (cut) systemcalls wit…
Browse files Browse the repository at this point in the history
…h one (sed) when getting DEVICESTRING.

Added quotes in various places for consistency
Dont set state to unknown if state is already critical (for code added in 1.4)
unset $ERR before doing anything to avoid problems if the variable is already set
  • Loading branch information
Klintrup committed Jun 20, 2019
1 parent 06a1439 commit 10380bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.4.0] - 2007-02-08
### Changed
- If a volume didn't have a known state, it just wouldn't show that volume, it now exits with errorcode3 and outputs as "unknown state"
## [1.4.1] - 2007-02-14
### Changed
- Patch by Christoph Schug applied to replace two (cut) systemcalls with one (sed) when getting DEVICESTRING.
- Added quotes in various places for consistency
- Don't set state to unknown if state is already critical (for code added in 1.4)
- unset $ERR before doing anything to avoid problems if the variable is already set
11 changes: 6 additions & 5 deletions check_smartarray.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/bin/sh
# NRPE check for Proliant SmartArray Controllers (ciss)
# Written by: Søren Klintrup <soren at klintrup.dk>
# version 1.4.0
# version 1.4.1

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DEVICES=$(camcontrol devlist|grep "COMPAQ RAID"|sed -Ee 's/.*(pass[0-9]{1,3}).*/\1/')
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
DEVICES="$(camcontrol devlist|grep "COMPAQ RAID"|sed -Ee 's/.*(pass[0-9]{1,3}).*/\1/')"
unset ERRORSTRING
unset OKSTRING
unset ERR

for DEVICE in ${DEVICES}
do
DEVICENAME="$(camcontrol devlist|grep ${DEVICE}|sed -Ee 's/.*(da[0-9]{1,3}).*/\1/')"
DEVICESTRING=$(camcontrol inquiry ${DEVICE} -D|cut -d '<' -f 2|cut -d '>' -f 1)
DEVICESTRING="$(camcontrol inquiry ${DEVICE} -D|sed -n -e 's/^[^<]*<\([^>]*\)>.*$/\1/p')"
if [ "$(echo ${DEVICESTRING}|tr A-Z a-z|sed -Ee 's/.*(rea|int|rec|fai|ok).*/\1/')" = "" ]
then
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: unknown state"
ERR = 3
if ! [ "${ERR}" = 2 ];then ERR=3;fi
else
case $(echo ${DEVICESTRING}|tr A-Z a-z|sed -Ee 's/.*(rea|int|rec|fai|ok).*/\1/') in
int)
Expand Down

0 comments on commit 10380bd

Please sign in to comment.