我正在尝试获取 ping 主机的无法访问状态,因为我分别获得了 up 和 down 的 (0,1) 值,我将如何获得任何条件“2”来告诉我无法访问 ping 主机?
我的代码,
import java.net.InetAddress;
public class PingExample
{
public static void main(String[] args)
{
try
{
InetAddress address = InetAddress.getByName("172.16.2.0");
// Try to reach the specified address within the timeout
// periode. If during this periode the address cannot be
// reach then the method returns false.
boolean reachable = address.isReachable(10000);
System.out.println("Is host reachable? " + reachable);
} catch (Exception e)
{
e.printStackTrace();
}
}
}
什么是主动和被动状态?我怎样才能检查它?
编辑:请参阅此链接第 26 页 http://nagios.sourceforge.net/docs/ndoutils/NDOUtils_DB_Model.pdf
stat 列说明。我想得到这个结果,因为我已经发布了我的代码,那么我将如何获得该列“状态”?请记住,我正在为“n”个主机使用循环。