Is there a method or some other function to ping a server, or a list of servers, from a workflow?
While Orchestrator doesn't expose an exact "ping" function, it gets close. Take a look at the System object in your api explorer and have a look at the isHostReachable method. This is supposed to return a true/false.
Here's a quick test line for your scriptable task:
System.debug(System.isHostReachable(serverToPing));
If you need to do a ping you can always use a local command or use another host to do a ping. We have an action that uses a linux host to do the ping.
var cmd = "ping -c 2 " + ipAddress;
var returnVal = false;
var exitCode = System.getModule("com.qualcomm.basic").runScriptingHostSshCommand(cmd);
// exit code 0 = success, 1 = partial packets returned, 2 = other error
System.log("IP Address Ping Exit Code (0 = Success, 1 = partial, 2 = other error) : " + exitCode);
if (exitCode.indexOf("0") == 0) {
returnVal = true;
}
return returnVal;
We have some workflows we've developed that use a pool of available hosts to run ssh scripts so that is what you are seeing in our script. You can just run an ssh command or a local command and your interpretation of the result might vary a bit depending on the os running the ping. Its a messy example and probably better more concise ways but it works in a pinch.
Hi Paul, nice pointer to using a scripting host to execute the ping command