如何检查服务器了?

问题描述:

我在两个不同的物理机器上有两个服务器节点IBM Websphere Application Server的集群。任何人都可以帮我用java代码来检查我的服务器实例是在运行还是其中一个服务器没有运行? / p>

I have got a cluster of two server nodes IBM Websphere Application Server on two different physical machine.Can anybody help me with java code to check whether my server instance is running or when one of the server is not up and running?

为了快速便携地进行操作,您可以查看服务器提供的页面。

To do it quickly and portably, you can check for a page if it's served by the server.

例如你可以:

boolean isAlive = true;
try {
  URL hp = new URL("http://yourserver/TestPage.html"); 
  URLConnection hpCon = hp.openConnection(); 
  // add more checks...
} catch (Exception e) {
  isAlive = false;
}

这种不太复杂的方法适用于每个http服务器。

This not much sophisticated method will work with every http server.