Flexgroups
#!/bin/bash flexgrouparray=( $(ssh monitor@$1 volume show -is-flexgroup true -fields volume | awk '{print $1","$2}' | grep -v "volume" | grep -v "entries" | grep ^[a-z]) ) numberofflexgroups=$(echo ${#flexgrouparray[@]}) whenlast=2 index=0 cluster=$1 if [ $numberofflexgroups -eq 0 ] then exit 2 fi printf "\n" printf "{\n\t\"data\":[\n\n" if [ $numberofflexgroups -eq 1 ] then svmname=$(echo ${flexgrouparray[$index]} | awk -F, '{print $1}') fgname=$(echo ${flexgrouparray[$index]} | awk -F, '{print $2}') printf "\t{\t\"{#FGSVMNAME}\":\"$svmname\",\t\t\"{#FGNAME}\":\"$fgname\"\t}\n" if ! grep -q "netapp_scaleout_throughput_checker.sh $cluster $svmname $fgname" /var/spool/cron/root then echo "*/10 * * * * /etc/zabbix/zabbix_agentd.d/netapp_scaleout_throughput_checker.sh $cluster $svmname $fgname" >> /var/spool/cron/root fi else while [ $whenlast -le $numberofflexgroups ] do svmname=$(echo ${flexgrouparray[$index]} | awk -F, '{print $1}') fgname=$(echo ${flexgrouparray[$index]} | awk -F, '{print $2}') printf "\t{\t\"{#FGSVMNAME}\":\"$svmname\",\t\t\"{#FGNAME}\":\"$fgname\"\t},\n" index=$(( $index + 1 )) whenlast=$(( $whenlast + 1 )) if ! grep -q "netapp_scaleout_throughput_checker.sh $cluster $svmname $fgname" /var/spool/cron/root then echo "*/10 * * * * /etc/zabbix/zabbix_agentd.d/netapp_scaleout_throughput_checker.sh $cluster $svmname $fgname" >> /var/spool/cron/root fi done svmname=$(echo ${flexgrouparray[$index]} | awk -F, '{print $1}') fgname=$(echo ${flexgrouparray[$index]} | awk -F, '{print $2}') printf "\t{\t\"{#FGSVMNAME}\":\"$svmname\",\t\t\"{#FGNAME}\":\"$fgname\"\t}\n" if ! grep -q "netapp_scaleout_throughput_checker.sh $cluster $svmname $fgname" /var/spool/cron/root then echo "*/10 * * * * /etc/zabbix/zabbix_agentd.d/netapp_scaleout_throughput_checker.sh $cluster $svmname $fgname" >> /var/spool/cron/root fi fi printf "\n\t]\n" printf "}\n"
Infinite Volumes
#!/bin/bash ivolarray=( $(for i in `ssh monitor@$1 vserver show -is-repository true -fields vserver | awk '{print $1}' | grep -v "vserver" | grep ^[a-z]`; do ssh monitor@$1 volume show -vserver $i -fields volume | awk '{print $1","$2}' | grep -v "volume" | grep -v "entries" | grep -v "_vol0" | grep ^[a-z]; done) ) numberofivols=$(echo ${#ivolarray[@]}) whenlast=2 index=0 cluster=$1 if [ $numberofivols -eq 0 ] then exit 2 fi printf "\n" printf "{\n\t\"data\":[\n\n" if [ $numberofivols -eq 1 ] then svmname=$(echo ${ivolarray[$index]} | awk -F, '{print $1}') ivolname=$(echo ${ivolarray[$index]} | awk -F, '{print $2}') printf "\t{\t\"{#IVOLSVMNAME}\":\"$svmname\",\t\t\"{#IVOLNAME}\":\"$ivolname\"\t}\n" if ! grep -q "netapp_scaleout_throughput_checker.sh $cluster $svmname $ivolname" /var/spool/cron/root then echo "03,13,23,33,43,53 * * * * /etc/zabbix/zabbix_agentd.d/netapp_scaleout_throughput_checker.sh $cluster $svmname $ivolname" >> /var/spool/cron/root fi else while [ $whenlast -le $numberofivols ] do svmname=$(echo ${ivolarray[$index]} | awk -F, '{print $1}') ivolname=$(echo ${ivolarray[$index]} | awk -F, '{print $2}') printf "\t{\t\"{#IVOLSVMNAME}\":\"$svmname\",\t\t\"{#IVOLNAME}\":\"$ivolname\"\t},\n" index=$(( $index + 1 )) whenlast=$(( $whenlast + 1 )) if ! grep -q "netapp_scaleout_throughput_checker.sh $cluster $svmname $ivolname" /var/spool/cron/root then echo "03,13,23,33,43,53 * * * * /etc/zabbix/zabbix_agentd.d/netapp_scaleout_throughput_checker.sh $cluster $svmname $ivolname" >> /var/spool/cron/root fi done svmname=$(echo ${ivolarray[$index]} | awk -F, '{print $1}') ivolname=$(echo ${ivolarray[$index]} | awk -F, '{print $2}') printf "\t{\t\"{#IVOLSVMNAME}\":\"$svmname\",\t\t\"{#IVOLNAME}\":\"$ivolname\"\t}\n" if ! grep -q "netapp_scaleout_throughput_checker.sh $cluster $svmname $ivolname" /var/spool/cron/root then echo "03,13,23,33,43,53 * * * * /etc/zabbix/zabbix_agentd.d/netapp_scaleout_throughput_checker.sh $cluster $svmname $ivolname" >> /var/spool/cron/root fi fi printf "\n\t]\n" printf "}\n"
Aggregates
#!/bin/bash aggrarray=( $(for i in `ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$1 "storage aggregate show -fields aggregate" 2> /dev/null | grep ^aggr[0-9] | awk '{print $1}'`; do echo $i; done) ) numberofaggrs=$(echo ${#aggrarray[@]}) whenlast=2 index=0 cluster=$1 if [ $numberofaggrs -eq 0 ] then exit 2 fi printf "\n" printf "{\n\t\"data\":[\n\n" if [ $numberofaggrs -eq 1 ] then aggrname=$(echo ${aggrarray[$index]}) printf "\t{\t\"{#AGGRNAME}\":\"$aggrname\"\t}\n" if ! grep -q "netapp_aggr_throughput_checker.sh $cluster"$ /var/spool/cron/root then echo "03,13,23,33,43,53 * * * * /etc/zabbix/zabbix_agentd.d/netapp_aggr_throughput_checker.sh $cluster" >> /var/spool/cron/root fi else while [ $whenlast -le $numberofaggrs ] do aggrname=$(echo ${aggrarray[$index]}) printf "\t{\t\"{#AGGRNAME}\":\"$aggrname\"\t},\n" index=$(( $index + 1 )) whenlast=$(( $whenlast + 1 )) if ! grep -q "netapp_aggr_throughput_checker.sh $cluster"$ /var/spool/cron/root then echo "03,13,23,33,43,53 * * * * /etc/zabbix/zabbix_agentd.d/netapp_aggr_throughput_checker.sh $cluster" >> /var/spool/cron/root fi done aggrname=$(echo ${aggrarray[$index]}) printf "\t{\t\"{#AGGRNAME}\":\"$aggrname\"\t}\n" if ! grep -q "netapp_aggr_throughput_checker.sh $cluster"$ /var/spool/cron/root then echo "03,13,23,33,43,53 * * * * /etc/zabbix/zabbix_agentd.d/netapp_aggr_throughput_checker.sh $cluster" >> /var/spool/cron/root fi fi printf "\n\t]\n" printf "}\n" if ! grep -q "netapp_aggr_capacity_check.sh $cluster"$ /var/spool/cron/root then echo "01,11,21,31,41,51 * * * * /etc/zabbix/zabbix_agentd.d/netapp_aggr_capacity_check.sh $cluster" >> /var/spool/cron/root fi if ! grep -q "netapp_volume_capacity_check.sh $cluster"$ /var/spool/cron/root then echo "01,11,21,31,41,51 * * * * /etc/zabbix/zabbix_agentd.d/netapp_volume_capacity_check.sh $cluster" >> /var/spool/cron/root fi
Cluster Nodes
#!/bin/bash nodearray=( $(ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$1 "system node show -fields node" 2> /dev/null | sed -n '/------/,/entries/p' | egrep -v ^"-|entries" | tr -s '[:space:]' ' ') ) numberofnodes=$(echo ${#nodearray[@]}) whenlast=2 index=0 cluster=$1 printf "{\n\t\"data\":[\n\n" if [ $numberofnodes -eq 1 ] then printf "\t{\t\"{#NCNODENAME}\":\"${nodearray[$index]}\"\t}\n" if ! grep -q "netapp_node_load_checker.sh $cluster"$ /var/spool/cron/root then echo "02,12,22,32,42,52 * * * * /etc/zabbix/zabbix_agentd.d/netapp_node_load_checker.sh $cluster" >> /var/spool/cron/root fi else while [ $whenlast -le $numberofnodes ] do printf "\t{\t\"{#NCNODENAME}\":\"${nodearray[$index]}\"\t},\n" index=$(( $index + 1 )) whenlast=$(( $whenlast + 1 )) if ! grep -q "netapp_node_load_checker.sh $cluster"$ /var/spool/cron/root then echo "02,12,22,32,42,52 * * * * /etc/zabbix/zabbix_agentd.d/netapp_node_load_checker.sh $cluster" >> /var/spool/cron/root fi done printf "\t{\t\"{#NCNODENAME}\":\"${nodearray[$index]}\"\t}\n" if ! grep -q "netapp_node_load_checker.sh $cluster"$ /var/spool/cron/root then echo "02,12,22,32,42,52 * * * * /etc/zabbix/zabbix_agentd.d/netapp_node_load_checker.sh $cluster" >> /var/spool/cron/root fi fi printf "\n\t]\n" printf "}\n"
SnapMirror Lifs
#!/bin/bash # detect number of intercluster lifs, strip out everything but the lif name # add to an array for the json creation below smlifarray=( $( for i in `ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$1 network interface show -vserver $1 -role intercluster 2> /dev/null | grep ^[[:space:]] | grep -v Logical | awk '{ p rint $1 }' | grep -v ^[[:space:]]`; do echo $i; done) ) # write detected intercluster lifs into file over writing any current file as # that will add and remove as required (node removal/add) # this is then used by the lif throughput checker script ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$1 "network interface show -vserver $1 -role intercluster" 2> /dev/null | grep ^[[:space:]] | grep -v Logical | awk '{ print $1 }' | grep -v ^[ [:space:]] > /tmp/$1_smlifs.txt numberofsmlifs=$(echo ${#smlifarray[@]}) whenlast=2 index=0 cluster=$1 if [ $numberofsmlifs -eq 0 ] then exit 2 fi printf "\n" printf "{\n\t\"data\":[\n\n" if [ $numberofsmlifs -eq 1 ] then smlifname=$(echo ${smlifarray[$index]}) printf "\t{\t\"{#SMLIFNAME}\":\"$smlifname\"\t}\n" if ! grep -q "netapp_smlif_throughput_checker.sh $cluster"$ /var/spool/cron/root then echo "04,09,14,19,24,29,34,39,44,49,54,59 * * * * /etc/zabbix/zabbix_agentd.d/netapp_smlif_throughput_checker.sh $cluster" >> /var/spool/cron/root fi else while [ $whenlast -le $numberofsmlifs ] do smlifname=$(echo ${smlifarray[$index]}) printf "\t{\t\"{#SMLIFNAME}\":\"$smlifname\"\t},\n" index=$(( $index + 1 )) whenlast=$(( $whenlast + 1 )) if ! grep -q "netapp_smlif_throughput_checker.sh $cluster"$ /var/spool/cron/root then echo "04,09,14,19,24,29,34,39,44,49,54,59 * * * * /etc/zabbix/zabbix_agentd.d/netapp_smlif_throughput_checker.sh $cluster" >> /var/spool/cron/root fi done smlifname=$(echo ${smlifarray[$index]}) printf "\t{\t\"{#SMLIFNAME}\":\"$smlifname\"\t}\n" if ! grep -q "netapp_smlif_throughput_checker.sh $cluster"$ /var/spool/cron/root then echo "04,09,14,19,24,29,34,39,44,49,54,59 * * * * /etc/zabbix/zabbix_agentd.d/netapp_smlif_throughput_checker.sh $cluster" >> /var/spool/cron/root fi fi printf "\n\t]\n" printf "}\n"
2 thoughts on “Zabbix Custom Discovery Scripts – NetApp”