> List, > > I have the following while loop that goes and pings a whole heap of servers around our company. If one is broken or doesn't respond to the ping my code e-mails me the results of which server isn't responding. This all works well but I really need it to be able to keep pinging all the servers and if one breaks I need the hostname of that to be stored in hash. Ie a new hash. > > First hash (Ping all these servers) > > %first_hash ( > > 1server.com' => 'Server1', > 2server.com' => 'Server2', > 3server.com' => 'Server3', > 4server.com' => 'Server4' > > } > > The script pings all the above servers. Then if one doesn't respond and nothing is returned. Then I create another hash... > > %second_hash; #server that didn't resond to ping request. > > This is all easy but I need my script to continue pinging the other servers every 4 minutes. And also keep checking the servers in the second hash for con ectivity and if they are conected I need the key from the second hash placed back into the first hash because it is live again. > > I just need a quick tutorial on how I would go about this ? > > Hope this makes sense :) > > Regards, > > Dan > > > while (1) { > $sleep = 5; #Sleep time in seconds. Have this at around 5 minutes or 300 seconds > $server = 'mail.server.com'; #Mail server. Change to suit other environments > $p = Net::Ping->new("icmp", 1, 2); #Ping object. Uses icmp protocal > foreach $host (sort keys (%host)) { > unless ($p->ping($host)) { > print "$host hello \n"; > $name = $host{$host}; #Name of the machine/host > %mail = ( To => '[EMAIL PROTECTED]', > From => '[EMAIL PROTECTED]', > Subject => $subject, > Message => $message, > SMTP => $server, > ); > sendmail(%mail) or die $Mail::Sendmail::error; > delete $host{$host}; > } > } > sleep $sleep; > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]