include totals from Sigar.getCpuPerc()
This commit is contained in:
parent
753d627296
commit
406cc69036
|
@ -23,6 +23,16 @@ public class CpuInfo extends SigarCommandBase {
|
||||||
return "Display cpu information";
|
return "Display cpu information";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void output(CpuPerc cpu) {
|
||||||
|
println("User Time....." + CpuPerc.format(cpu.getUser()));
|
||||||
|
println("Sys Time......" + CpuPerc.format(cpu.getSys()));
|
||||||
|
println("Idle Time....." + CpuPerc.format(cpu.getIdle()));
|
||||||
|
println("Wait Time....." + CpuPerc.format(cpu.getWait()));
|
||||||
|
println("Nice Time....." + CpuPerc.format(cpu.getNice()));
|
||||||
|
println("Combined......" + CpuPerc.format(cpu.getCombined()));
|
||||||
|
println("");
|
||||||
|
}
|
||||||
|
|
||||||
public void output(String[] args) throws SigarException {
|
public void output(String[] args) throws SigarException {
|
||||||
net.hyperic.sigar.CpuInfo[] infos =
|
net.hyperic.sigar.CpuInfo[] infos =
|
||||||
this.sigar.getCpuInfoList();
|
this.sigar.getCpuInfoList();
|
||||||
|
@ -38,25 +48,22 @@ public class CpuInfo extends SigarCommandBase {
|
||||||
if (cacheSize != Sigar.FIELD_NOTIMPL) {
|
if (cacheSize != Sigar.FIELD_NOTIMPL) {
|
||||||
println("Cache size...." + cacheSize);
|
println("Cache size...." + cacheSize);
|
||||||
}
|
}
|
||||||
|
println("");
|
||||||
|
|
||||||
if (!this.displayTimes) {
|
if (!this.displayTimes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<infos.length; i++) {
|
for (int i=0; i<infos.length; i++) {
|
||||||
|
println("CPU " + i + ".........");
|
||||||
if (cpus == null) {
|
if (cpus == null) {
|
||||||
cpus = this.sigar.getCpuPercList();
|
cpus = this.sigar.getCpuPercList();
|
||||||
}
|
}
|
||||||
CpuPerc cpu = cpus[i];
|
output(cpus[i]);
|
||||||
println("User Time....." + CpuPerc.format(cpu.getUser()));
|
|
||||||
println("Sys Time......" + CpuPerc.format(cpu.getSys()));
|
|
||||||
println("Idle Time....." + CpuPerc.format(cpu.getIdle()));
|
|
||||||
println("Wait Time....." + CpuPerc.format(cpu.getWait()));
|
|
||||||
println("Nice Time....." + CpuPerc.format(cpu.getNice()));
|
|
||||||
println("Combined......" + CpuPerc.format(cpu.getCombined()));
|
|
||||||
|
|
||||||
println("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("Totals........");
|
||||||
|
output(this.sigar.getCpuPerc());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue