Root/bin/snmp6

Source at commit a27d1958fb3a238dcdc9fe15e0d0649448409129 created 5 years 7 months ago.
By Werner Almesberger, ircstat/ML: update for 12/2013
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];
10do {
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}
29until (!$continuous);
30

Archive Download this file

Branches:
master



interactive