Date: Fri, 29 Mar 2024 11:13:27 +0000 (UTC) Message-ID: <1558673719.12803.1711710807456@change.sos-berlin.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_12802_1363049659.1711710807456" ------=_Part_12802_1363049659.1711710807456 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
FEATURE AVAILABILITY STARTING FROM RELEASE 1.11.5
The CheckHistory JITL = Job is intended as a replacement for the deprecated JobSchedulerCheckRunHistory Job.
rest
, containing a Job=
createApiAccessToken.job.xml
and a Job Chain =
createApiAccessToken.job_chain.xml
. These objects provided by defaul=
t with a new installation or update of the JOC Cockpit. They are not requir=
ed for Releases 1.12.8 and newer.sos:products:joc_cockpi=
t:history:view
permission has to be specified in the private.c=
onf
file. Note that the api_user role defined in the =
shiro.ini-example
file has these permissions by default. More inform=
ation about the private.conf
file can be found below.<=
/li>
To create the object:
function= spooler_process() { =20 // using the current job name var jobHistoryInfo =3D getJobHistoryInfoObject("job1"); ... return false; } function getJobHistoryInfoObject(jobname, timelimit) { var jobHistory =3D new Packages.com.sos.jitl.checkhistory.JobHistory( s= pooler.delegate ); if ((jobname =3D=3D=3D undefined) || (jobname =3D=3D=3D "")) { jobname =3D spooler_task.job.name; } if (timelimit =3D=3D=3D undefined) { timelimit =3D ""; } var jobHistoryInfo =3D jobHistory.getJobInfo( jobname, timelimit ); return jobHistoryInfo; }
Note that in the above example the job1 Parameter in the <=
em>spooler_process function has to include the full path within the Jo=
bScheduler live
folder.
The object provides the following methods:
jobHistoryInfo.getLastCompleted()
jobHistoryInfo.getRunning()
jobHistoryInfo.getLastCompletedSuccessful()
jobHistoryInfo.getLastCompletedWithError()
Each object provides:
.found
.name
.id
.jobName
.top
.start:
.end:
.executionResult
.errorMessage
.error
.errorCode
The following methods are provided in addition to the number of Job and = Order runs:
boolean jobHistoryInfo.isStartedToday()
true
, if the job has been started today.boolean isStartedTodayCompletedSuccessful()
true
, if the job has been started today and ended today su=
ccessful.jobHistoryInfo.isStartedTodayCompletedWithError()
true
, if the job has been started today and ended today wi=
th error.jobHistoryInfo.isStartedTodayCompleted()
true
, if the job has been started today. Doesn't matter wh=
ether ended successful or with an error.jobHistoryInfo.isCompletedToday()
true
, if the job has ended today.jobHistoryInfo.isCompletedTodaySuccessful()
true
, if the job has ended today successful.jobHistoryInfo.isCompletedTodayWithError()
true
, if the job has ended today with an error.jobHistoryInfo.isCompletedAfter("03:00:00")
true
, if the job has ended after the given time.jobHistoryInfo.isCompletedWithErrorAfter("03:00:00")
true
, if the job has ended with an error after the given t=
ime.jobHistoryInfo.isCompletedSuccessfulAfter("03:00:00")
true
, if the job has ended successful after the given time=
.jobHistoryInfo.isCompletedSuccessfulAfter("03:00:00")
true
, if the job has ended successful after the given time=
.jobHistoryInfo.startedAfter("03:00:00")
true
, if the job has been started after the given time.
jobHistoryInfo.startedWithErrorAfter("03:00:00")
true
, if the job has been started after the given time and=
ended with error.jobHistoryInfo.startedSuccessfulAfter("03:00:00")
true
, if the job has been started after the given time and=
ended successful.jobHistoryInfo.isCompletedBefore()
true
, if the job has been completed before the given time.=
jobHistoryInfo.isCompletedWithErrorBefore()
true
, if the job has been completed with an error before t=
he given time.jobHistoryInfo.isCompletedSuccessfulBefore()
true
, if the job has been completed successful before the =
given time.jobHistoryInfo.lastCompletedIsEndedBefore.order("03:00:00")
true
, if the last completion of the job has ended before t=
he given time.jobHistoryInfo.lastCompletedSuccessfulIsEndedBefore("03:00:00")
true
, if the last successful completion of the job is ende=
d before the given time.jobHistoryInfo.lastCompletedWithErrorIsEndedBefore("03:00:00")
true
, if the last completion of the job with an error was =
before the given time.jobHistoryInfo.lastCompletedIsStartedBefore("03:00:00")
true
, if the last completion of the job was before the giv=
en time.jobHistoryInfo.lastCompletedSuccessfulisStartedBefore("03:00:00")<= /pre>
true
, if the last successful completion of the job was bef=
ore the given time.jobHistoryInfo.lastCompletedWithErrorIsStartedBefore("03:00:00")= pre>
true
, if the last completion of the job with an error was =
before the given time.Please note that instead of using the methods described above, you can a=
lso use the .queryHistory method with the name of the method as a =
parameter.
For example:
jobHistoryInfo.queryHistory("isCompletedAfter(-1:10:48:33)")
This implementation uses the /orders/history and /tasks/his= tory REST web services. A database connection is not necessary.
sos:products:joc_cockpit:history:view
(e.g. api_user=
em> with the api_user role).com.sos.jitl.restclient.CreateApiAccessToken pre-processing monitor (see the example below) to make sure that this us=
er is logged in.
- Note that the functions provided by this monitor are integrated in the =
Java job implementation described below.
/sos/rest
(see attach=
ed rest.zip
file) is needed.
/sos/rest/createApiAccessToken
Job must be configured:
config/.private.conf
file./sos/rest/createApiAccessToken
J=
ob&l= t;job order=3D"yes" stop_on_error=3D"no" name=3D"createApiAccessToken"> <script language=3D"java" java_class_path=3D"" java_class=3D"com.so= s.jitl.restclient.CreateApiAccessToken"/> <run_time /> </job>
private.conf
file is located in the /config/priv=
ate
directory.username:passw=
ord
base64 encoded.
joc.webs= ervice.jitl{ joc.account=3D"YXBpX3VzZXI6YXBp" joc.url =3D "http://localhost:4446" }
This code is used in the check pre-processor of the check_start jo=
b in the example download archive.
<job = title=3D"Check the last job run with monitor" stop_on_error=3D"no" order= =3D"yes"> <settings > <log_level ><![CDATA[debug9]]></log_level> </settings> <description > <include file=3D"jobs/JobSchedulerCheckHistory.xml"/> </description> <params /> <script language=3D"java:javascript"> <![CDATA[function spooler_process() {=20 // using the current job name=20 var jobHistoryInfo =3D getJobHistoryInfoObject("job1"); report( jobHistoryInfo.getLastCompleted() ); return false; } function getJobHistoryInfoObject(jobname, timelimit) { var jobHistory =3D new Packages.com.sos.jitl.checkhistory.JobHistory( s= pooler.delegate ); if ((jobname =3D=3D=3D undefined) || (jobname =3D=3D=3D "")) { jobname =3D spooler_task.job.name; } if (timelimit =3D=3D=3D undefined) { timelimit =3D ""; } var jobHistoryInfo =3D jobHistory.getJobInfo( jobname, timelimit ); return jobHistoryInfo; } function report( reportItem ) { if (reportItem.found) { spooler_log.info( "Name:" + reportItem.name ); spooler_log.info( "Start Time: " + reportItem.start ); spooler_log.info( "End Time: " + reportItem.end ); } else { spooler_log.info( "Name: " + reportItem.name + " not found" ); } } ]]> </script> <monitor name=3D"apiAccessToken" ordering=3D"0"> <script language=3D"java" java_class=3D"com.sos.jitl.restclient= .CreateApiAccessToken"/> </monitor> <run_time /> </job>
A Java implementation is available as an alternative to using the API in= a JavaScript implementation as described above. Two example Jobs using thi= s implementation are provided in the Check History download linked at the e= nd of this article.
<job = title=3D"Check the last job run" order=3D"yes" stop_on_error=3D"no"> <script language=3D"java" java_class=3D"com.sos.jitl.checkhistory.J= obSchedulerCheckHistoryJSAdapterClass"/> <run_time /> </job>
query=
=3DisCompletedAfter (00:10:30)
.true|false
according to the result of the gi=
ven method.See the attached check_history.zip
=
file.