From a168c9c0f60d9ab27d750d9c5d7766b4cd65b70f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 17 Dec 2004 07:04:50 +0000 Subject: [PATCH] prevent negative cpu percentage --- bindings/java/src/net/hyperic/sigar/MultiProcCpu.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/java/src/net/hyperic/sigar/MultiProcCpu.java b/bindings/java/src/net/hyperic/sigar/MultiProcCpu.java index be3025e9..aa979ce5 100644 --- a/bindings/java/src/net/hyperic/sigar/MultiProcCpu.java +++ b/bindings/java/src/net/hyperic/sigar/MultiProcCpu.java @@ -57,6 +57,10 @@ public class MultiProcCpu extends ProcCpu { } cpu.percent = ((cpu.total - otime) / diff); + if (cpu.percent < 0.0) { + //counter wrapped + cpu.percent = (0.0 - cpu.percent); + } if (cpu.percent >= 1.0) { cpu.percent = 0.99; }