Aggregate Stats
#!/bin/bash # # script expects to be supplied the following values: # $1 = cluster name # cluster=$1 ssh monitor@$cluster statistics aggregate show -iterations 1 -interval 10 | sed -n '/aggr/,$p' | tr -s '[:space:]' ',' | sed -r 's/(.)('aggr')/\1\n\2/g' > '/tmp/'$cluster'_aggr_stats.txt'
Flexgroup & Infinite Volume Stats:
#!/bin/bash # # script expects to be supplied the following values: # $1 = cluster name # $2 = Flexgroup SVM name # $3 = Flexgroup name # # This script will work on flexgroups and ivols, the formatting # of the statistics command handles the wrapping of lines # caused by long constituent names and large numbers in # various metric columns. # # the latency code at the bottom had to check whether the # column figure is a number or not because it can sometimes # be a "-" count=0 total=0 cluster=$1 svm=$2 fg=$3 ssh monitor@$cluster statistics volume show -interval 10 -max 40 -iterations 1 -vserver $svm | sed -n '/'$fg'/,$p' | grep -v "_vol0" | tr -s '[:space:]' ',' | sed -r 's/(.)('$fg')/\1\n\2/g' | grep -v ^, | awk -F, '{print $3" "$4" "$5" "$6" "$7" "$8" "$9}' > '/tmp/'$cluster'_'$fg'_stats.txt' awk -F" " '{print $2}' '/tmp/'$cluster'_'$fg'_stats.txt' | paste -sd+ - | bc > '/tmp/'$cluster'_'$fg'_read_ops.txt' awk -F" " '{print $3}' '/tmp/'$cluster'_'$fg'_stats.txt' | paste -sd+ - | bc > '/tmp/'$cluster'_'$fg'_write_ops.txt' awk -F" " '{print $4}' '/tmp/'$cluster'_'$fg'_stats.txt' | paste -sd+ - | bc > '/tmp/'$cluster'_'$fg'_other_ops.txt' awk -F" " '{print $5}' '/tmp/'$cluster'_'$fg'_stats.txt' | paste -sd+ - | bc > '/tmp/'$cluster'_'$fg'_read_bps.txt' awk -F" " '{print $6}' '/tmp/'$cluster'_'$fg'_stats.txt' | paste -sd+ - | bc > '/tmp/'$cluster'_'$fg'_write_bps.txt' for i in $( awk -F" " '{print $7}' '/tmp/'$cluster'_'$fg'_stats.txt' ) do if [[ $i == ?(+|-)+([0-9]) ]] then total=$(echo $total+$i | bc ); ((count++)); else continue fi done echo "scale=4; ($total / $count) / 1000" | bc > '/tmp/'$cluster'_'$fg'_latency.txt'
Cluster Node Stats:
#!/bin/bash # # script expects to be supplied the following values: # $1 = cluster name # cluster=$1 # gather cluster node stats # write to file ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$1 statistics node show -iterations 1 -interval 10 > /tmp/$1_node_stats.txt
SnapMirror Lif Stats
#!/bin/bash # # script expects to be supplied the following values: # $1 = cluster name # cluster=$1 # gather cluster lif stats # write to file ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$1 statistics lif show -vserver $1 -iterations 1 -interval 10 > /tmp/$1_raw_lif_stats.txt # read file written by lif disco script to grep for the lif # write commar deliminated stats to lif file for item # prototype to read for graphing file='/tmp/'$1'_smlifs.txt' # stats are in order of: # # *Recv Sent # Recv Data Recv Sent Data Sent # Packet (Bps) Errors Packet (Bps) Errors # for i in $(cat $file) do grep $i '/tmp/'$1'_raw_lif_stats.txt' | tr -s '[:space:]' ',' | awk -F, '{print $3" "$4" "$5" "$6" "$7" "$8}' > '/tmp/'$1'_'$i'_stats.txt' done # code to calculate total read and total # write Bytes/s throughput: count=0 recp_total=0 recp_bps=0 file='/tmp/'$cluster'_smlifs.txt' for i in $(cat $file) do recp_bps=$( grep $i '/tmp/'$cluster'_raw_lif_stats.txt' | tr -s '[:space:]' ','| awk -F, '{print $4}' ) if [[ $recp_bps == ?(+|-)+([0-9]) ]] then recp_total=$(echo $recp_total+$recp_bps | bc ) ((count++)) else continue fi done echo $recp_total > '/tmp/'$cluster'_total_recp_sm_lif.txt' count=0 sent_total=0 sent_bps=0 for i in $(cat $file) do sent_bps=$( grep $i '/tmp/'$cluster'_raw_lif_stats.txt' | tr -s '[:space:]' ','| awk -F, '{print $7}' ) if [[ $sent_bps == ?(+|-)+([0-9]) ]] then sent_total=$(echo $sent_total+$sent_bps | bc ) ((count++)) else continue fi done echo $sent_total > '/tmp/'$cluster'_total_sent_sm_lif.txt'
One thought on “Zabbix Custom NetApp Statistics Gather Scripts”