#!/bin/rc
NET=$1
NOW=`{date -n};
mount /srv/snmp /n/gw gw
test1=`{cat /n/gw/ifDescr,ifIndex,ifPhysAddress,ifInOctets,ifOutOctets | table.rc 6 | grep $NET | awk '{print $4 $5}' | sed 's/[\(\)]/ /g'}
sleep 1;
test2=`{cat /n/gw/ifDescr,ifIndex,ifPhysAddress,ifInOctets,ifOutOctets | table.rc 6 | grep $NET | awk '{print $4 $5}' | sed 's/[\(\)]/ /g'}
echo $test1 T $test2 | sed 's/ T /\n/g' | awk -v 'time='^$NOW 'BEGIN { bin=0;bout=0} {
lastbin=bin;
lastbout=bout;
bin=$1;
bout=$2;
} END {
printf("%d %d %d\n",time,bin-lastbin, bout-lastbout);
}' >> /sys/log/mon/netmon.$1
unmount /n/gw
|