Status Script

Check the status of the specified jobs in the DRM system.

Your status script should tell the client whether or not the job has been killed in the queue outside of the 3DEXPERIENCE platform.

This page discusses:

Description

The status wrapper script should check the execution status of the DRM jobs identified by the IDs given. 3DOrchestrate writes the command arguments and command output to the 3DOrchestrate Distribution Server log file.

Syntax

<statusPath> drmjobid1 ... drmjobidn

where:

<statusPath> Command specified by the property fiper.system.<drm-name>.statusCommandScriptPath (in the SMAExeServer.properties file).
drmjobid1 ... drmjobidn

List of unique job IDs (strings) that have been returned by the submit script.

For example:

bjobs.pl ID1 ID2 ID3 ID4

Return

The status script should return JavaScript Object Notation (JSON) in the following format:

[
{drmjobid:"<DRM_JOB_ID>",jobstatus:"<DRM_JOB_STATUS>",message:"<MESSAGE>"},
{drmjobid:"<DRM_JOB_ID>",jobstatus:"<DRM_JOB_STATUS>",message:"<MESSAGE>"},
...
{drmjobid:"<DRM_JOB_ID>",jobstatus:"<DRM_JOB_STATUS>",message:"<MESSAGE>"}
]

where:

<DRM_JOB_ID> ID string of the job.
<DRM_JOB_STATUS>

Job status which can be any of the following:

  • RUNNING—the work item is still running in the DRM job scheduler
  • PENDING—the work item is pending execution in the DRM job scheduler
  • SUSPENDED—the work item is suspended in the DRM job scheduler
  • ABORTED—the work item has failed and is no longer in the DRM job scheduler
  • CANCELLED—the work item has failed and is no longer in the DRM job scheduler
  • UNKNOWN—the work item has failed and is no longer in the DRM job scheduler
  • FINISHED—the work item is done and is no longer in the DRM job scheduler

<MESSAGE> Any message from the DRM system.

3DOrchestrate logs the DRM job status in the 3DOrchestrate Distribution Server log file.

Example

An example Perl script for the status command for IBM Spectrum LSF is shown below.

#!/usr/local/perl/bin/perl
##!/usr/bin/env perl
#
#SCRIPT ARGUMENTS:  
#    $0 drmjobid1 ... drmjobidN
#
#DEBUG OUTPUT: 
#    written to catalina.out when fiper.system.<DRM_NAME>.debugLog=true
#
#SCRIPT OUTPUT
#
#  JSON:
#   [
#    {  drmjobid: "<DRM_JOB_ID>", jobstatus:"<DRM_JOB_STATUS>", message:  "<MESSAGE>"  },
#    {  drmjobid: "<DRM_JOB_ID>", jobstatus:"<DRM_JOB_STATUS>", message:  "<MESSAGE>"  },
#    {  drmjobid: "<DRM_JOB_ID>", jobstatus:"<DRM_JOB_STATUS>", message:  "<MESSAGE>"  }
#   ]
#  where:
#       <DRM_JOB_ID>     =    DRM Job ID
#       <DRM_JOB_STATUS> =    DRM Job Status, Status could be any of the following:
#                                 RUNNING
#                                 PENDING
#                                 SUSPENDED
#                                 ABORTED
#                                 CANCELLED
#                                 UNKNOWN
#                                 FINISHED
#       <MESSAGE>        =    DRM message

use strict;
use JSON;

my %jobInfo;

open(BJOBS, "bjobs -UF @ARGV 2>&1 |");
while(<BJOBS>) {
   chomp;
   if (/Job\s+\<(\d+)\>.*Status\s+\<(\w+)\>/) {
        my $jobID = $1;
        my $jobStatus = $2; 
        if ($jobStatus eq "RUN") {
            $jobStatus = "RUNNING";
        } elsif ($jobStatus eq "PEND") {
            $jobStatus = "PENDING";
        } elsif ($jobStatus =~ /SUSP/) {
            $jobStatus = "SUSPENDED";
        } elsif ($jobStatus =~ /EXIT/) {
            $jobStatus = "ABORTED";
        } else {
            $jobStatus = "UNKNOWN";
        }
        $jobInfo{$jobID}{'drmjobid'} = $jobID;
        $jobInfo{$jobID}{'jobstatus'} = "$jobStatus";
        $jobInfo{$jobID}{'message'} = "Job $jobID is $jobStatus.";
   } elsif (/Job\s+\<(\d+)\>\s+is\s+not\s+found/) {
        my $jobID = $1;
        $jobInfo{$jobID}{'drmjobid'} = $jobID;
        $jobInfo{$jobID}{'jobstatus'} = "UNKNOWN";
        $jobInfo{$jobID}{'message'} = "Job $jobID is not found.";
   }   
}
close BJOBS;

my $json = "\[";
foreach my $id (keys %jobInfo) {
   $json .= to_json \%{$jobInfo{$id}}; 
   $json .= ",";
}
$json =~ s/\,$//;
$json .= "\]";
print "$json\n";

exit 0;