Commit fd57f022 authored by Peter Pentchev's avatar Peter Pentchev

Use Getopt::Std and add the -n interval option.

parent a20b78cb
Change log for ethstats, the network traffic statistics utility
1.0.1 not yet ;)
- use Getopt::Std for command-line option processing
- add the -n interval option to specify the polling interval
1.0 (unknown)
- released into the public domain by Drew Strieb
......
#!/usr/bin/perl
use Getopt::Std;
# I received this without copyright, but have since been told by the owner
# that it is released into the public domain.
#
......@@ -24,7 +26,15 @@ $period = 10;
# eth0: 1217210 9400 0 0 0 8 0 11 1207648 8019 0 0 0 0 0 0
# eth1: 2039952 21982 6 0 0 6 0 0 47000710 34813 0 0 0 821 0 0
$addtime = 1 if($ARGV[0] eq "-t");
my %opts;
getopts('n:t', \%opts) or die("Usage: ethstats [-t] [-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;
}
$op = $period;
$period = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment