#! /usr/bin/perl -w use strict; # # "now" script by Julen Larrucea # julen@larrucea.eu # Loadleveler version (written for MareNostrum and supercomputers in Barcelona Supercomputing Center) # ### Build the array with all the info my @BULK = `llq -l` ; #Defining the initial variables my $NAME = ''; my $STATUS = ''; my $NPROC = ''; my $JID = ''; my $PATH = ''; my $COLOR = ''; #Printing the header of the output. print " \033[34m Running Jobs\033[0m \033[1;46;34m NYT \033[0m \n "; print "Status NProc Job Name Job ID Path\n "; #The blanks are right print "\n"; foreach my $JOB (@BULK) # $JOB is each row for the array @BULK { if ($JOB =~ m/Status:/) # Get the Courrent Status for each job {$STATUS = (split(' ',$JOB))[1]; if ($STATUS =~ m/Running/) {$COLOR = '42;34' ; $STATUS = "\033[${COLOR}m R \033[0m"} # Print an "R" in green elsif ($STATUS =~ m/Idle/) {$COLOR = '47;33'; $STATUS = "\033[${COLOR}m I \033[0m"} # Print an "I" in orange elsif ($STATUS =~ m/Not/) {$COLOR = '43;36'; $STATUS = "\033[${COLOR}m H \033[0m"} # Print an "I" in orange elsif ($STATUS =~ m/Starting/) {$COLOR = '47;34'; $STATUS = "\033[${COLOR}m S \033[0m"} # Print an "I" in orange elsif ($STATUS =~ m/Remove/) {$COLOR = '47;36'; $STATUS = "\033[${COLOR}m D \033[0m"} # Print an "I" in orange elsif ($STATUS =~ m/Cancel/) {$COLOR = '38;41'; $STATUS = "\033[${COLOR}m C \033[0m"} #Print an "C" in red } elsif ($JOB =~ m/Job Name:/) # Get the Job Names {$NAME = sprintf ("%-15s",(split(' ',$JOB))[2])} #Limit the no. of letters in $NAME elsif ($JOB =~ m/Job Step Id:/) # Get the Job ID { $JID = sprintf ("%22s",(split(' ',$JOB))[3])} elsif ($JOB =~ m/Initial/) # Get the Path to the output { $PATH = sprintf ("%40s",(split(' ',$JOB))[3])} elsif ($JOB =~ m/Total Task/) # Get the No. of processors for each job {$NPROC = sprintf ("%4s",(split(' ',$JOB))[3]); chomp($NAME); # Erasing the blanks before and after the words chomp($STATUS); chomp($PATH); chomp($JID); print " $STATUS | $NPROC | $NAME | $JID | $PATH \n"; # print " ------|-----|----------------|----------\n"; } }; print "\n";