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

2018-02-27: FG; Added discovery rules, for RAIDarrays and devices.

parent e4b29621
UserParameter=custom.dellmd38xx.array.discovery[*],/etc/zabbix/scripts/zbxDellStorageDeviceDiscover.sh $1
UserParameter=custom.dellmd38xx.array.exec[*],/etc/zabbix/scripts/zbxDellStorageStatusCheck.sh $1 --raid $2
UserParameter=custom.dellmd38xx.device.discovery[*],/etc/zabbix/scripts/zbxDellStorageDeviceDiscover.sh $1 --devices
......@@ -54,6 +54,8 @@ Options:
Storage,RAID,Disk
(note that Disk matches both Group and Pool)
--devices Output full JSON, not only array names
--timeout=seconds Connection timeout
[default: 30]
......@@ -69,12 +71,13 @@ DEBUG=0
TEST=1
MONINTERVAL=1
PATHBIN="`which SMcli > /dev/null`"
SHOWDEV=0
TIMEOUT=30
WANTOBJECTS="Storage,RAID,Disk"
# Use getopt(1) program to parse command line options
SHORT=vhep:m:w:dt
LONG=version,help,check,path:,match:,want:,timeout:,debug,test
LONG=version,help,check,path:,match:,want:,devices,timeout:,debug,test
PARSED=`getopt --options $SHORT --longoptions $LONG --name "$0" -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$PARSED"
......@@ -105,6 +108,10 @@ while true; do
WANTOBJECTS="$2"
shift 2
;;
--devices)
SHOWDEV=1
shift 1
;;
--timeout)
TIMEOUT="$2"
shift 2
......@@ -177,48 +184,61 @@ if [[ $RET_VAL = 0 ]]; then
raidList="${raidCtrlArray2[$idx]}"
STATUSFILE=`mktemp`
GET_CMD="$PATHBIN $raidList $CHECKSYNTAX -c 'set session performanceMonitorInterval=3 performanceMonitorIterations=1 ; save storageArray performanceStats file=\"$STATUSFILE\";' > /dev/null"
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
# get data from server
eval $GET_CMD
RET_VAL=$?
if [[ $RET_VAL = 0 ]]; then
while read STATUSLINE
do
# read the status file to get all relevant statistics
# Replaces all occurrences of " character
aLine=`echo ${STATUSLINE//\"}`
# Split line into fields
IFS=',' read -a arrayLine <<< "$aLine"
# Skip not-so-interesting lines
firstField="${arrayLine[0]}"
firstWord=`echo ${arrayLine[0]} | awk '{print $1}'`
if [[ -z "$firstWord" || ! "${wantObjArr[@]}" =~ "$firstWord" ]]; then
continue
fi
tmpString=`echo $firstField | awk '{print $1" "$2}'`
deviceType=${tmpString// /_}
deviceName=${firstField:${#tmpString}+1}
deviceName=${deviceName// /_}
if [[ $firstIter = 1 ]]; then
firstIter=0
else
echo "," >> $DISCOJSON
fi
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\", " >> $DISCOJSON
echo -n -e "\"{#DEVTYPE}\":\"${deviceType}\", \"{#DEVNAME}\":\"${deviceName}\"\n }" >> $DISCOJSON
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
echo -e "raidName: ${raidNameArray[$idx]} deviceType: ${deviceType} \t deviceName: ${deviceName}"
fi
done < $STATUSFILE
if [[ $SHOWDEV = 1 ]]; then
GET_CMD="$PATHBIN $raidList $CHECKSYNTAX -c 'set session performanceMonitorInterval=3 performanceMonitorIterations=1 ; save storageArray performanceStats file=\"$STATUSFILE\";' > /dev/null"
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
# get data from server
eval $GET_CMD
RET_VAL=$?
if [[ $RET_VAL = 0 ]]; then
while read STATUSLINE
do
# read the status file to get all relevant statistics
# Replaces all occurrences of " character
aLine=`echo ${STATUSLINE//\"}`
# Split line into fields
IFS=',' read -a arrayLine <<< "$aLine"
# Skip not-so-interesting lines
firstField="${arrayLine[0]}"
firstWord=`echo ${arrayLine[0]} | awk '{print $1}'`
if [[ -z "$firstWord" || ! "${wantObjArr[@]}" =~ "$firstWord" ]]; then
continue
fi
tmpString=`echo $firstField | awk '{print $1" "$2}'`
deviceType=${tmpString// /_}
deviceName=${firstField:${#tmpString}+1}
deviceName=${deviceName// /_}
if [[ $firstIter = 1 ]]; then
firstIter=0
else
echo "," >> $DISCOJSON
fi
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\", " >> $DISCOJSON
echo -n -e "\"{#DEVTYPE}\":\"${deviceType}\", \"{#DEVNAME}\":\"${deviceName}\"\n }" >> $DISCOJSON
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
echo -e "raidName: ${raidNameArray[$idx]} deviceType: ${deviceType} \t deviceName: ${deviceName}"
fi
done < $STATUSFILE
fi
rm $STATUSFILE
else
if [[ $firstIter = 1 ]]; then
firstIter=0
else
echo "," >> $DISCOJSON
fi
echo -n -e " {\n\t\"{#RAIDNAME}\":\"${raidNameArray[$idx]}\"\n }" >> $DISCOJSON
if [[ $DEBUG = 1 ]]; then
echo -n -e "\tGot:\t"
echo -e "raidName: ${raidNameArray[$idx]}"
fi
fi
rm $STATUSFILE
done
echo -e '\n ]\n}' >> $DISCOJSON
fi
......@@ -232,6 +252,7 @@ if [[ $DEBUG = 1 ]]; then
echo "--path=$PATHBIN"
echo "--match=$MATCHSTR"
echo "--interval=$MONINTERVAL"
echo "--devices: $SHOWDEV"
echo "--timeout=$TIMEOUT"
echo -e " wantObjects: ${wantObjArr[@]}\n"
echo -e "\n########################################\n"
......
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