Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

What I want to do is the following (in wierd prototype):

main: our %ssh (hash of active ssh sessions, Net::OpenSSH) read file with list of vm's to turn off. for each line with 1 or more vm's start thread1 kill_all_thread1 after timeout for each line with 1 or more vm's start thread2 thread1: @vms = split (',',$0) for each vm gather all info needed if (! exists $ssh{vm-manager} { $ssh{vm-manager} = Net::OpenSSH->new(vm-manager) (stdout,stderr)=$ssh{vm-manager}->capture2(request vm to stop) *check errors* (status,stderr)=$ssh{vm-manager}->capture2(request status vm) while (status != dead) { (status,stderr)=$ssh{vm-manager}->capture2(request status + vm) sleep some time } thread2: @vms = split (',',$0) for each vm gather all info needed if (! exists $ssh{vm-manager} { $ssh{vm-manager} = Net::OpenSSH->new(vm-manager) (stdout,stderr)=$ssh{vm-manager}->capture2(pull plug vm)

The current solution with ksh has several problems:

  • It's all sequential.
    Not a problem with 2-3 vm's, but the total we have is 70+.
  • It initiates a new ssh session per command issued.
    When trying to split the list into seperate commands, the vm-manager gets swamped with ssh sessions. (old hardware, no budget to replace with something fast enough to handle lots of ssh logins)
  • Most vms can be stopped parallel, but some combination of vms may only be stopped in sequence. (application requirements)
  • Sometimes a vm refuses to die within the allotted time.
  • When a vm refuses to die and there are dependent vms, the nice version has to be killed and the rude version has to be started for the same set.
    I.e. in list lpar1,lpar2 when lpar1 refuses to die, it's not allowed to stop lpar2 and then kill lpar1, but it's required to kill lpar1 and then stop/kill lpar2.

Now I'm typing this, I'm thinking of relocating the timeout inside the while loop of thread1, combine thread 1 and 2 and have the resulting thread handle the stopping of it's list. When a timeout within the thread occurs, kill and be friendly with the next. (or surrender after second timeout and exit with a list of vms that have not yet been disabled.)

With the scenario above, is it possible to have a second timeout in main and just simply exit when the main timeout is reached?

$_->join for @jobs;

This waits for the threads to end, how to escape this line? As far as I can find, that's where I need the signal (and the threads->exit() in the signal handler) for.

In reply to Re^6: Perl 5.8.8 threads, clean exit by T_I
in thread Perl 5.8.8 threads, clean exit by T_I

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (6)
    As of 2018-06-18 22:23 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (111 votes). Check out past polls.