Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Re: Ping server from workflow

$
0
0

Yes, the System.isHostReachable(<ip or servername?,<timeout in MS>) works in VCO

 

EXAMPLE: System.isHostReachable(fakeservername,5000);

 

I've created a "ghetto" dual-stage ping, as sometimes the above will return a false negative ("hostname" being my input for servername or IP & "result" being my boolean output).

 

result = System.isHostReachable(hostname,5000);

 

if (result == false){

  try{

  System.log("SECONDARY PING STARTED");

  var cmd = new String();

  cmd = "ping -n 1 " + hostname;

  var command = new Command(cmd);

  command.execute(true);

  var pingResultNumber = command.result;

  var curlResult = command.output;

  System.log(curlResult);

 

  if(curlResult.trim().toLowerCase().indexOf("ms ttl") > -1 ){

  System.log("Host "+hostname+" is responding to pings.");

  result = true;

  }else{

  System.log("Host "+hostname+" is NOT responding to pings.");

  result = false;

  }

 

  } catch (e) {

  throw "Unable to execute command " + e;

  }

}

else

{

System.log("Host "+hostname+" is responding to pings.");

result = true;

}


Viewing all articles
Browse latest Browse all 168455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>