ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/java/SystemMonitor.java
Revision: 1.2
Committed: Mon Nov 27 20:36:30 2000 UTC (24 years ago) by ab11
Branch: MAIN
Changes since 1.1: +82 -44 lines
Log Message:
changed the layout so it conforms to the Templateclass.java

File Contents

# Content
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: ab11 $
12 * @version $Id: SystemMonitor.java,v 1.1 2000/11/27 20:28 ab11 Exp $
13 */
14 class SystemMonitor {
15
16 //---FINAL ATTRIBUTES---
17
18 //---STATIC METHODS---
19
20 //---CONSTRUCTORS---
21
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
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