Scrat has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Time::Local; use Net::Ping; my ($time); my @hostnames = ("10.0.0.1"); my $p = Net::Ping->new("icmp"); my $hostname; print "\nWriting data to ping.log\n"; print "Press CTRL-C to exit\n"; while(1) { foreach my $hostname (@hostnames) { $time = localtime; open (LogFile, ">>ping.log") || die "Sorry, cannot open logfil +e\n"; print (LogFile "$time - "); print (LogFile "$hostname is "); print (LogFile "NOT ") unless $p->ping($hostname, 2); print (LogFile "reachable.\n"); close Logfile; sleep(5); } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Ping log terminates unexpectedly
by AcidHawk (Vicar) on Mar 23, 2006 at 14:07 UTC | |
by Scrat (Monk) on Mar 23, 2006 at 14:30 UTC | |
Re: Ping log terminates unexpectedly
by eXile (Priest) on Mar 23, 2006 at 14:55 UTC | |
by nimdokk (Vicar) on Mar 23, 2006 at 15:47 UTC | |
by gawatkins (Monsignor) on Mar 23, 2006 at 18:10 UTC | |
Re: Ping log terminates unexpectedly
by monkey_boy (Priest) on Mar 23, 2006 at 13:49 UTC | |
Re: Ping log terminates unexpectedly
by timos (Beadle) on Mar 23, 2006 at 13:50 UTC |