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.4 by ab11, Thu Nov 30 17:33:36 2000 UTC vs.
Revision 1.7 by ab11, Fri Dec 8 15:45:28 2000 UTC

# Line 2 | Line 2
2  
3   //---IMPORTS---
4  
5 < import java.util.Random;
5 > import java.io.*;
6 > import java.net.*;
7 > import java.util.*;
8  
9   /**
10   * Gathers system information then outputs it as XML
# Line 31 | Line 33 | class SystemMonitor {
33          // like things to monitor
34          
35          lastCheck = System.currentTimeMillis();
36 <        sequence = 0;
36 >        sequence = 1;
37  
38  
39          // why oh why wont ultra edit let me put Long in the next line? oh its trying to
40          // correct keywords =|
41 +        /*
42 +        
43          try {
44                  udpcheckInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000;
45          }
# Line 44 | Line 48 | class SystemMonitor {
48                  // 5 mins
49                  udpcheckInterval = 5000 * 60;
50          }
51 +        */
52 +        
53          // make the check interval into seconds
54          
55      }
# Line 57 | Line 63 | class SystemMonitor {
63      */
64      public String getInfo(){
65          // called to retrieve the stored averages and output them as a XML string
66 <        XMLFormatter xml = new XMLFormatter("packet");
66 >        String host = new String();
67 >        String ip = new String();
68 >        try {
69 >            host = InetAddress.getLocalHost().getHostName();
70 >                    ip = InetAddress.getLocalHost().getHostAddress();
71 >        } catch(UnknownHostException e) {
72 >            System.out.println(e);
73 >        }
74 >                String date = Long.toString(System.currentTimeMillis());
75 >        XMLFormatter xml = new XMLFormatter("packet", "machine_name=\""+host+"\" ip=\""+ip+"\" date=\""+date+"\" seq_no=\""+sequence+"\"");
76 >
77 >            // get and decode the data
78 >            DecodeCPU_TXT details = new DecodeCPU_TXT();
79 >
80 >        // add the decoded info
81 >        xml.addString(details.getItems());
82          
62        Random rand = new Random();
83          
84 <        // just send some dummy info for now.
65 <        xml.addNest("packet_info");
66 <            String currentTime = Long.toString(System.currentTimeMillis());
67 <            xml.addElement("date_time", currentTime );
68 <            xml.addElement("sequence", Integer.toString(sequence));
69 <        xml.closeNest();
70 <        xml.addNest("core");
71 <            xml.addElement("cpu",""+rand.nextInt(100));
72 <            xml.addElement("memory",""+rand.nextInt(100));
73 <        xml.closeNest();
74 <        if ( rand.nextBoolean() ){
75 <                xml.addNest("additional");
76 <                    xml.addElement("users",""+rand.nextInt(30));
77 <                xml.closeNest();
78 <        }
84 >        /*
85          // MUST FIX THIS..!!!!
86          try {
87                  long updateIn = ( lastCheck + udpcheckInterval )-System.currentTimeMillis();
# Line 90 | Line 96 | class SystemMonitor {
96          catch( InterruptedException e ){
97                  System.out.println("Sleep interrupted");
98          }
99 +        */
100          
101          // increment sequence.
102          sequence++;
103 <        lastCheck = System.currentTimeMillis();
103 >        // lastCheck = System.currentTimeMillis();
104                  
105          // finally return a string
106          return xml.returnXML();
# Line 107 | Line 114 | class SystemMonitor {
114  
115      private long lastCheck;
116      private int sequence;
110    private long udpcheckInterval;
111    private final long defaultUpdateTime = 60000;
117  
118   //---STATIC ATTRIBUTES---
119  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines