--- projects/cms/source/host/java/SystemMonitor.java 2000/11/27 19:44:32 1.1 +++ projects/cms/source/host/java/SystemMonitor.java 2000/11/27 20:36:30 1.2 @@ -1,52 +1,90 @@ +//---PACKAGE DECLARATION--- + +//---IMPORTS--- + +/** + * Gathers system information then outputs it as XML + * Collects data based on properties gained from the configurator + * then packages these up using XMLFormatter and outputs them if + * the timeout has passed. + * + * @author $Author: ab11 $ + * @version $Id: SystemMonitor.java,v 1.2 2000/11/27 20:36:30 ab11 Exp $ + */ class SystemMonitor { - public SystemMonitor( Config config ){ - // create a new instace, get the info we need out of config - // like things to monitor - - lastCheck = System.currentTimeMillis(); - sequence = 0; +//---FINAL ATTRIBUTES--- +//---STATIC METHODS--- - // 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")); - - } +//---CONSTRUCTORS--- - public String getInfo(){ - // called to retrieve the stored averages and output them as a XML string - XMLFormatter xml = new XMLFormatter("packet"); - - // just send some dummy info for now. - xml.addNest("packet_info"); - String currentTime = Long.toString(System.currentTimeMillis()); - xml.addElement("date_time", currentTime ); - xml.addElement("sequence", Integer.toString(sequence)); - xml.closeNest(); - xml.addNest("core"); - xml.addElement("cpu","100"); - xml.addElement("memory","200"); - xml.closeNest(); - xml.addNest("additional"); - xml.addElement("users","20"); - xml.closeNest(); - - // MUST FIX THIS..!!!! - while ( System.currentTimeMillis() < ( lastCheck + checkInterval ) ){ - // errm do nothing.. block or something. - } - - // increment sequence. - sequence++; - - // finally return a string - return xml.returnXML(); - } // getinfo() +/** + * Public constructor for the class. Takes in a Config object to gain its + * properties from. + * + */ + public SystemMonitor( Config config ){ + // create a new instace, get the info we need out of config + // like things to monitor + + lastCheck = System.currentTimeMillis(); + sequence = 0; - // last time the system data was returned. + + // 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")); + + } + +//---PUBLIC METHODS--- + + /** + * Gathers system information and will black until the timeout has passed. + * + * @return the system information in an XML packet + */ + public String getInfo(){ + // called to retrieve the stored averages and output them as a XML string + XMLFormatter xml = new XMLFormatter("packet"); + + // just send some dummy info for now. + xml.addNest("packet_info"); + String currentTime = Long.toString(System.currentTimeMillis()); + xml.addElement("date_time", currentTime ); + xml.addElement("sequence", Integer.toString(sequence)); + xml.closeNest(); + xml.addNest("core"); + xml.addElement("cpu","100"); + xml.addElement("memory","200"); + xml.closeNest(); + xml.addNest("additional"); + xml.addElement("users","20"); + xml.closeNest(); + + // MUST FIX THIS..!!!! + while ( System.currentTimeMillis() < ( lastCheck + checkInterval ) ){ + // errm do nothing.. block or something. + } + + // increment sequence. + sequence++; + + // finally return a string + return xml.returnXML(); + } // getinfo() + +//---PRIVATE METHODS--- + +//---ACCESSOR/MUTATOR METHODS--- + +//---ATTRIBUTES--- + private long lastCheck; private int sequence; private long checkInterval; + +//---STATIC ATTRIBUTES--- } // class \ No newline at end of file