Java 远程机器信息访问|不带JMX
嗨,我需要在不使用JMX的情况下获得java中远程系统的CPU使用情况 我有代码要在本地机器上测试,但不是在远程机器上测试Java 远程机器信息访问|不带JMX,java,Java,嗨,我需要在不使用JMX的情况下获得java中远程系统的CPU使用情况 我有代码要在本地机器上测试,但不是在远程机器上测试 try{ Sigar session = new Sigar(); System.out.println(session.getNetInfo()); String temp,fdigit; int cpuUsage=0; double freeCpu
try{
Sigar session = new Sigar();
System.out.println(session.getNetInfo());
String temp,fdigit;
int cpuUsage=0;
double freeCpu = 0;
DecimalFormatSymbols simbol = new DecimalFormatSymbols();
simbol.setDecimalSeparator('.');
DecimalFormat df = new DecimalFormat("##.##",simbol);
while(true){
temp="";
cpuUsage=0;
Thread.sleep(900);
CpuPerc cpuPerc = session.getCpuPerc();
freeCpu = cpuPerc.getCombined()*100;
freeCpu = Double.valueOf(df.format(freeCpu));
temp=""+freeCpu;
fdigit=temp.substring(temp.indexOf(".")+1);
if(Integer.parseInt(fdigit)>=4){
cpuUsage=Integer.parseInt(temp.substring(0, temp.indexOf(".")));
cpuUsage=cpuUsage+1;
}
System.out.println(cpuUsage+"%");
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
我在谷歌上搜索了一下,但没有使用JMX,我找不到任何样本
因此,我希望我们的堆栈溢出用户能提供帮助。请尽快告诉我。如果没有JMX对该服务的支持,我们将退回到sigar。但是我们在监控平台上运行一个代理,通过网络发送数据。好的,没有办法完全远程完成。:谢谢你的回复。我不知道RHQ。我需要访问远程机器系统信息(cpu使用)。是否有任何方法可以单独使用ip地址或其他我需要的信息。请让我知道?在IBM的TADDM产品中,他们在*nix上做任何事情,只需登录到box并运行shell命令。对于Windows,我相信它使用Windows管理API。如果一个人被迫这样做,我认为这可能是一个有效的选择。