summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-01-10 21:56:14 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-10 21:56:14 +0100
commit824e8aee6addbd53d0ccb41515d936b475e955ce (patch)
tree6e14f81a6a72678ad4a59886e6a673d0e1749665
parent97d4a8839b90374b06605ac494589faf88e4e746 (diff)
downloadnet_if-824e8aee6addbd53d0ccb41515d936b475e955ce.tar.gz
net_if-824e8aee6addbd53d0ccb41515d936b475e955ce.tar.bz2
net_if-824e8aee6addbd53d0ccb41515d936b475e955ce.zip
style changes
-rwxr-xr-xnet_if17
1 files changed, 8 insertions, 9 deletions
diff --git a/net_if b/net_if
index 5b6e845..8dee003 100755
--- a/net_if
+++ b/net_if
@@ -61,7 +61,7 @@ sub get_if_status (@) {
}
sub get_if_stats ($) {
- my $if = shift @_;
+ my $if = shift;
my $stats = {};
open(PFCTL, "-|", "pfctl", "-vvsI", "-i", $if);
@@ -85,14 +85,13 @@ sub get_if_stats ($) {
}
sub print_stats ($) {
- my ($stats, $count, $perfdata, $if);
- $stats = shift @_;
+ my $stats = shift;
+ my ($count, $perfdata);
$count = keys %$stats;
$perfdata = "";
- for (keys %$stats) {
- $if = $_;
- for (qw( in4 out4 in6 out6 )) {
+ for my $if (keys %$stats) {
+ for (qw( in4 out4 in6 out6 )) {
$perfdata = "$perfdata $if-$_=$stats->{$if}->{$_};";
}
}
@@ -100,6 +99,7 @@ sub print_stats ($) {
msg('ok', "$count interfaces |$perfdata");
}
+
my ($up, $down, $error) = get_if_status(@ARGV);
if (@$error) {
@@ -113,9 +113,8 @@ if (@$down) {
}
my $stats = {};
-while (@$up) {
- my $if = shift @$up;
+for my $if (@$up) {
$stats->{$if} = get_if_stats($if);
}
-print_stats($stats)
+print_stats($stats);