I'm new to Sigar. I would like to run a simple test to know how I can monitor my system.
I added sigar-1.6.4
and log4j
as external libraries, but when I go to run it, I face this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Sigar.getCpuInfoList()[Lorg/hyperic/sigar/CpuInfo;
at org.hyperic.sigar.Sigar.getCpuInfoList(Native Method)
Here is my code:
import java.util.Map;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Sigar sigar = new Sigar();
CpuInfo[] cpuinfo = null;
try {
cpuinfo = sigar.getCpuInfoList();
} catch (SigarException se) {
se.printStackTrace();
}
System.out.println("---------------------");
System.out.println("Sigar found " + cpuinfo.length + " CPU(s)!");
System.out.println("---------------------");
}
}
Any help would be appreciated.
I understood the problem!
I have to use the following JVM Argument:
-Djava.library.path="./lib"
in Run Configuration, Arguments tab, VM arguments in eclipse, while the contnet of sigar-bin/lib is in lib folder.