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.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
#---> 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
......@@ -49,8 +49,8 @@ Options:
-m, --match=String Filter Storage Array name according to String
-r, --raid=String Skip initial SMcli query and assume argument is
comma-separated list of controllers belonging
to the same Storage Array
comma-separated list of controller-name followed
by relevant controller addresses
-w, --want=String1[,String2[,String3]]
List of words identifying storage objects
......@@ -103,7 +103,7 @@ Options:
ZABBIXSERVER=localhost
SENDER=/usr/bin/zabbix_sender
DEBUG=0
TEST=1
TEST=0
ZABBIXPORT=10051
ZABBIXSOURCE=localhost
CHECKSYNTAX="-e"
......@@ -232,6 +232,7 @@ if [[ -z $CONFIGFILE ]]; then
echo "$DEFAULTCONFIG" > $CONFIGFILE
fi
hasFailed=0
if [[ -z "$RAIDCTRLLIST" ]]; then
KNOWNARRAYS=`mktemp`
if [ -z "$PATHBIN" ]; then
......@@ -270,7 +271,8 @@ if [[ -z "$RAIDCTRLLIST" ]]; then
done < $KNOWNARRAYS
rm $KNOWNARRAYS
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"
if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
......@@ -282,13 +284,24 @@ if [[ -z "$RAIDCTRLLIST" ]]; then
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
echo 2
fi
raidList="$raidCtrlThis"
else
raidList="${RAIDCTRLLIST//,/ }"
raidNameThis="${RAIDCTRLLIST%%,*}"
tmpString="${RAIDCTRLLIST#*,}"
raidList="${tmpString//,/ }"
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"
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
rm -f $SENDERFILE
done < $STATUSFILE
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"
if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
......@@ -377,9 +391,22 @@ else
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
echo 1
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
if [[ $DEBUG = 1 ]]; then
......@@ -408,6 +435,7 @@ if [[ $DEBUG = 1 ]]; then
echo "--zabbixport=$ZABBIXPORT"
echo "--zabbixsource=$ZABBIXSOURCE"
echo "--timeout=$TIMEOUT"
echo "--test=$TEST"
echo -e "\n wantObjects=${wantObjArr[@]}\n"
......@@ -419,11 +447,14 @@ if [[ $DEBUG = 1 ]]; then
fi
# Housekeeping
rm -f $STATUSFILE
rm -f $SENDERFILEDEBUG
rm -f $SENDERFILESTATUS
if [[ -n $tmpCONFIGFILE ]]; then
rm -f $CONFIGFILE
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 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