We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to execute ping command from scheduled job?

Rajanmehta
Mega Guru

Hello

I am new bee to scripting in SNOW. We are on Jakarta.

I have following snippet from a scheduled job and need to run a ping command on a host to find out if the host responses or not. If ping fails I set host to retired.

I have some vision that this command has to run on a MID server and get the response back in the script, but no clue on how to do that.

Any help is greatly appreciated.

Thank you very much in advance.

find_real_file.png

while(rec.next()){

var lastDisco =rec.getValue('last_discovered');

var host = rec.getValue('name');

gs.addInfoMessage('Last Discovery Date:'+lastDisco+'     Host:'+host);

//Ping logic starts here

//   if(!PING){

//         rec.setValue('short_description','Retired');

//         rec.update();

//         gs.info('Host set for Retired');

//   }else{

//         gs.info("Host recently Discovered");

// }

}

4 REPLIES 4

Mike Allen
Mega Sage

You would have to have Orchestration to do this, I believe.   You can run a command in a cmd prompt that will do it for you.   Just create a workflow that does it and call the workflow in the script.



https://docs.servicenow.com/bundle/geneva-it-operations-management/page/product/orchestration/refere...


Thanks Mike. Appreciate your response.



I have created a workflow which does a ping job on a host passed as a parameter.



Could you please let me know, how can I call that workflow in my above script?  



Thanks,



Rajan Mehta


Thanks Shishir,



Based on document, I came up with following to trigger the WorkFlow.



var w = new Workflow();


w.startFlow('sysID',rec,'update',host);



This triggers the workflow OK. My next question is how do I assign this value of Host into Workflow?



workflow.scratchpad.hostname = ??



find_real_file.png