Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Does Net::Ping have concurrency issues?

by ehdonhon (Curate)
on May 30, 2003 at 20:07 UTC ( [id://261931]=note: print w/replies, xml ) Need Help??


in reply to Does Net::Ping have concurrency issues?

Suggestions:

  • Use Parallel::ForkManager
  • splice off a segment of @targets for each child instead of only doing one target per child. It will be more efficient due to the overhead of forking processes.
  • Comment on Re: Does Net::Ping have concurrency issues?

Replies are listed 'Best First'.
Re: Re: Does Net::Ping have concurrency issues?
by phydeauxarff (Priest) on May 30, 2003 at 21:19 UTC
    We had a similar issue where we needed to run through about 40 thousand IP addresses to make sure folks weren't using IP's not assigned to them....Using Parallel::ForkManager made this much simpler.

    For more detail on the method I used to setup the mySQL connection check out Re: Re: Re: Secure ways to use DBI?

    The code below pulls the IP's from a database and runs through them 50 at a time...it runs quite well on a Ultra-Sparc 60

    #!/usr/bin/perl use Net::Ping; use DBI (); use Data_config; use Parallel::ForkManager; my $MAX_PROCESSES = 50; ## Create a database handle ## ## The actual user/pass info is in Data_config.pl ## my $DSN = "DBI:$DBDRIVER:database=$DATABASE:host=$DBHOST:port=$DBPORT" +; my $DBH = DBI->connect($DSN, $USERNAME, $PASSWORD, { RaiseError => 1, PrintError => 1 }); $|=1; my $PING_TIMEOUT = 2; $pm = new Parallel::ForkManager($MAX_PROCESSES); foreach my $IP (map { $_->[0] } @{ $DBH->selectall_arrayref( "SELECT ip_address FROM ips" )}) { # Forks and returns the pid for the child: my $pid = $pm->start and next; my $ping = new Net::Ping ("icmp"); if ($ping->ping($IP, $PING_TIMEOUT)) { print "$IP Gotcha! \n"; } else { print "$IP \n"; } $ping->close(); $pm->finish; # Terminates the child process } $pm->wait_all_children;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found