Skip to content

Commit

Permalink
If a volume didnt have a known state, it just wouldnt show that volum…
Browse files Browse the repository at this point in the history
…e, it now exits with errorcode3 and outputs as "unknown state"
  • Loading branch information
Klintrup committed Jun 20, 2019
1 parent 92cddba commit 5e1d4bc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.3.1] - 2007-01-19
### Changed
- Using tr to replace the string-output from camcontrol, for a more human-readable script, no changes in functionality.
## [1.4.0] - 2007-01-19
### 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"
52 changes: 29 additions & 23 deletions check_smartarray.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
#!/bin/sh
# NRPE check for Proliant SmartArray Controllers (ciss)
# Written by: Søren Klintrup <soren at klintrup.dk>
# version 1.3.1
# version 1.4.0

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

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)
case $(echo ${DEVICESTRING}|tr A-Z a-z|sed -Ee 's/.*(rea|int|rec|fai|ok).*/\1/') in
int)
ERR=2
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: DEGRADED"
;;
fai)
ERR=2
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: FAILED"
;;
rec)
if ! [ "${ERR}" = 2 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: rebuilding"
;;
rea)
if ! [ "${ERR}" = 2 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: ready for recovery"
;;
ok)
OKSTRING="${OKSTRING} | ${DEVICENAME}: ok"
;;
esac
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
else
case $(echo ${DEVICESTRING}|tr A-Z a-z|sed -Ee 's/.*(rea|int|rec|fai|ok).*/\1/') in
int)
ERR=2
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: DEGRADED"
;;
fai)
ERR=2
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: FAILED"
;;
rec)
if ! [ "${ERR}" = 2 -o "${ERR}" = 3 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: rebuilding"
;;
rea)
if ! [ "${ERR}" = 2 -o "${ERR}" = 3 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} | ${DEVICENAME}: ready for recovery"
;;
ok)
OKSTRING="${OKSTRING} | ${DEVICENAME}: ok"
;;
esac
fi
done
if [ "${ERRORSTRING}" -o "${OKSTRING}" ]
then
Expand Down

0 comments on commit 5e1d4bc

Please sign in to comment.