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.2 by ab11, Mon Nov 27 20:36:30 2000 UTC vs.
Revision 1.3 by ab11, Thu Nov 30 04:11:00 2000 UTC

# Line 2 | Line 2
2  
3   //---IMPORTS---
4  
5 + import java.util.Random;
6 +
7   /**
8   * Gathers system information then outputs it as XML
9   * Collects data based on properties gained from the configurator
# Line 34 | Line 36 | class SystemMonitor {
36  
37          // why oh why wont ultra edit let me put Long in the next line? oh its trying to
38          // correct keywords =|
39 <        checkInterval = Long.parseLong(config.getProperty("UDPINTEVAL"));
39 >        checkInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000;
40 >        // make the check interval into seconds
41          
42      }
43  
# Line 49 | Line 52 | class SystemMonitor {
52          // called to retrieve the stored averages and output them as a XML string
53          XMLFormatter xml = new XMLFormatter("packet");
54          
55 +        Random rand = new Random();
56 +        
57          // just send some dummy info for now.
58          xml.addNest("packet_info");
59              String currentTime = Long.toString(System.currentTimeMillis());
# Line 56 | Line 61 | class SystemMonitor {
61              xml.addElement("sequence", Integer.toString(sequence));
62          xml.closeNest();
63          xml.addNest("core");
64 <            xml.addElement("cpu","100");
65 <            xml.addElement("memory","200");
64 >            xml.addElement("cpu",""+rand.nextInt(100));
65 >            xml.addElement("memory",""+rand.nextInt(100));
66          xml.closeNest();
67 <        xml.addNest("additional");
68 <            xml.addElement("users","20");
69 <        xml.closeNest();
70 <        
67 >        if ( rand.nextBoolean() ){
68 >                xml.addNest("additional");
69 >                    xml.addElement("users",""+rand.nextInt(30));
70 >                xml.closeNest();
71 >        }
72          // MUST FIX THIS..!!!!
73 <        while ( System.currentTimeMillis() < ( lastCheck + checkInterval ) ){
74 <          // errm do nothing.. block or something.      
73 >        try {
74 >                Thread.sleep(( lastCheck + checkInterval )-System.currentTimeMillis());
75          }
76 +        catch( InterruptedException e ){
77 +                System.out.println("Sleep interrupted");
78 +        }
79          
80          // increment sequence.
81          sequence++;
82 +        lastCheck = System.currentTimeMillis();
83                  
84          // finally return a string
85          return xml.returnXML();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines