Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/snmpfs/tools/netmon

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/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

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].