diff --git a/Dell_MD38XX/Config/userparameter_dellmd38xx.conf b/Dell_MD38XX/Config/userparameter_dellmd38xx.conf index cf306e355ae60b9eded34bdd18c301e097ccdaf3..f551190e1a05bda38c9ed180f64d67692808f144 100644 --- a/Dell_MD38XX/Config/userparameter_dellmd38xx.conf +++ b/Dell_MD38XX/Config/userparameter_dellmd38xx.conf @@ -1,3 +1,5 @@ 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 diff --git a/Dell_MD38XX/Script/zbxDellStorageDeviceStatus.sh b/Dell_MD38XX/Script/zbxDellStorageDeviceStatus.sh index 96d28672bff3d8373b4e456d135b99e17b339b1b..4df317e3ef397734eee80e44112924a91781937a 100755 --- a/Dell_MD38XX/Script/zbxDellStorageDeviceStatus.sh +++ b/Dell_MD38XX/Script/zbxDellStorageDeviceStatus.sh @@ -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" diff --git a/Dell_MD38XX/Script/zbxDellStorageDiscover.sh b/Dell_MD38XX/Script/zbxDellStorageDiscover.sh index bfdf30f40b8d8281c75a6e587df1cc28f43ba903..3c699b45b45a877311f085ebeb1fbada442fe8dd 100755 --- a/Dell_MD38XX/Script/zbxDellStorageDiscover.sh +++ b/Dell_MD38XX/Script/zbxDellStorageDiscover.sh @@ -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]}"