Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r4907 - developers/werner/bin (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-01-27 09:30:18 +0100 (Tue, 27 Jan 2009)
New Revision: 4907

Added:
   developers/werner/bin/snmp
Log:
Utility to track changes to /proc/net/snmp



Added: developers/werner/bin/snmp
===================================================================
--- developers/werner/bin/snmp                          (rev 0)
+++ developers/werner/bin/snmp  2009-01-27 08:30:18 UTC (rev 4907)
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+# Show /proc/net/snmp in a readable format. Optionally, show differences
+# after intervals.
+#
+# usage:  snmp
+#         snmp <interval>
+#
+$SNMP = "/proc/net/snmp";
+$LINE = 78;
+$continuous = $ARGV[0];
+do {
+    open(PROC,$SNMP) || die "open $SNMP: $!";
+    while (<PROC>) {
+       @label = split(" ");
+       @data = split(" ",<PROC>);
+       $tag = $label[0];
+       $j = 0;
+       $fields = $#label+1;
+       while ($j < $fields) {
+           $first = $second = "";
+           $put = 0;
+           for ($i = $j; $i < $fields; $i++) {
+               if (!$put || $last{$tag.$label[0]} != $data[0]+1 ||
+                 !$continuous) {
+                   $data = $continuous && $put && $more ?
+                     sprintf("%+d", $data[0]-$last{$tag.$label[0]}+1) :
+                     $data[0];
+                   $size = length($label[0]) > length($data) ?
+                     length($label[0]) : length($data);
+                   if (length($second)+$size > $LINE) {
+                       unshift(@label,$tag);
+                       unshift(@data,$tag);
+                       $i--;
+                       last;
+                   }
+                   $first .= sprintf("%-${size}s ",$label[0]);
+                   $second .= sprintf("%${size}s ",$data);
+                   $last{$tag.$label[0]} = $data[0]+1;
+                   $put++;
+               }
+               shift(@label);
+               shift(@data);
+           }
+           print "$first\n$second\n" if $put > 1;
+           $j = $i;
+       }
+    }
+    if ($continuous) {
+       sleep($continuous);
+       print (("-"x$LINE)."\n");
+    }
+    $more = 1;
+}
+until (!$continuous);


Property changes on: developers/werner/bin/snmp
___________________________________________________________________
Name: svn:executable
   + *




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to