/[mon-modules]/fping+args.monitor
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /fping+args.monitor

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Wed Jul 10 08:53:22 2002 UTC revision 1.4 by dpavlin, Fri Jul 26 10:43:47 2002 UTC
# Line 1  Line 1 
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  #  #
5  # Jim Trocki, trockij@transmeta.com  # Jim Trocki, trockij@transmeta.com
6  #  #
7    # This module is modified to recognize hosts in format
8    # username[:password]@host/database ...
9    # which is used my pgsql.monitor (of course, just host is used) by
10    # Dobrica Pavlinusic, dpavlin@rot13.org
11    # http://www.rot13.org/~dpavlin/sysadm.html
12    #
13  # $Id$  # $Id$
14  #  #
15  #    Copyright (C) 1998, Jim Trocki  #    Copyright (C) 1998, Jim Trocki
# Line 56  my $END_TIME; Line 62  my $END_TIME;
62    
63  exit 0 if (@ARGV == 0);  exit 0 if (@ARGV == 0);
64    
65  open (IN, "$CMD @ARGV 2>&1 |") ||  my @hosts;
66    
67    # you can use hosts in format host:optional configuration parameters and
68    # this part will strip everything after hostname
69    foreach (@ARGV) {
70            if (m/^[^:]+:?[^\@]*\@([^\/]+)\/?.*/) {
71                    my $host = $1;
72                    push @hosts,$host if (! grep /^$host$/,@hosts);
73            } else {
74                    push @hosts,$_ if (! grep /^$_$/,@hosts);
75            }
76    }
77    
78    open (IN, "$CMD @hosts 2>&1 |") ||
79          die "could not open pipe to fping: $!\n";          die "could not open pipe to fping: $!\n";
80    
81  my @unreachable;  my @unreachable;
# Line 67  my @error;             # other errors which I'll gi Line 86  my @error;             # other errors which I'll gi
86  my @icmp;               # ICMP messages output by fping  my @icmp;               # ICMP messages output by fping
87  my %addr_unknown;  my %addr_unknown;
88    
89  my %want_host = map { $_ => 1 } @ARGV;  # hosts fping hasn't output yet  my %want_host = map { $_ => 1 } @hosts; # hosts fping hasn't output yet
90    
91  while (<IN>)  while (<IN>)
92  {  {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.26