--- projects/cms/source/host/java/SystemMonitor.java 2000/11/30 17:33:36 1.4 +++ projects/cms/source/host/java/SystemMonitor.java 2000/12/07 18:25:37 1.5 @@ -3,6 +3,7 @@ //---IMPORTS--- import java.util.Random; +import java.io.*; /** * Gathers system information then outputs it as XML @@ -11,7 +12,7 @@ import java.util.Random; * the timeout has passed. * * @author $Author: ab11 $ - * @version $Id: SystemMonitor.java,v 1.4 2000/11/30 17:33:36 ab11 Exp $ + * @version $Id: SystemMonitor.java,v 1.5 2000/12/07 18:25:37 ab11 Exp $ */ class SystemMonitor { @@ -59,6 +60,28 @@ class SystemMonitor { // called to retrieve the stored averages and output them as a XML string XMLFormatter xml = new XMLFormatter("packet"); + // the process to run + try { + Process proc = Runtime.getRuntime().exec("/usr/local/sbin/top -s1 -d2 0 > top.txt"); + // this process will take atleast 2 seconds to complete + try { + proc.waitFor(); + } + catch ( InterruptedException e ){ + + } + + } + catch ( IOException e ){ + + } + + + + // now do some text processing. + DecodeCPU_TXT details = new DecodeCPU_TXT("top.txt"); + + Random rand = new Random(); // just send some dummy info for now. @@ -67,15 +90,9 @@ class SystemMonitor { xml.addElement("date_time", currentTime ); xml.addElement("sequence", Integer.toString(sequence)); xml.closeNest(); - xml.addNest("core"); - xml.addElement("cpu",""+rand.nextInt(100)); - xml.addElement("memory",""+rand.nextInt(100)); - xml.closeNest(); - if ( rand.nextBoolean() ){ - xml.addNest("additional"); - xml.addElement("users",""+rand.nextInt(30)); - xml.closeNest(); - } + xml.addString(details.getItems()); + + // MUST FIX THIS..!!!! try { long updateIn = ( lastCheck + udpcheckInterval )-System.currentTimeMillis();