diff options
Diffstat (limited to 'net_if')
-rwxr-xr-x | net_if | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -28,14 +28,14 @@ sub msg ($@) { } # Check the status of the given network interface and return -# three lists the interfaces sorted by status (up, down, error). -# This resolves interfaces groups, but only return the interfaces -# that are up. +# three lists of the interfaces sorted by status (all, down, error). +# This does resolves interfaces groups automaticaly and returns +# the member interfaces. # # parameter: # list of interfaces sub get_if_status (@) { - my (@up, @down, @error); + my (@all, @down, @error); while (@_) { # untaint interface name @@ -59,19 +59,15 @@ sub get_if_status (@) { while (<IFCONFIG>) { # parse ifconfig output: if ($_ =~ m/^([-a-v0-9]+): flags=([0-9]+)</) { - if ($2 & 1) { - push(@up, $1); - } - else { - push (@down, $if) if $1 eq $if; - } + push(@all, $1); + push(@down, $1) unless ($2 & 1); } } close(IFCONFIG) or push(@error, $if); } - return (\@up, \@down, \@error); + return (\@all, \@down, \@error); } # Get the byte conters for incomming and outgoing packages. @@ -125,7 +121,7 @@ sub print_stats ($) { } -my ($up, $down, $error) = get_if_status(@ARGV); +my ($interfaces, $down, $error) = get_if_status(@ARGV); if (@$error) { $error = join ", ", @$error; @@ -138,7 +134,7 @@ if (@$down) { } my $stats = {}; -for my $if (@$up) { +for my $if (@$interfaces) { $stats->{$if} = get_if_stats($if); } |