--- projects/cms/source/host/java/SystemMonitor.java 2000/11/27 20:36:30 1.2 +++ projects/cms/source/host/java/SystemMonitor.java 2000/11/30 04:11:00 1.3 @@ -2,6 +2,8 @@ //---IMPORTS--- +import java.util.Random; + /** * Gathers system information then outputs it as XML * Collects data based on properties gained from the configurator @@ -9,7 +11,7 @@ * the timeout has passed. * * @author $Author: ab11 $ - * @version $Id: SystemMonitor.java,v 1.2 2000/11/27 20:36:30 ab11 Exp $ + * @version $Id: SystemMonitor.java,v 1.3 2000/11/30 04:11:00 ab11 Exp $ */ class SystemMonitor { @@ -34,7 +36,8 @@ class SystemMonitor { // why oh why wont ultra edit let me put Long in the next line? oh its trying to // correct keywords =| - checkInterval = Long.parseLong(config.getProperty("UDPINTEVAL")); + checkInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000; + // make the check interval into seconds } @@ -49,6 +52,8 @@ class SystemMonitor { // called to retrieve the stored averages and output them as a XML string XMLFormatter xml = new XMLFormatter("packet"); + Random rand = new Random(); + // just send some dummy info for now. xml.addNest("packet_info"); String currentTime = Long.toString(System.currentTimeMillis()); @@ -56,20 +61,25 @@ class SystemMonitor { xml.addElement("sequence", Integer.toString(sequence)); xml.closeNest(); xml.addNest("core"); - xml.addElement("cpu","100"); - xml.addElement("memory","200"); + xml.addElement("cpu",""+rand.nextInt(100)); + xml.addElement("memory",""+rand.nextInt(100)); xml.closeNest(); - xml.addNest("additional"); - xml.addElement("users","20"); - xml.closeNest(); - + if ( rand.nextBoolean() ){ + xml.addNest("additional"); + xml.addElement("users",""+rand.nextInt(30)); + xml.closeNest(); + } // MUST FIX THIS..!!!! - while ( System.currentTimeMillis() < ( lastCheck + checkInterval ) ){ - // errm do nothing.. block or something. + try { + Thread.sleep(( lastCheck + checkInterval )-System.currentTimeMillis()); } + catch( InterruptedException e ){ + System.out.println("Sleep interrupted"); + } // increment sequence. sequence++; + lastCheck = System.currentTimeMillis(); // finally return a string return xml.returnXML();