<div class="gmail_quote">Boa noite, <br><br>To com umas dúvidas e o google não quer me ajudar :/<br><br>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.<br>
<br>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.<br><br>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!<br>
<br>while (<>) {<br> $alive = ping(host => $HOST1, timeout => 4);<br> print "$HOST1 is alive\n" if $alive;<br><br> if (!$alive) { <br> <br> my $num_alive = 0;<br> foreach (@hosts) {<br>
$alive = ping(hostname => $_, timeout => 3);<br> print "$_ is alive!\n" if $alive;<br> $num_alive++ if $alive;<br><br> }<br> <br> print "$num_alive hosts are alive.\n"; <br>
if ($num_alive == '0') {<br>
<br> my %mail = (<br> To=>"$mail_destination",<br> From=>"$from",<br> Subject=>"Network Outage",<br> Message=>"This is an automatic alert. The link is down.",<br>
smtp=>"$smtp_server",<br> auth=>{user=>$from, pass=>$password, method=>'PLAIN'}<br> );<br><br> sendmail(%mail) or die $Mail::Sendmail::error; <br> }<br>
<br>
} <br>sleep $TBP;<br>}<br><font color="#888888"><br><br><br clear="all"><br>-- <br><a href="http://www.alvespassos.com" target="_blank">http://www.alvespassos.com</a><br>Sharing things that we cannot buy.<br>Mobile +353 (0)83 4005868<br>
</font></div>