public void terminate() {
}
private synchronized ProcessCpuUtilization getUtilization() {
ProcessCpuUtilization pCpu;
if (sigar!=null) {
try {
/* On rare occasions the percentage has been a negative value,
* always make sure its a postive value */
double percent = Math.abs(sigar.getProcessCpuPercentage(pid));
long sys = sigar.getProcessCpuSys(pid);
long user = sigar.getProcessCpuUser(pid);
//System.out.println("User time....." + user);
//System.out.println("Sys time......" + sys);
//System.out.println("Percent......." + percent);
//System.out.println("------------")
pCpu = new ProcessCpuUtilization(id, percent, sys, user, tVals);
} catch(Exception e) {
logger.warn("SIGAR exception getting ProcessCpu, get CPU process utilization using JMX", e);
double percent = getUtilizationUsingJMX();
pCpu = new ProcessCpuUtilization(id, percent, tVals);
}
} else {
double percent = getUtilizationUsingJMX();
pCpu = new ProcessCpuUtilization(id, percent, tVals);
}
return pCpu;
}