#!/bin/bash
#!/usr/bin/expect
gw=`ip ro show| grep 'default'|awk '{print $3}'`
lanip=`ip addr show eth1|grep 'inet'|awk '{print $2}'|cut -d/ -f1`
wanip=`ip addr show eth0|grep 'inet'|awk '{print $2}'|cut -d/ -f1`
grep -o "src=.*dport=[0-9]\{1,5\}" /proc/net/ip_conntrack |awk '{print $1}'|awk -F= '{print $2}' |sort |uniq -c | sort -n | awk '(sum += $1); END{print "sum = "sum}'|tail -10
# script name : netwatch.exp
# save the same path with check_conn.sh
#set ip [lindex $argv 0]
#set timeout 1
#spawn ping -c 1 -s 1 $ip
#expect {
# "%0 packet loss" {
# exit 0
# }
# timeout {
# exit 1
# }
#}
./netwatch.exp $lanip >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "ping lanip $lanip Ok"
else
echo "lanip $lanip seems doesn't work"
fi
./netwatch.exp $wanip >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "ping wanip $wanip Ok"
else
echo "wanip $wanip seems doesn't work"
fi
./netwatch.exp $gw >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "ping gw $gw Ok"
else
echo "gw $gw can't reach!!!!!!!!!!!!"
fi
|