Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Remote Monitoring using multi-threading

by TGI (Parson)
on Mar 15, 2010 at 17:27 UTC ( #828740=note: print w/replies, xml ) Need Help??


in reply to Remote Monitoring using multi-threading

Yes, you can--but you will be better off using an event-loop based library like POE or AnyEvent.

jfroebe's suggestion to use POE is on solid ground. There are many libraries for client/server interaction for POE. This sort of task was what lead to POE's development. POE is bit to wrap your head around, but it is powerful and works well. I've written several monitoring scripts that run for months at a time without problems on a Windows XP host.

AnyEvent is newer entry to the world of event loops in Perl. I've seen many positive comments, but have not tried it myself. The POD also links to other event loops.

Coro is another option, it bills itself as "the only real threads in perl". I've never tried it, so I can't give any review.


TGI says moo

  • Comment on Re: Remote Monitoring using multi-threading

Replies are listed 'Best First'.
Re^2: Remote Monitoring using multi-threading
by BrowserUk (Pope) on Mar 15, 2010 at 17:42 UTC
    I've written several monitoring scripts that run for months at a time without problems on a Windows XP host.

    Got one that you'd care to share for education purposes?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Sadly, even though I wrote the programs, the code isn't mine to share.

      But they are pretty much vanilla POE. One even uses POE::Wheel::Run to control an external process--PWR had problems on Win32 in the past.

      The later program was finished in 2007. It's still running now, last system reboot was in December, caused by a crappy USB serial port driver.

      The samples in the docs and on the POE site are a good starting place. I also recommend the Programming POE presentation--it's a bit old, but has good info.

      I hope that this info makes up a bit for being unable to share.


      TGI says moo

        Sadly, even though I wrote the programs, the code isn't mine to share.

        Sadly, that always seems to be the case with POE code.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Remote Monitoring using multi-threading
by ikegami (Pope) on Mar 15, 2010 at 18:09 UTC

    Coro is a cooperative multithreading environment that uses the same interface as threads. It integrates into other event loops such as AnyEvent's.

    You could use Coro to do some unrelated processing while AnyEvent::FastPing is busy pinging machines. (It appears you can do related processing in a registered callback.)

    Update: Very bad example removed.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2020-10-29 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (270 votes). Check out past polls.

    Notices?