> I need some assistance.
>
> I wrote a script that takes an array of IP addresses, and in a foreach
> loop uses a subroutine to make a few SNMP connections, and writes
> results to a flat file.(snipet below)
>
> For 1000 IP addresses, it takes 17 minutes. I wonder if there's a way
> to fork 10-20 (at a time) (subroutine) processes so I can process 10
> devices at a time.
>
> I ask because some of our locations have 4000+ devices, and would take
> well over an hour to gather data linearly.
>
> -Mike
>
> Loop that calls sub:
>
> foreach $ip (@cmip){
> if($ip ne '0.0.0.0'){
> &pollmodem($ip,$com);
> }
> }
>
Sure, depends on how complex you want to get, and what &pollmodem
actually does. Also note that generally we drop the & in Perl 5 and that
you should be using 'strict' and 'warnings'.
perldoc perlipc
perldoc -f fork
perldoc -f wait
perldoc -f waitpid
perldoc -f select
Are good places to start. You might also consider POE,
http://poe.perl.org
And I am assuming you are using something like Net::SNMP to handle the
remote calls? Conveniently it appears to provide a non-blocking object
behavior that may make it possible to not have to roll your own, though
I haven't specifically used the module before, check its docs here:
http://search.cpan.org/~dtown/Net-SNMP-4.1.2/lib/Net/SNMP.pm
Specifically see if example 4 provides you close to what you need,
http://search.cpan.org/~dtown/Net-SNMP-4.1.2/lib/Net/SNMP.pm#4._Non-blocking_SNMPv1_get-request_for_sysUpTime_on_multiple_hosts
HTH,
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>