From 368de3b8820ce4ddfb751db4fd6a3564ef9e7aec Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 7 Jul 2004 02:46:32 +0000 Subject: [PATCH] format load average --- bindings/java/src/net/hyperic/sigar/cmd/Uptime.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Uptime.java b/bindings/java/src/net/hyperic/sigar/cmd/Uptime.java index 730c0767..4b48100a 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Uptime.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Uptime.java @@ -3,12 +3,18 @@ package net.hyperic.sigar.cmd; import net.hyperic.sigar.SigarProxy; import net.hyperic.sigar.SigarException; import net.hyperic.sigar.SigarNotImplementedException; +import net.hyperic.sigar.util.PrintfFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Uptime extends SigarCommandBase { + private static Object[] loadAvg = new Object[3]; + + private static PrintfFormat formatter = + new PrintfFormat("%.2f, %.2f, %.2f"); + public Uptime(Shell shell) { super(shell); } @@ -32,8 +38,13 @@ public class Uptime extends SigarCommandBase { try { double[] avg = sigar.getLoadAverage(); + loadAvg[0] = new Double(avg[0]); + loadAvg[1] = new Double(avg[1]); + loadAvg[2] = new Double(avg[2]); + loadAverage = "load average: " + - avg[0] + ", " + avg[1] + ", " + avg[2]; + formatter.sprintf(loadAvg); + } catch (SigarNotImplementedException e) { loadAverage = "(load average unknown)"; }