<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 (&lt;&gt;) {<br>    $alive = ping(host =&gt; $HOST1, timeout =&gt; 4);<br>    print &quot;$HOST1 is alive\n&quot; if $alive;<br><br>  if (!$alive) {       <br>  <br>   my $num_alive = 0;<br>   foreach (@hosts) {<br>

     $alive = ping(hostname =&gt; $_, timeout =&gt; 3);<br>     print &quot;$_ is alive!\n&quot; if $alive;<br>     $num_alive++ if $alive;<br><br>   }<br>   <br>   print &quot;$num_alive hosts are alive.\n&quot;;   <br>
   if ($num_alive == &#39;0&#39;) {<br>
<br>      my %mail = (<br>          To=&gt;&quot;$mail_destination&quot;,<br>          From=&gt;&quot;$from&quot;,<br>          Subject=&gt;&quot;Network Outage&quot;,<br>          Message=&gt;&quot;This is an automatic alert. The link is down.&quot;,<br>

          smtp=&gt;&quot;$smtp_server&quot;,<br>          auth=&gt;{user=&gt;$from, pass=&gt;$password, method=&gt;&#39;PLAIN&#39;}<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>