如何检查服务器了? [英] How to check server is up?

查看:114
本文介绍了如何检查服务器了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个不同的物理机器上有两个服务器节点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.

这篇关于如何检查服务器了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆