#!/usr/local/bin/perl # rload: formats output of "ruptime" info on load on cluster machines # Usage: rload # Examples: # rload # rload -help $helpline = '11'; if ( $ARGV[0] =~ /^-h.*/ ) { system "head -$helpline $0; sleep 1"; } else { print "\n"; } $ncol = '3'; $icol = '0'; $wad = ''; open(LIST,"ruptime | awk '{print \$1, \$7}' | sort -n +1 |"); $numhosts = '0'; $ngreater = '0'; $ntotal = '0'; while () { chop; chop; ($name, $load) = split(' ',$_,2); $Hosts[$numhosts++] = $name; # print "name load $name $load\n"; $wad = $wad . $name . ' ' . $load . ' '; if ( $load >= 1.00 ) { $ngreater++; } $ntotal++; if ( ++$icol >= $ncol ) { # print "$wad\n"; ($a,$b,$c,$d,$e,$f) = split(' ',$wad); write; $wad = ''; $icol = 0; } } $wad .= '--- 0 --- 0'; ($a,$b,$c,$d,$e,$f) = split(' ',$wad); write; # now clean out expired time files chop($result = `rjob -timefile`); ($dir, $waittime) = split(' ', $result); ##print "got: $dir $waittime"; foreach (@Hosts) { $fname = "$dir"."$_"; if( -f $fname && -M $fname > 2*$waittime) { system "rm -f $fname"; } } print "\nNumber of machines with load > 1.00 is: $ngreater out of $ntotal\n\n"; exit 0; format STDOUT = @<<<<<<<<<< @##.### @<<<<<<<<<< @##.### @<<<<<<<<<< @##.### $a,$b,$c,$d,$e,$f .