Commit e5211790 authored by Fulvio Galeazzi's avatar Fulvio Galeazzi
Browse files

2018-02-28: FG; Updated.

parent a14ff87c
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.devdiscovery[*],/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.
UserParameter=custom.dellmd38xx.device.discovery[*],cat /tmp/zbxDellStorageDiscover.out
......@@ -46,7 +46,11 @@ Options:
-p PATHBIN, --path=PATHBIN
Full path of SMcli executable
-r, --raid=String Name (or IP of one of the controllers) of the Storage Array
-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
-w, --want=String1[,String2[,String3]]
List of words identifying storage objects
......@@ -128,8 +132,8 @@ avgIOlat,1"
WANTOBJECTS="Storage,RAID,Disk"
# Use getopt(1) program to parse command line options
SHORT=vhep:r:w:i:z:s:q:c:k:dt
LONG=version,help,check,path:,raid:,want:,interval:,zabbixserver:,sender:,zabbixport:,zabbixsource:,timeout:,config:,debug,dumpconfig,test
SHORT=vhep:m:r:w:i:z:s:q:c:k:dt
LONG=version,help,check,path:,match:,raid:,want:,interval:,zabbixserver:,sender:,zabbixport:,zabbixsource:,timeout:,config:,debug,dumpconfig,test
PARSED=`getopt --options $SHORT --longoptions $LONG --name "$0" -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$PARSED"
......@@ -152,8 +156,12 @@ while true; do
PATHBIN="$2"
shift 2
;;
-m|--match)
MATCHSTR="$2"
shift 2
;;
-r|--raid)
RAIDNAME="$2"
RAIDCTRLLIST="$2"
shift 2
;;
-w|--want)
......@@ -220,46 +228,50 @@ if [[ -z $CONFIGFILE ]]; then
echo "$DEFAULTCONFIG" > $CONFIGFILE
fi
KNOWNARRAYS=`mktemp`
if [ -z "$PATHBIN" ]; then
PATHBIN="`which SMcli > /dev/null`"
fi
GET_CMD="$SUDOCMD $PATHBIN -d -i > $KNOWNARRAYS"
if [[ $DEBUG = 1 ]]; then
echo -n -e "\n########################################\n"
echo -n -e "Command line to collect data\n"
echo -n -e "$GET_CMD\n"
fi
eval $GET_CMD
RET_VAL=$?
if [[ $RET_VAL = 0 ]]; then
index=0
raidCtrlThis=""
raidNameThis=""
while read aLine ; do
# Strip leading and trailing space, replace blanks with comma
aNiceLine=`echo $aLine | sed -e 's/^\s\+//' -e 's/\s\+$//' -e 's/\s\+/,/g'`
firstWord=${aNiceLine%%,*}
if [[ -z "$firstWord" || ${firstWord} == *"SMcli"* ]]; then
continue
fi
if [[ ! "$aLine" == *"$RAIDNAME"* ]]; then
continue
fi
raidNameThis="$firstWord"
tmpString="${aNiceLine#*,}"
raidCtrlThis="${tmpString//,/ }"
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
echo -e "raidName: ${raidNameThis} raidCtrl: --${raidCtrlThis}--"
fi
break
done < $KNOWNARRAYS
rm $KNOWNARRAYS
if [[ -z "$RAIDCTRLLIST" ]]; then
KNOWNARRAYS=`mktemp`
if [ -z "$PATHBIN" ]; then
PATHBIN="`which SMcli > /dev/null`"
fi
GET_CMD="$SUDOCMD $PATHBIN -d -i > $KNOWNARRAYS"
if [[ $DEBUG = 1 ]]; then
echo -n -e "\n########################################\n"
echo -n -e "Command line to collect data\n"
echo -n -e "$GET_CMD\n"
fi
eval $GET_CMD
RET_VAL=$?
if [[ $RET_VAL = 0 ]]; then
index=0
raidCtrlThis=""
raidNameThis=""
while read aLine ; do
# Strip leading and trailing space, replace blanks with comma
aNiceLine=`echo $aLine | sed -e 's/^\s\+//' -e 's/\s\+$//' -e 's/\s\+/,/g'`
firstWord=${aNiceLine%%,*}
if [[ -z "$firstWord" || ${firstWord} == *"SMcli"* ]]; then
continue
fi
if [[ ! -z "$MATCHSTR" && ! "$aLine" == *"$MATCHSTR"* ]]; then
continue
fi
raidNameThis="$firstWord"
tmpString="${aNiceLine#*,}"
raidCtrlThis="${tmpString//,/ }"
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
echo -e "raidName: ${raidNameThis} raidCtrl: --${raidCtrlThis}--"
fi
break
done < $KNOWNARRAYS
rm $KNOWNARRAYS
else
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 2" >> $SENDERFILE
fi
raidList="$raidCtrlThis"
else
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 2" >> $SENDERFILE
raidList="${RAIDCTRLLIST//,/ }"
fi
raidList="$raidCtrlThis"
IFS=',' read -a wantObjArr <<< "$WANTOBJECTS"
......
......@@ -223,7 +223,7 @@ if [[ $RET_VAL = 0 ]]; then
else
echo "," >> $DISCOJSON
fi
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\", " >> $DISCOJSON
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\", \"{#RAIDCTRL}\":\"${raidCtrlArray1[$idx]}\", " >> $DISCOJSON
echo -n -e "\"{#DEVTYPE}\":\"${deviceType}\", \"{#DEVNAME}\":\"${deviceName}\"\n }" >> $DISCOJSON
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
......@@ -238,7 +238,8 @@ if [[ $RET_VAL = 0 ]]; then
else
echo "," >> $DISCOJSON
fi
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\"\n }" >> $DISCOJSON
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\", " >> $DISCOJSON
echo -n -e "\"{#RAIDCTRL}\":\"${raidCtrlArray1[$idx]}\"\n }" >> $DISCOJSON
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
echo -e "raidName: ${raidNameArray[$idx]}"
......
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