ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/java/SystemMonitor.java
(Generate patch)

Comparing projects/cms/source/host/java/SystemMonitor.java (file contents):
Revision 1.1 by ab11, Mon Nov 27 19:44:32 2000 UTC vs.
Revision 1.2 by ab11, Mon Nov 27 20:36:30 2000 UTC

# Line 1 | Line 1
1 + //---PACKAGE DECLARATION---
2 +
3 + //---IMPORTS---
4 +
5 + /**
6 + * Gathers system information then outputs it as XML
7 + * Collects data based on properties gained from the configurator
8 + * then packages these up using XMLFormatter and outputs them if
9 + * the timeout has passed.
10 + *
11 + * @author  $Author$
12 + * @version $Id$
13 + */
14   class SystemMonitor {
15  
16 <        public SystemMonitor( Config config ){
4 <                // create a new instace, get the info we need out of config
5 <                // like things to monitor
6 <                
7 <                lastCheck = System.currentTimeMillis();
8 <                sequence = 0;
16 > //---FINAL ATTRIBUTES---
17  
18 + //---STATIC METHODS---
19  
20 <                // why oh why wont ultra edit let me put Long in the next line? oh its trying to
12 <                // correct keywords =|
13 <                checkInterval = Long.parseLong(config.getProperty("UDPINTEVAL"));
14 <                
15 <        }
20 > //---CONSTRUCTORS---
21  
22 <        public String getInfo(){
23 <                // called to retrieve the stored averages and output them as a XML string
24 <                XMLFormatter xml = new XMLFormatter("packet");
25 <                
26 <                // just send some dummy info for now.
27 <                xml.addNest("packet_info");
28 <                    String currentTime = Long.toString(System.currentTimeMillis());
29 <                    xml.addElement("date_time", currentTime );
30 <                    xml.addElement("sequence", Integer.toString(sequence));
31 <                xml.closeNest();
32 <                xml.addNest("core");
28 <                    xml.addElement("cpu","100");
29 <                    xml.addElement("memory","200");
30 <                xml.closeNest();
31 <                xml.addNest("additional");
32 <                    xml.addElement("users","20");
33 <                xml.closeNest();
34 <                
35 <                // MUST FIX THIS..!!!!
36 <                while ( System.currentTimeMillis() < ( lastCheck + checkInterval ) ){
37 <                  // errm do nothing.. block or something.          
38 <                }
39 <                
40 <                // increment sequence.
41 <                sequence++;
42 <                                
43 <                // finally return a string
44 <                return xml.returnXML();
45 <        } // getinfo()
22 > /**
23 > * Public constructor for the class. Takes in a Config object to gain its
24 > * properties from.
25 > *
26 > */  
27 > public SystemMonitor( Config config ){
28 >        // create a new instace, get the info we need out of config
29 >        // like things to monitor
30 >        
31 >        lastCheck = System.currentTimeMillis();
32 >        sequence = 0;
33  
34 <    // last time the system data was returned.
34 >
35 >        // why oh why wont ultra edit let me put Long in the next line? oh its trying to
36 >        // correct keywords =|
37 >        checkInterval = Long.parseLong(config.getProperty("UDPINTEVAL"));
38 >        
39 >    }
40 >
41 > //---PUBLIC METHODS---
42 >
43 >   /**
44 >    * Gathers system information and will black until the timeout has passed.
45 >    *
46 >    * @return the system information in an XML packet
47 >    */
48 >    public String getInfo(){
49 >        // called to retrieve the stored averages and output them as a XML string
50 >        XMLFormatter xml = new XMLFormatter("packet");
51 >        
52 >        // just send some dummy info for now.
53 >        xml.addNest("packet_info");
54 >            String currentTime = Long.toString(System.currentTimeMillis());
55 >            xml.addElement("date_time", currentTime );
56 >            xml.addElement("sequence", Integer.toString(sequence));
57 >        xml.closeNest();
58 >        xml.addNest("core");
59 >            xml.addElement("cpu","100");
60 >            xml.addElement("memory","200");
61 >        xml.closeNest();
62 >        xml.addNest("additional");
63 >            xml.addElement("users","20");
64 >        xml.closeNest();
65 >        
66 >        // MUST FIX THIS..!!!!
67 >        while ( System.currentTimeMillis() < ( lastCheck + checkInterval ) ){
68 >          // errm do nothing.. block or something.      
69 >        }
70 >        
71 >        // increment sequence.
72 >        sequence++;
73 >                
74 >        // finally return a string
75 >        return xml.returnXML();
76 >    } // getinfo()
77 >    
78 > //---PRIVATE METHODS---
79 >
80 > //---ACCESSOR/MUTATOR METHODS---
81 >
82 > //---ATTRIBUTES---
83 >
84      private long lastCheck;
85      private int sequence;
86      private long checkInterval;
87 +
88 + //---STATIC ATTRIBUTES---
89  
90   } // class

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines