Greetings :)

I have a challenge for which I _think_ the use of threads is possibly the answer. However, as threading is completely new and unchartered (and somewhat daunting) territory for me, I felt that it may be wise to consult the monks before diving in and getting a mouthful ;)

My problem can be summarised as follows:

In other words....

# psuedocode foreach my $foo (%controllers) { foreach (@{$controllers{$foo}{access_points}}) { Is $_ alive? } }

Currently, I run my test every 20 minutes, and it takes ~15 minutes to test every single AP. Because I need to allow for a time out, the run time will increase or decrease depending on the number of AP's detected as off line on any given run. Clearly, this is not scalable, and I'm going to have problems as the number of devices to be tested increases. So I need to find a more efficient way to do it.

I've done a bit of reading on Perl threads, and in particular the threads tutorial, and I suspect that what I'm looking for is a "Work Crew" model. But again, I'm not sure, so I'm seeking your collective advice...

Many thanks,
Darren :)

PS. I probably should make mention of the fact that my current code is implemented as an extension for the Big Brother Network Monitoring Tool. That is, the reports that my code produces are fed into Big Brother.

Update: I feel quite overwhelmed by the number of responses and the variety of potential solutions offered. Proves once again the TIMTOWTDIness of Perl, and the value of Perlmonks as a community ('sif we didn't know these already). For the time being, I have a very quick & dirty implementation of Parallel:ForkManager working, which has solved my immediate problem. However, I fully intend to investigate most of the other solutions offered. So a big thank you to all those that offered their advice and comment :)


In reply to Testing many devices - are threads the answer? by McDarren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.