diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1d4e4cb --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: wa.server.WebAdminServer + diff --git a/src/wa/server/util/ProcStat.java b/src/wa/server/util/ProcStat.java index 7e8a98e..9ea89c0 100644 --- a/src/wa/server/util/ProcStat.java +++ b/src/wa/server/util/ProcStat.java @@ -22,6 +22,7 @@ package wa.server.util; +import zutil.io.MultiPrintStream; import zutil.log.LogUtil; import java.io.BufferedReader; @@ -57,12 +58,13 @@ public class ProcStat { BufferedReader in = new BufferedReader(new FileReader(PROC_PATH)); String line = null; while((line=in.readLine()) != null){ - String[] str = line.split("\\w*"); - if(str[0].equals("cpu")) + String[] str = line.split("\\W+"); + if(str[0].equals("cpu")) { cpuTotal.update(str); + } else if(str[0].startsWith("cpu")){ int cpuId = Integer.parseInt(str[0].substring(3)); - if(cpus.size() < cpuId) + if(cpus.size() <= cpuId) cpus.add(new CpuStats()); cpus.get(cpuId).update(str); } @@ -190,4 +192,15 @@ public class ProcStat { } + public static void main(String[] args){ + while(true){ + Iterator it = ProcStat.getCpuStats(); + for(int i=0; it.hasNext(); ++i){ + CpuStats cpu = it.next(); + System.out.print("CPU"+i+": " + cpu.getTotalLoad()+ " "); + } + System.out.println("Total Load: " + ProcStat.getTotalCpuStats().getTotalLoad()); + try{Thread.sleep(1000);}catch (Exception e){} + } + } }