baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:

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