Commit 13379d51 authored by Fulvio Galeazzi's avatar Fulvio Galeazzi
Browse files

2018-03-01: FG; Make several zabbix_send, one for each device.

parent 7b143c49
......@@ -55,7 +55,7 @@ Options:
-w, --want=String1[,String2[,String3]]
List of words identifying storage objects
to query information for. Defaults to
Storage,RAID,Disk
Storage,RAID
(note that Disk matches both Group and Pool)
-i TIME, --interval=ITIME
......@@ -128,8 +128,9 @@ avgMBs,0
curIOlat,0
maxIOlat,0
minIOlat,0
avgIOlat,1"
WANTOBJECTS="Storage,RAID,Disk"
avgIOlat,0"
# WANTOBJECTS="Storage,RAID,Disk"
WANTOBJECTS="Storage,RAID"
# Use getopt(1) program to parse command line options
SHORT=vhep:m:r:w:i:z:s:q:c:k:dt
......@@ -221,7 +222,10 @@ done
# Temporary files
STATUSFILE=`mktemp`
SENDERFILE=`mktemp`
SENDERFILESTATUS=`mktemp`
if [[ $DEBUG = 1 ]]; then
SENDERFILEDEBUG=`mktemp`
fi
if [[ -z $CONFIGFILE ]]; then
CONFIGFILE=`mktemp`
tmpCONFIGFILE=1
......@@ -266,7 +270,18 @@ if [[ -z "$RAIDCTRLLIST" ]]; then
done < $KNOWNARRAYS
rm $KNOWNARRAYS
else
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 2" >> $SENDERFILE
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 2" >> $SENDERFILESTATUS
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS"
if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
echo "\"---\" \"---\" \"---\"" >> $SENDERFILEDEBUG
echo -n -e "\n########################################\n"
echo -n -e "zabbix_sender output\n"
[[ $TEST = 0 ]] && eval $SENDER_CMD
echo -n -e "\n"
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
echo 2
fi
raidList="$raidCtrlThis"
......@@ -285,8 +300,19 @@ RET_VAL=$?
# in case of error, just send [failed] = 1
# otherwise send all collected data
if [[ $RET_VAL = 0 ]]; then
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 0" >> $SENDERFILE
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 0" >> $SENDERFILESTATUS
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS"
if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
echo "\"---\" \"---\" \"---\"" >> $SENDERFILEDEBUG
echo -n -e "\n########################################\n"
echo -n -e "zabbix_sender output\n"
[[ $TEST = 0 ]] && eval $SENDER_CMD
echo -e "\n"
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
index=0
zbxKey=()
zbxWant=()
......@@ -312,6 +338,7 @@ if [[ $RET_VAL = 0 ]]; then
continue
fi
SENDERFILE=`mktemp`
tmpString=`echo $firstField | awk '{print $1" "$2}'`
deviceType=${tmpString// /_}
deviceName=${firstField:${#tmpString}+1}
......@@ -323,14 +350,36 @@ if [[ $RET_VAL = 0 ]]; then
echo -n "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.${zbxKey[$idx]}[${raidNameThis},${deviceType},${deviceName}]\" " >> $SENDERFILE
echo ${arrayLine[$idx]} >> $SENDERFILE
done
# Send all information to Zabbix using zbbix_sender
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILE"
if [[ $DEBUG = 1 ]]; then
cat $SENDERFILE >> $SENDERFILEDEBUG
echo "\"---\" \"---\" \"---\"" >> $SENDERFILEDEBUG
echo -n -e "\n########################################\n"
echo -n -e "zabbix_sender output\n"
[[ $TEST = 0 ]] && eval $SENDER_CMD
echo -n -e "\n"
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
rm -f $SENDERFILE
done < $STATUSFILE
else
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 1" >> $SENDERFILE
echo "\"$ZABBIXSOURCE\" \"custom.dellmd38xx.device.failed[${raidNameThis}]\" 1" >> $SENDERFILESTATUS
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILESTATUS"
if [[ $DEBUG = 1 ]]; then
cat $SENDERFILESTATUS >> $SENDERFILEDEBUG
echo "\"---\" \"---\" \"---\"" >> $SENDERFILEDEBUG
echo -n -e "\n########################################\n"
echo -n -e "zabbix_sender output\n"
[[ $TEST = 0 ]] && eval $SENDER_CMD
echo -n -e "\n"
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
echo 1
fi
# Send all information to Zabbix using zbbix_sender
SENDER_CMD="$SENDER -v --zabbix-server $ZABBIXSERVER --port $ZABBIXPORT --input-file $SENDERFILE"
# DEBUG
if [[ $DEBUG = 1 ]]; then
......@@ -344,11 +393,8 @@ if [[ $DEBUG = 1 ]]; then
echo -e "\n########################################\n"
echo -e "Metrics to be sent\n"
SENDERFILEDEBUG=`mktemp`
echo '"SERVER" "METRIC" VALUE' >> $SENDERFILEDEBUG
cat $SENDERFILE >> $SENDERFILEDEBUG
column -t -s'\"' $SENDERFILEDEBUG
rm -f $SENDERFILEDEBUG
echo -e "\n########################################\n"
echo -e "Parameters\n"
......@@ -370,20 +416,12 @@ if [[ $DEBUG = 1 ]]; then
echo -e "$GET_CMD\n"
echo -e "Command line to send data to Zabbix\n"
echo -e "$SENDER_CMD\n"
if [[ $TEST = 0 ]]; then
echo -e "\n########################################\n"
echo -e "zabbix_sender output\n"
eval $SENDER_CMD
echo -e "\n"
fi
else
[[ $TEST = 0 ]] && eval $SENDER_CMD > /dev/null
fi
# Housekeeping
rm -f $STATUSFILE
rm -f $SENDERFILE
rm -f $SENDERFILEDEBUG
rm -f $SENDERFILESTATUS
if [[ -n $tmpCONFIGFILE ]]; then
rm -f $CONFIGFILE
fi
......
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