SIAGR API を使用して CPU 使用率を計算していますが、LOAD RUNNER でテストすると例外が発生しますが、それ以外の場合は問題ありません。
org.hyperic.sigar.SigarFileNotFoundException: No such file or directory
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:348)
以下のサンプルコードを見つけてください
public static void main(String[] args)
{
try
{
Shell shell = new Shell();
shell.setPageSize(PageControl.SIZE_UNLIMITED);
Sigar sigar = shell.getSigar();
CpuPerc cpu = null;
for (int i = 0; i < 10; i++)
{
try
{
Thread.sleep(500L);
} catch (Exception e)
{
// TODO: handle exception
}
cpu = sigar.getCpuPerc();
double val = cpu.getCombined();
int cpuUsage = (int) (val * 100);
// System.out.println(CpuPerc.format(val));
System.out.println(cpuUsage);
}
}
catch (SigarException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
私の要件は、50 サイクルの特定の時間間隔で CPU 使用率を収集し、平均と最高をログに記録することです。
この問題の解決を手伝ってください