1 |
#!/usr/bin/perl |
#!/usr/bin/perl -w |
2 |
# |
# |
3 |
# Return a list of hosts which not reachable via ICMP echo |
# Return a list of hosts which not reachable via ICMP echo |
4 |
# |
# |
56 |
|
|
57 |
exit 0 if (@ARGV == 0); |
exit 0 if (@ARGV == 0); |
58 |
|
|
59 |
open (IN, "$CMD @ARGV 2>&1 |") || |
my @hosts; |
60 |
|
|
61 |
|
# you can use hosts in format host:optional configuration parameters and |
62 |
|
# this part will strip everything after hostname |
63 |
|
foreach (@ARGV) { |
64 |
|
if (m/^[^:]+:?[^\@]*\@([^\/]+)\/?.*/) { |
65 |
|
my $host = $1; |
66 |
|
push @hosts,$host if (! grep /^$host$/,@hosts); |
67 |
|
} else { |
68 |
|
push @hosts,$_ if (! grep /^$_$/,@hosts); |
69 |
|
} |
70 |
|
} |
71 |
|
|
72 |
|
open (IN, "$CMD @hosts 2>&1 |") || |
73 |
die "could not open pipe to fping: $!\n"; |
die "could not open pipe to fping: $!\n"; |
74 |
|
|
75 |
my @unreachable; |
my @unreachable; |
80 |
my @icmp; # ICMP messages output by fping |
my @icmp; # ICMP messages output by fping |
81 |
my %addr_unknown; |
my %addr_unknown; |
82 |
|
|
83 |
my %want_host = map { $_ => 1 } @ARGV; # hosts fping hasn't output yet |
my %want_host = map { $_ => 1 } @hosts; # hosts fping hasn't output yet |
84 |
|
|
85 |
while (<IN>) |
while (<IN>) |
86 |
{ |
{ |