Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can configure your existing SSH job chain to start the monitoring job chain, which then will monitor the task of your original job chain as well as the processes started on the remote host via SSH.

Anchor
mode_of_operation
mode_of_operation
Mode

...

of Operation

To configure your SSH job to use the SSH Session Management you have to configure your SSH job and define a cleanup job chain for the cleanup work.

...

  • format:
    • <command> \${pid} \${user}
  • default value:
    • /bin/ps -ef | grep \${pid} | grep \${user} | grep -v grep
  • description:
    • The command or script checks if the process on the remote host is still running. The cleanup job expects an exitcode = 0 if the process is still running or other than 0 if the process is not available anymore. The command or script depends on the OS of the remote host. If the command is not set, the default command for Linux is used.
       The ${pid} and ${user} placeholders will be substituted by the cleanup job. Note that the leading $ character has to be escaped with "\".
    • Example commands:
      • /bin/ps -ef 
        • writes all running processes to stdout on the remote host
      • | grep \${pid}
        • filters the result to show only results containing the given ${pid}
      • | grep \${user} 
        • filters the result to show only results containing the given ${user}
      • | grep -v grep
        • filters the grep command itself

Example: Configuration

...

with JOE

Job

Parameters

Example: XML

...

configuration

Code Block
languagexml
titlejob xml
<job title="Launch commands or executable files by SSH">
  <description>
    <include file="jobs/JobSchedulerSSHJob.xml"/>
  </description>
  <params>
    <param name="host" value="[HOST]"/>
    <param name="port" value="[SSHPORT]"/>
    <param name="user" value="[USERNAME]"/>
    <param name="password" value="[PASSWORD]"/>
    <param name="auth_method" value="password"/>
    <param name="command_script_file" value="[PATH_TO_SCRIPTFILE]\test_sleep_90s.sh"/>
    <param name="runWithWatchdog" value="true"/>
    <param name="cleanupJobchain" value="kill_jobs/remote_cleanup_test"/>
    <param name="ssh_job_kill_pid_command" value="kill -9 \${pid}"/>
    <param name="ssh_job_terminate_pid_command" value="kill -15 \${pid}"/>
    <param name="ssh_job_get_pid_command" value="echo $$"/>
    <param name="ssh_job_get_active_processes_command" value="/bin/ps -ef | grep \${pid} | grep \${user} | grep -v grep"/>
  </params>
  <script java_class="sos.scheduler.job.SOSSSHJob2JSAdapter" language="java"/>
  <run_time/>
</job>

Anchor
config_second_job_chain
config_second_job_chain
Configuration

...

of the Cleanup Job Chain

A cleanup job chain with two jobs has to be configured to process the cleanup of the remote processes or the JobScheduler task.

The cleanup job chain consists of two jobs, one to read the pid of the connected shell from a temporary file on the remote host and one to check if the process or the JobScheduler task is still running. The temporary file will be generated automatically and deleted after processing. The second job also ends either the remote process or the JobScheduler task as appropriate.

Job 1: The read-pid-from-temporary-file

...

job

The first job reads the pid from the temporary file on the remote host. If your SSH job is configured as described above, the temporary file will have been created automatically on the remote host.

...

After choosing the relevant class name from the list, configure a setback for the job. The setback will be used to restart the job according to the conditions found by the job (described above).

Job 2: The check-and-kill

...

job

The second job checks:

  • if the pid determined by the first job is still active
  • if the JobScheduler task is still active 
  • kills the remote process or the JobScheduler task 

...