[torquedev] job logging showjobs vmem patch

Gareth.Williams at csiro.au Gareth.Williams at csiro.au
Wed Jan 18 22:01:54 MST 2012


> -----Original Message-----
> From: torquedev-bounces at supercluster.org [mailto:torquedev-
> bounces at supercluster.org] On Behalf Of Ken Nielson
> Sent: Tuesday, 17 January 2012 4:42 AM
> To: Torque Developers mailing list
> Subject: Re: [torquedev] job logging showjobs vmem patch
> 
> Gareth,
> 
> I see what you mean. If you have time and are willing to fix this for
> array jobs we would be very happy.
> 
> Ken
> 
> ----- Original Message -----
> > From: "Gareth Williams" <Gareth.Williams at csiro.au>
> > To: torquedev at supercluster.org
> > Sent: Sunday, January 15, 2012 9:17:31 PM
> > Subject: Re: [torquedev] job logging showjobs vmem patch
> >
> > I've just noticed that array jobs are not particularly well handled
> > by the showjobs script:
-snip-

Here's a patch for showjobs to handle array jobs better.  There is a second path to express memory in mebibytes or gibibytes if the values are big enough (someone local asked for that - and it is meant to be human readable). I noticed that there is a job record for the whole array which has some value but it contains Output and Error file fields which (currently) no such files are created.

Gareth

--- /apps/torque/bin/showjobs   2012-01-16 19:37:43.336090321 +1100
+++ showjobs    2012-01-19 14:42:48.032725413 +1100
@@ -73,6 +73,11 @@
     }
 }
 
+# treat brackets as literal in job id for array jobs
+$specifiedJobId =~ s/\[/\\\[/g;
+$specifiedJobId =~ s/\]/\\\]/g;
+
+
 # Build a sorted list of job files
 chdir("${torqueHomeDir}/job_logs")
   or die
@@ -265,7 +270,7 @@
               if (
                 defined $specifiedJobId
                 && (! defined $jobAttr{'Job Id'}
-                    || $jobAttr{'Job Id'} !~ /^${specifiedJobId}\b/)
+                    || $jobAttr{'Job Id'} !~ /^${specifiedJobId}(?:.|\b)/)
               );
             next
               if (

--- showjobs    2012-01-19 15:57:42.517901727 +1100
+++ showjobs.mgb        2012-01-19 15:46:36.319334573 +1100
@@ -185,11 +185,11 @@
         }
         elsif ($line =~ /<mem>([^<]+)</ && $context eq 'resources_used')
         {
-            $jobAttr{'Memory Used'} = $1;
+            $jobAttr{'Memory Used'} = ktoMG($1);
         }
         elsif ($line =~ /<vmem>([^<]+)</ && $context eq 'resources_used')
         {
-            $jobAttr{'vmem Used'} = $1;
+            $jobAttr{'vmem Used'} = ktoMG($1);
         }
         elsif ($line =~ /<opsys>([^<]+)</ && $context eq 'resource_List')
         {
@@ -414,6 +414,31 @@
     else { return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds); }
 }
 
+
+################################################################################
+# $ktoMG = ktoMG($kilo)
+# Converts kilo units to mega or giga (mebi and gibi)
+# k, M and G are used rather than the more correct Ki, Mi and Gi
+################################################################################
+sub ktoMG
+{
+    my ($value) = @_;
+    if ($value =~ /^\s*(\d+)k/) {
+        my $k = $1;
+        if ($k > 1024) {
+            my $M = $k / 1024;
+            if ($M > 1024) {
+                my $G = $M / 1024;
+                $G = sprintf("%.1f", $G);
+                $value =~ s/${k}k/${G}G/;
+            } else {
+                $M = sprintf("%.1f", $M);
+                $value =~ s/${k}k/${M}M/;
+            }
+        }
+    }
+    return $value;
+}
 ##############################################################################
 
 __END__


More information about the torquedev mailing list