java sigar cpu使用率,java - java.lang.UnsatisfiedLinkError:org.hyperic.sigar.Cpu.gather(Lorg / hyperic ...

在window10上使用eclips存在问题

5월 25, 2017 9:15:52 오전 org.apache.catalina.core.StandardWrapperValve invoke

심각: Servlet.service() for servlet [jsp] in context with path [/ESTIS] threw exception [An exception occurred processing JSP page /Estis/Admin_SystemMonitoring.jsp at line 51

48: SystemMonitoring sm=new SystemMonitoring();

49: CPUVo cpuVo=new CPUVo();

50: MemoryVo memoryVo=new MemoryVo();

51: cpuVo=sm.getCPU();

52: memoryVo=sm.getMemory();

53: %>

54:

Stacktrace:] with root cause

java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Cpu.gather(Lorg/hyperic/sigar/Sigar;)V

at org.hyperic.sigar.Cpu.gather(Native Method)

at org.hyperic.sigar.Cpu.fetch(Cpu.java:30)

at org.hyperic.sigar.Sigar.getCpu(Sigar.java:320)

at org.hyperic.sigar.Sigar.getCpuPerc(Sigar.java:341)

at SystemMonitoring.SystemMonitoring.getCPU(SystemMonitoring.java:27)

at org.apache.jsp.Estis.Admin_005fSystemMonitoring_jsp._jspService(Admin_005fSystemMonitoring_jsp.java:163)

我在Admin_SystemMonitoring.jsp中调用Sigar API

public CPUVo getCPU()

{

System.out.println("================== CPU DATA ====================");

Sigar sigar = new Sigar();

CpuPerc cpu = null;

CpuPerc[] cpus = null;

CPUVo vo=new CPUVo();

try

{

cpu = sigar.getCpuPerc();

cpus = sigar.getCpuPercList();

vo.setUserTime(CpuPerc.format(cpu.getUser()));

vo.setTotalSysTime(CpuPerc.format(cpu.getSys()));

vo.setTotalIdle(CpuPerc.format(cpu.getIdle()));

System.out.println(String.format("Total User Time : %s / Total Sys Time : %s / Total Idle : %s ",

vo.getUserTime(),

vo.getTotalSysTime(),

vo.getTotalIdle()));

} catch (Exception e)

{

e.printStackTrace();

}

return vo;

}

但是,如果我在Java主类中调用,则SystemMonitoring类可以工作。 另外,我在(project-properties-java构建路径)和(WebContent-WEB-INF-lib)中添加Sigar.jar

我不知道如果我在jsp中调用该方法,为什么它不起作用...我该如何解决?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值