hi ppl,

i have written this subroutine to check the status of my caster (3 nodes + frontend). so if some application needs to see what other proc are running on the cluste it run's the sub :

################################################## sub _ganglia_info { ################################################## my ($self,%arg) = @_; my ($total_load,$total_proc) = (0,0); my (%gngl_info,%free_slots); foreach (@{$arg{ginfo}}){ chomp(my $who = `whoami`); chomp(my $host = `hostname -s`); my $pstmt = ($_ eq $host) ? ("cat /proc/cpuinfo | grep processor.* +: | wc -l") : ("ssh $who\@"."$_ cat /proc/cpuinfo | grep processor.*: + | wc -l"); my $lstmt = ($_ eq $host) ? ("ps -eo pcpu r") : ("ssh $who\@"."$_ +ps -eo pcpu r"); my $usrs = ($_ eq $host) ? ("ps -eo user r") : ("ssh $who\@"."$_ p +s -eo user r"); my $rnprc = ($_ eq $host) ? ("ps -eo cmd r") : ("ssh $who\@"."$_ p +s -eo cmd r"); chomp(my $proc = qx($pstmt)); chomp(my $tmp_load = qx($lstmt)); chomp(my $rhsts = qx($usrs)); chomp(my $rjob = qx($rnprc)); my @hsts = split("\n",$rhsts); my @job = split("\n",$rjob); my %tmp_hsh; @tmp_hsh{@hsts} = @job; $gngl_info{$_} = \%tmp_hsh; my @array = split("\n",$tmp_load); my $tmp_load_s = 0; foreach (@array){ $tmp_load_s += $_ if ($_ =~/\d+\.\d+/g); } $total_proc += $proc; $free_slots{$_} = int($proc - ($tmp_load_s / 100 )); $total_load += (100 - ($tmp_load_s / $proc )); } $total_load = $total_load / @{$arg{ginfo}}; return [$total_proc,$total_load,\%free_slots,\%gngl_info]; }
retrieves the results :
Total numb of proc: Total load %: Number of free(allegedly) cpu's per node: who is running which proc on which node:
im not concerned if a application running takes only 10% of my cpu , if that is the case i'll treat this cpu as a taken one.

so the problem is : it seams i can ssh into a nod and run ps and retrieve the right results for avg. load and number of free cpu's per node but i can't get the results for

who is running which proc on which node: -> ps -eo user r and ps -eo cmd r

i am retrieving partial results(example: if there are 3 proc (100%) running on node 1 i'll get for 4CPU machine that 1 CPU is free but it will also report only one-two users running one-two proc's and there should be 3)

can anybody help me with this one ? is there a module that does that?

thnx


In reply to checking the cluster status by baxy77bax

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.