Tuesday, June 18, 2013

Scripts to check Network Stats in a Nutanix Cluster.

Nutanix cluster captures sysstats every often so you can use it graph , using our Nagios tool and run scripts against it
If there is any network latency and unreachable, you use the following script:
Here is the script that checks the ping_hosts.INFO


 for i in `svmips` ; do (echo ; echo "SVM: $i" ; ssh $i cat data/logs/sysstats/ping_hosts.INFO | egrep -v "IP : time" | \
awk '/^#TIMESTAMP/ || $3>13.00 || $3=unreachable' | egrep -B1 " ms|unreachable" | egrep -v "\-\-" ); done

This will print if there is any unreachable or ping response taking more than 13 ms.


Here is another script that prints network utilization of above 1.2Gbps ( you can use Nagios to graph but
 it does not combine both Rx and Tx Bps


for i in `svmips`; do (echo CVM:$i; ssh $i cd data/logs/sysstats;cat sar.INFO |egrep "eth0"| awk '/^#TIMESTAMP/ || \
$6 > 30000 || $7 > 30000' | egrep -B1 " eth0" | awk '{print $1,$2,$6,$7,($6+$7)/1024}'|awk '$5 > 120');done

Here is the modification of above script to check Average BW during certain time: - 6pm to 12 midnight.


for i in `svmips`; do (echo CVM:$i; ssh $i cat data/logs/sysstats/sar.INFO |egrep "eth0"| awk '/^#TIMESTAMP/ || \
$6 > 30000 || $7 > 30000' | egrep -B1 " eth0" | awk '{print $1,$2,$6,$7,($6+$7)/1024}');done |\
 egrep "^06|^07|^08|^09|^10|^11"|grep PM|awk '{sum+=$5} END { print "Average = ",sum/NR}'
Or find the total number of times,network utilization crossed 2G between certain time
for i in `svmips`; do (echo CVM:$i; ssh $i cd data/logs/sysstats;cat sar.INFO |egrep "eth0"| awk '/^#TIMESTAMP/ || \
$6 > 30000 || $7 > 30000' | egrep -B1 " eth0" | awk '{print $1,$2,$6,$7,($6+$7)/1024}'|awk '$5 > 200');done|\
 grep -v CVM|wc-l 


Used this script to verify if the customer network usage dropped to 1G(between 2pm to 3pm)

for i in `svmips`; do (echo CVM:$i; ssh $i cat data/logs/sysstats/sar.INFO |egrep "eth0"| awk '/^#TIMESTAMP/ || \
$6 > 50000 || $7 > 50000' | egrep -B1 " eth0" | awk '{print $1,$2,$6,$7,($6+$7)/1024}');done | egrep "^02"|grep PM

1 comment: