File: 02-interface.patch

package info (click to toggle)
ethstats 1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 96 kB
  • ctags: 9
  • sloc: perl: 269; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Description: Allow a single interface to be watched.
Author: Peter Pentchev <roam@ringlet.net>
Last-Modified: 2010-04-16

--- a/ethstats.pl
+++ b/ethstats.pl
@@ -27,14 +27,17 @@
 #  eth1: 2039952   21982    6    0    0     6          0         0 47000710   34813    0    0    0   821       0          0
 
 my %opts;
+my $iface;
 
-getopts('n:t', \%opts) or die("Usage: ethstats [-t] [-n period]\n");
+getopts('i:n:t', \%opts) or
+    die("Usage: ethstats [-t] [-i iface] [-n period]\n");
 $addtime = 1 if defined($opts{'t'});
 if (defined($opts{'n'})) {
 	die("The period must be a positive integer\n")
 	    unless $opts{'n'} =~ /^([1-9]\d*)$/;
 	$period = $1;
 }
+$iface = $opts{'i'}; # also works if it isn't defined
 
 $op = $period;
 $period = 1;
@@ -68,6 +71,7 @@
     chop($l);
     ($dev, $rest) = split(/:/, $l);
     $dev  =~ s/\s//g;
+    next if defined($iface) && $dev ne $iface;
     $rest =~ s/^\s+//;
     @devarr = split(/\s+/, $rest);
     $bytesin{$dev} = @devarr[0]; $bytesout{$dev} = @devarr[8];