Commit 2ca230cc authored by Peter Pentchev's avatar Peter Pentchev

Use the warnings pragma with all warnings fatal.

parent 786a6167
......@@ -12,7 +12,7 @@ Change log for ethstats, the network traffic statistics utility
- add a simple Makefile
- declare a 5.010 minimum Perl version dependency
- update the Perl source style a bit:
- use strict mode
- use strict mode and the warnings pragma
1.0 (unknown)
- released into the public domain by Drew Strieb
......
......@@ -2,6 +2,7 @@
use v5.010;
use strict;
use warnings FATAL => qw(all);
use Getopt::Std;
......@@ -116,7 +117,7 @@ sleep $period;
while(1) {
convert();
print time()." " if($addtime==1);
print time()." " if $addtime;
if ($numdevs > 1) {
print acolor 'yellow';
printf "total: %7.2f Mb/s In %7.2f Mb/s Out", $tkbin, $tkbout;
......@@ -149,8 +150,8 @@ sub convert {
next if defined($iface) && $dev ne $iface;
$rest =~ s/^\s+//;
my @devarr = split(/\s+/, $rest);
$bytesin{$dev} = @devarr[0]; $bytesout{$dev} = @devarr[8];
$packin{$dev} = @devarr[1]; $packout{$dev} = @devarr[9];
$bytesin{$dev} = $devarr[0]; $bytesout{$dev} = $devarr[8];
$packin{$dev} = $devarr[1]; $packout{$dev} = $devarr[9];
}
close(IN);
......@@ -164,8 +165,8 @@ sub convert {
next if($dev eq "lo");
$numdevs++;
# packets in/out
my $packdiffin = ($packin{$dev} - $opackin{$dev});
my $packdiffout = ($packout{$dev} - $opackout{$dev});
my $packdiffin = ($packin{$dev} - ($opackin{$dev} // 0));
my $packdiffout = ($packout{$dev} - ($opackout{$dev} // 0));
$packdiffin += 4294967296 if($packdiffin<0);
$packdiffout += 4294967296 if($packdiffout<0);
$opackin{$dev} = $packin{$dev};
......@@ -174,8 +175,8 @@ sub convert {
$packout{$dev} = $packdiffout / $period;
# bytes in/out
my $diffin = ($bytesin{$dev} - $obytesin{$dev});
my $diffout = ($bytesout{$dev} - $obytesout{$dev});
my $diffin = ($bytesin{$dev} - ($obytesin{$dev} // 0));
my $diffout = ($bytesout{$dev} - ($obytesout{$dev} // 0));
$diffin += 4294967296 if($diffin<0);
$diffout += 4294967296 if($diffout<0);
$obytesin{$dev} = $bytesin{$dev};
......
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