Introduction

Monitors (also called Pre-/Post-Processing Monitors) are used with Jobs to provide pre-processing and post-processing capabilities by Scripting. Pre-Processing Monitors are executed before a task or processing step is executed by the JobScheduler. Similarly Post-Processing Monitors are executed once a task or processing step has been completed. 

  • Jobs can have multiple Pre-/Post-Processing Monitors. The order in which these are executed by the JobScheduler can be specified by setting a parameter.
    • Pre-Processing Monitors can be created to 
      • validate required conditions for a particular task to be started or 
      • set a parameter value dynamically, e.g. today's date.
    • At the same time Post-Processing Monitors can check the job's execution status, return code, total execution time etc..
  • Pre-/Post-Processing Monitors can be programmed independently of a job's programming language. For example, a shell script job can have a Pre-/Post-Processing Monitor written in JavaScript. 

A short introduction to JobScheduler Monitors in general can be found in our Monitors article.

Named Pre-/Post-Processing Monitors

  • Named Monitors are Pre-/Post-Processing Monitors that are specified in the configuration of individual jobs.
    (Monitors can also be specified in the configuration of the executing JobScheduler as Enforced Monitors.)
  • Pre-/Post-Processing Monitors are generic blocks of code stored in separate files in the JobScheduler's live folder with file extension *.monitor.xml, e.g. MyMonitor.monitor.xml.
    • Pre-/Post-Processing Monitors can be reused - i.e. included by multiple jobs. 
    • Pre-/Post-Processing Monitors can implement unique features within JobScheduler by accessing the JobScheduler's API Interface
  • Feature Availabiliy
    • JS-1145 - Getting issue details... STATUS
    • JOE-117 - Getting issue details... STATUS

  • Example
    • In following example we will create a Pre-Processing Monitor that shows all the order parameters before start of a job. In addition, we will see that parameters created by one task can be carried forward by the executing order to the next task. The first job JobA will create two parameters BOOKINGD_DATE and START_TRX_ID which will be carried forward by the order to the next job JobB.

Creating a Named Pre-/Post-Processing Monitor using JOE

In following example we will create a Pre-Processing Monitor that shows all the order parameters before start of a job. In addition, we will see that parameters created by one task can be carried forward by the executing order to the next task. A first job JobA will create two parameters BOOKINGD_DATE and START_TRX_ID which will be carried forward by the order to the next job JobB.

Creating a job chain and order for the example

This example uses a simple job chain and order to demonstrate the configuration of a Named Monitor.

Download the example configuration.

We recommend downloading the example configuration and unpacking the configuration in your JobScheduler's live folder.

Opening the configuration in the JobScheduler's Object Editor, JOE, will show the file structure illustrated in the left hand pane of the following screenshot:

  • The example has a job chain with one job with a shell script that contains a simple sleep function. The Order1_0 has one parameter, orderParameter, with the value 1.
  • Opening the Pre-/Post-Processing element in JOE's left hand pane as shown in the next screenshot to display the configuration for the show_all_order_parameters_pre Monitor:

  • The next two sections describe how to create and apply the show_all_order_parameters_pre Monitor.

Creating the Example Monitor using JOE

  • In the left hand navigation pane click on the Pre-/Post-Processing Monitor element.
  • In the far right top side click on New to create a Pre-/Post-Processing Monitor
    • A new Monitor will be created with a default name, process0.
  • Click on the Name of the newly created Monitor: 
    • This will open a form allowing more configuration options such as Name, Ordering etc. to be set.
      • Click inside the Name text box and specify a relevant name for the Monitor, e.g. show_all_orders_parameters_pre.
      • Leave the Ordering at the default value of 0.
      • Choose the javax.script:ecmascript script language from the Language dropdown menu.
    • Just below of click on the script tab and chose the spooler_process_before() code snippet.

    • Copy & Paste the following code snippet as a replacement for the function:

      show_all_order_parameters_pre
      function spooler_process_before() {
      
          var parameters = spooler_task.order().params();
          spooler_log.info( ".. total number of order parameters: " + parameters.count() );
      
          var names = parameters.names().split( ';' );
          for( i=0; i < parameters.count(); i++ ) {
              spooler_log.info( ".. parameter: "+ names[i] + " = " + parameters.value( names[i] ) );
          }
      
          return true;
      }
    • Save the configuration by clicking on the Save Configuration icon in the top left hand corner of JOE.

Specification of Monitors as Pre- or Post-Processors

  • The use of the spooler_process_before() or spooler_process_after() function in the monitor script defines whether a Monitor is a pre-processor or post-processor.
  • In addition to the two spooler_process_*() functions two additional functions can be used in monitor scripts:
    • spooler_task_before()
    • spooler_task_after()
  • The most important difference between the spooler_process and spooler_task functions is that the spooler_task functions are able to handle return codes. 
  • More detailed information about these functions can be found in the Monitors section of the JobScheduler reference documentation.

Assigning the Example Monitor as a Named Monitor

  • Click on the job you want to use the show_all_order_parameters_pre Pre-Processing Monitor with.
  • Expand the job configuration options by clicking on the left side of the job.
    • Click on the Monitors Used option that will open the pane for assigning a Pre-/Post-Processing Monitor.
    • Click on the button New Monitor Use as shown in the screenshot below.
    • Select the show_all_order_parameters_pre monitor from the Monitor drop down list. 
    • Assign an Ordering value 0 to the Ordering text box.
    • Click on the Apply Monitor Use button.
    • Save the configuration by clicking on the Save Configuration icon.

Configuration Notes

  • The same Pre-/Post Processing Monitor can be used by a number of jobs.
  • The Browse button in the Monitors Used pane can be used to select Monitors from other subfolders in the JobScheduler live folder.
    This means that a series of generic Monitors could be configured in a central directory and then be specified for individual jobs as required.

Specification of the Monitor Execution Order in Detail

The Ordering setting
  • The Ordering setting can be specified in both the Monitor configuration itself and in the job configuration as an attribute for the Monitors used parameter.
    • Ordering values saved as an attribute for the Monitors used parameter will overwrite settings specified for the Monitor itself.
  • Pre-processor Monitors with a smaller Ordering attribute will be executed before pre-processor Monitors with a larger Ordering attribute.
  • Post-processor Monitors with a smaller Ordering attribute will be executed after post-processor Monitors with a larger Ordering attribute.
The position of the Monitor in the JobScheduler's live Folder
  • The order in which JobScheduler executes monitors is dependent on the position of the monitor element in the JobScheduler live folder:
    • Pre-processing monitors
      • Monitors are in different folders:
        • Consider the folders a/b/c:
          • all process_before monitors in folder a will be executed before process_before monitors in folders b and c
      • Monitors in the same folder: 
        • Monitors in the same folder will be executed according to the ordering attributes specified for the monitors.
    • Post-processing monitors
      • Monitors are in different folders:
        • Consider the folders a/b/c:
          • all process_after monitors in folder c will be executed before process_after monitors in folders b and a
      • Monitors in the same folder:

        • Monitors in the same folder will be executed according to the ordering attribute specified for the monitors.

Modifying Monitors

  • JobScheduler tracks changes to Monitor files and to files included with monitor files that make use of <include live_file="..."/> elements.
    • Adding, modifying and removing monitor files or files included with monitor files causes the JobScheduler to terminate tasks that use the relevant monitor i.e. the tasks are terminated with the current process step. This behavior is the same as for other JobScheduler elements: schedules, process classes and locks.

Viewing Monitors in JOC

Monitor configuration is not directly visible in the JobScheduler Operating Center (JOC) as can be seen in the the following screenshot, which shows the Named Monitor example described above.

However, clicking on the Job node menu Show configuration button as shown in the screenshot will open a listing of the job node configuration with the <monitor.use> element as shown below:

Instruction Video



References

Change Management References

T Key Linked Issues Fix Version/s Status P Summary Updated
Loading...
Refresh

See also