...
- JavaScript example for use with a job: this job requests the status information from the JobScheduler Universal Agent and returns the total number of tasks that have been executed during the Agents' lifetime. This job reads the web service URL from a job parameter.
- Download: rest_client.job.xml
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<job stop_on_error="no" > <params > <param name="agent_service" value="localhost:4445/jobscheduler/agent/api/"/> </params> <script language="java:javascript"> <![CDATA[ function spooler_process() { var parameters = spooler.create_variable_set(); parameters.merge( spooler_task.params ); var agent_service = parameters.value( "agent_service" ); var response = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( agent_service ); // alternative REST methods // var response = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://localhost:4445/jobscheduler/agent/api/" ); // var response = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand("get", "http://localhost:4445/jobscheduler/agent/api/" ); // var response = com.sos.jitl.restclient.JobSchedulerRestClient.getRestService( "localhost", 4445, "/jobscheduler/agent/api/", "http" ); if (response) { eval ( "var jsonObject = " + response + ";" ); spooler_log.info( jsonObject.totalTaskCount + " tasks on Agent [" + agent_service + "]: " + jsonObject.system.hostname ); } else { spooler_log.error( "no response from Agent web service at: " + agent_service ); } return false; } ]]> </script> <run_time /> </job> |
...