Commit 720c78d8 authored by Fulvio Galeazzi's avatar Fulvio Galeazzi
Browse files

2018-03-06: FG; Consistently changed (script/config) behaviour of -r switch.

parent 13379d51
# $2 is left as a placeholder, just in case...
UserParameter=custom.dellmd38xx.array.discovery[*],/etc/zabbix/scripts/zbxDellStorageDiscover.sh $1 $2 UserParameter=custom.dellmd38xx.array.discovery[*],/etc/zabbix/scripts/zbxDellStorageDiscover.sh $1 $2
UserParameter=custom.dellmd38xx.array.exec[*],/etc/zabbix/scripts/zbxDellStorageDeviceStatus.sh $1 --raid $2 UserParameter=custom.dellmd38xx.array.exec[*],/etc/zabbix/scripts/zbxDellStorageDeviceStatus.sh $1 --raid $2,$3
# UserParameter=custom.dellmd38xx.device.discovery[*],/etc/zabbix/scripts/zbxDellStorageDiscover.sh $1 $2 $3 --devices # UserParameter=custom.dellmd38xx.device.discovery[*],/etc/zabbix/scripts/zbxDellStorageDiscover.sh $1 $2 $3 --devices
#---> Workaround, as above command takes too long to execute: make Zabbix happy by reading a file, produced with crontab by above script. #---> Workaround, as above command takes too long to execute: make Zabbix happy by reading a file, produced with crontab by above script.
UserParameter=custom.dellmd38xx.device.discovery[*],cat /tmp/zbxDellStorageDiscover.out UserParameter=custom.dellmd38xx.device.discovery[*],cat /tmp/zbxDellStorageDiscover.out
...@@ -49,8 +49,8 @@ Options: ...@@ -49,8 +49,8 @@ Options:
-m, --match=String Filter Storage Array name according to String -m, --match=String Filter Storage Array name according to String
-r, --raid=String Skip initial SMcli query and assume argument is -r, --raid=String Skip initial SMcli query and assume argument is
comma-separated list of controllers belonging comma-separated list of controller-name followed
to the same Storage Array by relevant controller addresses
-w, --want=String1[,String2[,String3]] -w, --want=String1[,String2[,String3]]
List of words identifying storage objects List of words identifying storage objects
...@@ -103,7 +103,7 @@ Options: ...@@ -103,7 +103,7 @@ Options:
ZABBIXSERVER=localhost ZABBIXSERVER=localhost
SENDER=/usr/bin/zabbix_sender SENDER=/usr/bin/zabbix_sender
DEBUG=0 DEBUG=0
TEST=1 TEST=0
ZABBIXPORT=10051 ZABBIXPORT=10051
ZABBIXSOURCE=localhost ZABBIXSOURCE=localhost
CHECKSYNTAX="-e" CHECKSYNTAX="-e"
...@@ -232,6 +232,7 @@ if [[ -z $CONFIGFILE ]]; then ...@@ -232,6 +232,7 @@ if [[ -z $CONFIGFILE ]]; then
echo "$DEFAULTCONFIG" > $CONFIGFILE echo "$DEFAULTCONFIG" > $CONFIGFILE
fi fi
hasFailed=0
if [[ -z "$RAIDCTRLLIST" ]]; then if [[ -z "$RAIDCTRLLIST" ]]; then
KNOWNARRAYS=`mktemp` KNOWNARRAYS=`mktemp`
if [ -z "$PATHBIN" ]; then if [ -z "$PATHBIN" ]; then
...@@ -270,7 +271,8 @@ if [[ -z "$RAIDCTRLLIST" ]]; then ...@@ -270,7 +271,8 @@ if [[ -z "$RAIDCTRLLIST" ]]; then
done < $KNOWNARRAYS done < $KNOWNARRAYS
rm $KNOWNARRAYS rm $KNOWNARRAYS
else else
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 2" >> $SENDERFILESTATUS hasFailed=2
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" $hasFailed" >> $SENDERFILESTATUS
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS" SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS"
if [[ $DEBUG = 1 ]]; then if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
...@@ -282,13 +284,24 @@ if [[ -z "$RAIDCTRLLIST" ]]; then ...@@ -282,13 +284,24 @@ if [[ -z "$RAIDCTRLLIST" ]]; then
else else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null [[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi fi
echo 2
fi fi
raidList="$raidCtrlThis" raidList="$raidCtrlThis"
else else
raidList="${RAIDCTRLLIST//,/ }" raidNameThis="${RAIDCTRLLIST%%,*}"
tmpString="${RAIDCTRLLIST#*,}"
raidList="${tmpString//,/ }"
fi fi
if [[ $hasFailed > 0 ]]; then
if [[ $TEST = 0 ]]; then
if [[ $DEBUG = 1 ]]; then
rm -f $SENDERFILEDEBUG
fi
rm -f $SENDERFILESTATUS
fi
echo $hasFailed
exit $hasFailed
fi
IFS=',' read -a wantObjArr <<< "$WANTOBJECTS" IFS=',' read -a wantObjArr <<< "$WANTOBJECTS"
GET_CMD="$SUDOCMD $PATHBIN $raidList $CHECKSYNTAX -c 'set session performanceMonitorInterval=$MONINTERVAL performanceMonitorIterations=1 ; save storageArray performanceStats file=\"$STATUSFILE\";' > /dev/null" GET_CMD="$SUDOCMD $PATHBIN $raidList $CHECKSYNTAX -c 'set session performanceMonitorInterval=$MONINTERVAL performanceMonitorIterations=1 ; save storageArray performanceStats file=\"$STATUSFILE\";' > /dev/null"
...@@ -365,7 +378,8 @@ if [[ $RET_VAL = 0 ]]; then ...@@ -365,7 +378,8 @@ if [[ $RET_VAL = 0 ]]; then
rm -f $SENDERFILE rm -f $SENDERFILE
done < $STATUSFILE done < $STATUSFILE
else else
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 1" >> $SENDERFILESTATUS hasFailed=1
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" $hasFailed" >> $SENDERFILESTATUS
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS" SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS"
if [[ $DEBUG = 1 ]]; then if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
...@@ -377,9 +391,22 @@ else ...@@ -377,9 +391,22 @@ else
else else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null [[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi fi
echo 1
fi fi
if [[ $hasFailed > 0 ]]; then
if [[ $TEST = 0 ]]; then
if [[ $DEBUG = 1 ]]; then
rm -f $SENDERFILEDEBUG
fi
rm -f $SENDERFILESTATUS
rm -f $STATUSFILE
if [[ -n $tmpCONFIGFILE ]]; then
rm -f $CONFIGFILE
fi
fi
echo $hasFailed
exit $hasFailed
fi
# DEBUG # DEBUG
if [[ $DEBUG = 1 ]]; then if [[ $DEBUG = 1 ]]; then
...@@ -408,6 +435,7 @@ if [[ $DEBUG = 1 ]]; then ...@@ -408,6 +435,7 @@ if [[ $DEBUG = 1 ]]; then
echo "--zabbixport=$ZABBIXPORT" echo "--zabbixport=$ZABBIXPORT"
echo "--zabbixsource=$ZABBIXSOURCE" echo "--zabbixsource=$ZABBIXSOURCE"
echo "--timeout=$TIMEOUT" echo "--timeout=$TIMEOUT"
echo "--test=$TEST"
echo -e "\n wantObjects=${wantObjArr[@]}\n" echo -e "\n wantObjects=${wantObjArr[@]}\n"
...@@ -419,11 +447,14 @@ if [[ $DEBUG = 1 ]]; then ...@@ -419,11 +447,14 @@ if [[ $DEBUG = 1 ]]; then
fi fi
# Housekeeping # Housekeeping
rm -f $STATUSFILE if [[ $TEST = 0 ]]; then
rm -f $SENDERFILEDEBUG if [[ $DEBUG = 1 ]]; then
rm -f $SENDERFILESTATUS rm -f $SENDERFILEDEBUG
if [[ -n $tmpCONFIGFILE ]]; then fi
rm -f $CONFIGFILE rm -f $SENDERFILESTATUS
rm -f $STATUSFILE
if [[ -n $tmpCONFIGFILE ]]; then
rm -f $CONFIGFILE
fi
fi fi
echo 0 echo 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment