Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Short pinging script isn't working

by andyford (Curate)
on Nov 21, 2007 at 17:52 UTC ( [id://652185]=note: print w/replies, xml ) Need Help??


in reply to Short pinging script isn't working

I ran this on Windows (XP Pro) with ActiveState Perl 5.8.8 and it worked just by changing the target to my local host. Do you have the Windows firewall running?

As far as the timeout goes, you already have it in your call to the 'ping' function:

$p->ping($target, 2)
gives a 2 second timeout. Or as jbert pointed out ('ctor' means 'constructor' means Net::Ping->new), you can specify the timeout in your 'new' call.

To repeat every 5 seconds I think you have to get outside Net::Ping. Here's a rough untested estimate of one way to do it without even trying to take into account the time that it actually takes to do the ping:

while (1) { $p->ping($target, 2); sleep 5; }

After that, if you want to initiate the ping on every fifth second you could try Schedule::Cron. Then, when you get tired of reinventing the monitoring wheel, install Nagios for some serious pinging that can result in an annoying sound coming from your pager at 2AM.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://652185]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-25 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found