Hi All,
Need to run the netstat -i command on the list of hosts and check if "Ierrs" and "Oerrs" has value greaterthan 0.
for Ex: below output, driver bge1 and bge3 has Oerrs and Ierrs value > 0, So, script should report saying
"Netstat status for $host, driver bge1 has Oerrs = 20, Failed"
"Netstat status for $host, driver bge3 has Ierrs = 10, Failed"
Netstat -i ouptut :
root@1Q-01 # netstat -i
Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue
lo0 8232 loopback localhost 12167130 0 12167130 0 0 0
bge0 1500 1Q-01 1Q-01 6118243 0 1204595 0 0 0
bge1 1500 1Q-01-DFT 1Q-01-DFT 6572109 0 2907975 20 0 0
bge3 1500 1Q-01-BD1 1Q-01-BD1 3416729 10 89438 0 0 0
main script :
Serverlist=../Serverlist
echo "Running netstat status"
cat $Serverlist | grep -v '#'
if [ ! $? ]; then
logIt "error no Serverlist"
exit
else
list=`cat $Serverlist | sort | grep -v '#' | awk '{print $2}' `
export list
for ip in $list; do
check=$STATUS_OK;
host=`grep -v "#" $Serverlist | grep -w $ip | awk '{print $1}'`
netstat -i | head -5 | tail -4 | awk '{ print $1 " " $6 " " $8 }'| while read output;
do
driver=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
Ierrs=$(echo $output | awk '{ print $2 }' )
Oerrs=$(echo $output | awk '{ print $3 }' )
if [ $Ierrs -ge 0 ]; then
echo "Netsat status for $driver, has input error $Ierrs on $host as on $(date)"
fi
if [ $0errs -ge 0 ]; then
echo "Netsat status for $driver, has output error $Oerrs on $host as on $(date)"
fi
done
done
fi
Serverlist file has 2 hosts ip address/name
1Q-01 10.11.122.10
2Q-02 10.11.122.13
Problem is am facing is, i don't know how to run this script or netstat command on each hosts listed in serverlist file.
Am running this main script from management server which has access to all the hosts which are listed in serverlist file.
Anyhelp much appriciated.
Many Thanks,
O