Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
| 1 | #!/usr/bin/perl |
| 2 | # Show /proc/net/snmp6 continuously. Loosely based on |
| 3 | # http://svn.openmoko.org//developers/werner/bin/snmp |
| 4 | # |
| 5 | # usage: snmp6 <interval> |
| 6 | # |
| 7 | $SNMP = "/proc/net/snmp6"; |
| 8 | $LINE = 78; |
| 9 | $continuous = $ARGV[0]; |
| 10 | do { |
| 11 | open(PROC, $SNMP) || die "open $SNMP: $!"; |
| 12 | while (<PROC>) { |
| 13 | die unless /^(\S+)(\s+)(\d+)$/; |
| 14 | if (!defined $last{$1}) { |
| 15 | print; |
| 16 | } elsif ($last{$1} != $3) { |
| 17 | printf "$1$2%+d\n", $3-$last{$1}; |
| 18 | } |
| 19 | $last{$1} = $3; |
| 20 | } |
| 21 | close(PROC); |
| 22 | |
| 23 | if ($continuous) { |
| 24 | sleep($continuous); |
| 25 | print (("-"x$LINE)."\n"); |
| 26 | } |
| 27 | $more = 1; |
| 28 | } |
| 29 | until (!$continuous); |
| 30 |
Branches:
master
