VMware Cloud Community
uswbnc53
Enthusiast
Enthusiast

Ping server from workflow

Is there a method or some other function to ping a server, or a list of servers, from a workflow?

3 Replies
Burke-
VMware Employee
VMware Employee

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));

Screen Shot 2017-04-19 at 9.57.19 AM.png

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
qc4vmware
Virtuoso
Virtuoso

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.

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee

Hi Paul, nice pointer to using a scripting host to execute the ping command Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter