[SP-pm] Net::Ping::External Win/Unix

Esdras Neto esdras at gmail.com
Wed Mar 10 15:27:01 PST 2010


Boa noite,

To com umas dúvidas e o google não quer me ajudar :/

Estou usando o modulo Net::Ping::External pois preciso fazer um script que
monitore a conexão com a internet que funcione tanto no Windows quanto no
Linux.

O projeto é simples, monitorar um host externo se esse host parar de
responder testar com outros hosts e caso fique sem resposta muda a rota e
manda um email pros admin.

Mas o net::ping::external parece nem sempre funcionar no Linux e no windows
ele pede interação. Alguem da uma luz? Segue o script. vlwz!

while (<>) {
    $alive = ping(host => $HOST1, timeout => 4);
    print "$HOST1 is alive\n" if $alive;

  if (!$alive) {

   my $num_alive = 0;
   foreach (@hosts) {
     $alive = ping(hostname => $_, timeout => 3);
     print "$_ is alive!\n" if $alive;
     $num_alive++ if $alive;

   }

   print "$num_alive hosts are alive.\n";
   if ($num_alive == '0') {

      my %mail = (
          To=>"$mail_destination",
          From=>"$from",
          Subject=>"Network Outage",
          Message=>"This is an automatic alert. The link is down.",
          smtp=>"$smtp_server",
          auth=>{user=>$from, pass=>$password, method=>'PLAIN'}
          );

   sendmail(%mail) or die $Mail::Sendmail::error;
   }

  }
sleep $TBP;
}




-- 
http://www.alvespassos.com
Sharing things that we cannot buy.
Mobile +353 (0)83 4005868
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20100310/056f9d3d/attachment.html>


More information about the SaoPaulo-pm mailing list