Search This Blog

Tuesday, May 24, 2011

How to find VM guests having Network issue.

This has helped me for finding machines having network issues.

Such machines can then be tracked and further analyzed to find the root cause behind the network issue.

First You will need to login to your VM server.
Issue following command.
watch -n 1 -d netstat -i
Now observe Parameters in Bold.
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
If you find any of above (In bold only ) parameter value to be non 0 and continuously increasing Then this might be an indication of network problem in your vm guest.
Below is typical example of vm machine having network problem.
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
vif22.0 1500 0 0 0 0 0 0 0 39072827 0 BMRU
vif122.0 1500 0 0 0 0 0 0 0 37392429 0 BMRU
vif276.0 1500 0 0 0 0 0 0 0 22717649 0 BMRU

As you can observe Packet are getting dropped while transmitting. So all you need to do is
find the associated vm guests to that virtual interface.
This can be done using following command.

ps -ef | grep tap122.0 (Notice here vif is replaced with tap).
output will contain the name of vm guest having network issue.


You may use following script to find the vm guests.

#!/bin/bash

FIND=`netstat -i | grep vif* | awk '{ if ($10 > 100) print $1":"$10}'`

if [ -z "$FIND" ]
then
echo "No Packet drop (More than 100)"
exit
fi

for I in $FIND
do
Search=`echo $I |awk -F ":" '{print $1}' |awk -F "vif" '{print "tap"$2}'`
if [ -z "$FIND" ]
then
echo "No Interface Found"
exit
fi
ps -ef | grep $Search | grep -v grep | awk '{print $12}'
done

No comments:

Post a Comment