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

Otávio Fernandes otaviof at gmail.com
Wed Mar 10 17:43:08 PST 2010


2010/3/10 Esdras Neto <esdras em gmail.com>:
> 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
>
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm

Esdras,

Você precisa ser mais específico sobre os problemas, com o que foi
descrito fica difícil ir além de críticas ao seu código.

Atenciosamente,

-- 
Otávio Fernandes <otaviof at gmail.com>
http://blog.emresumo.com


More information about the SaoPaulo-pm mailing list