ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/Conient.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/Conient.java (file contents):
Revision 1.4 by ajm, Mon Jan 15 00:12:31 2001 UTC vs.
Revision 1.6 by ajm, Mon Jan 15 03:15:06 2001 UTC

# Line 29 | Line 29 | public class SwingClient extends JFrame implements Run
29       */
30      public final String REVISION = "$Revision$";
31      
32 <    private final int width = 300;
32 >    private final int width = 400;
33      private final int height = 700;
34      
35   //---STATIC METHODS---
36  
37      public static void main(String[] args) {
38          try {
39 <            String host = args[0];
39 >            String host = null;
40 >            if (args.length != 1) {
41 >                Object response = null;
42 >                while(!(response instanceof String)) {
43 >                    response = JOptionPane.showInputDialog(null, "Please enter the name of a server running the I-Scream client interface:", "I-Scream Server", JOptionPane.INFORMATION_MESSAGE);
44 >                }
45 >                host = (String) response;
46 >            } else {
47 >                host = args[0];
48 >            }
49 >
50              int port = 4510;
51              Socket socket = new Socket(host, port);
52              BufferedReader inBound = new BufferedReader(new InputStreamReader(socket.getInputStream()));
53              PrintWriter outBound = new PrintWriter(socket.getOutputStream());
54              DataReader data = new DataReader(inBound);
55          
56 <            SwingClient cli = new SwingClient(data);
57 <            Thread cliThread = new Thread(cli);
58 <            cliThread.start();
56 >            SwingClient client = new SwingClient(data);
57 >            Thread clientThread = new Thread(client);
58 >            clientThread.start();
59          } catch (Exception e) {
60              System.err.println("ERROR START: " + e);
61 +            System.exit(1);
62          }  
63      }
64      
# Line 73 | Line 84 | public class SwingClient extends JFrame implements Run
84          header.add(Box.createHorizontalGlue());
85          header.add(iscream);
86          
76        
77        
87          //_tabbedPane.setSelectedIndex(0);
88          
89          // build the frame
# Line 93 | Line 102 | public class SwingClient extends JFrame implements Run
102      public void run() {
103          HashMap hostList = new HashMap();
104          try {
105 <        _data.start();
106 <        while(true) {
107 <            synchronized (_data) {
108 <                _data.wait();
105 >            _data.start();
106 >            while(true) {
107 >                synchronized (_data) {
108 >                    _data.wait();
109 >                }
110 >                String xml = _data.getXML();
111 >                if (xml == null) {
112 >                    // shouldn't really happen...but not sure
113 >                    _status.setText("No XML to update...");
114 >                } else {
115 >                    _status.setText("Got inbound data...handling");
116 >                    // Get a string without any null characters in it.
117 >                    //  -- maybe String.trim() would be better here ?
118 >                    if (xml.indexOf(0) != -1) {
119 >                        xml = xml.substring(0, xml.indexOf(0));
120 >                    }
121 >                    else {
122 >                        xml = xml.substring(0, xml.length());
123 >                    }
124 >                    
125 >                    // Use XMLPacketMaker to make an XMLPacket object.
126 >                    XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
127 >                    XMLPacket packet = xmlPacketMaker.createXMLPacket();
128 >                    String hostName = packet.getParam("packet.attributes.machine_name");
129 >                    if(!hostList.containsKey(hostName)) {
130 >                        host = new HostDisplayPanel();      
131 >                        _tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName);
132 >                        hostList.put(hostName, host);
133 >                        _status.setText("New Host added: " + hostName);
134 >                    }
135 >                    ((HostDisplayPanel) hostList.get(hostName)).updateHost(packet);
136 >                }
137              }
101            String xml = _data.getXML();
102            if (xml == null) {
103                _status.setText("No XML to update...");
104            } else {
105            
106            // Get a string without any null characters in it.
107            //  -- maybe String.trim() would be better here ?
108            if (xml.indexOf(0) != -1) {
109                xml = xml.substring(0, xml.indexOf(0));
110            }
111            else {
112                xml = xml.substring(0, xml.length());
113            }
114            
115            // Use XMLPacketMaker to make an XMLPacket object.
116            XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
117            XMLPacket packet = xmlPacketMaker.createXMLPacket();
118            String hostName = packet.getParam("packet.attributes.machine_name");
119            if(!hostList.containsKey(hostName)) {
120                host = new HostDisplayPanel();      
121                _tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName);
122                hostList.put(hostName, host);
123                _status.setText("New Host added: " + hostName);
124            }
125            ((HostDisplayPanel) hostList.get(hostName)).updateHost(packet);
126            }
127        }
138          } catch (Exception e) {
139              System.err.println("ERROR RUN: " + e);
140          }
# Line 147 | Line 157 | public class SwingClient extends JFrame implements Run
157   //---ACCESSOR/MUTATOR METHODS---
158  
159   //---ATTRIBUTES---
160 +
161      HostDisplayPanel host;
162      JTabbedPane _tabbedPane = new JTabbedPane();
152
153    JLabel _machine_name = new JLabel();
154    JLabel _ip = new JLabel();
155    JLabel _date = new JLabel();
156    JLabel _seq_no = new JLabel();
157    
158    JLabel _sTime = new JLabel();
159    
160    JLabel _load_load1 = new JLabel();
161    JLabel _load_load5 = new JLabel();
162    JLabel _load_load15 = new JLabel();
163    
164    JLabel _processes_total = new JLabel();
165    JLabel _processes_sleeping = new JLabel();
166    JLabel _processes_zombie = new JLabel();
167    JLabel _processes_stopped = new JLabel();
168    
169    int min = 0;
170    int max = 100;
171    JProgressBar _cpu_idle = new JProgressBar(JProgressBar.HORIZONTAL, min, max);
172    {
173        _cpu_idle.setStringPainted(true);
174    }
175    JProgressBar _cpu_user = new JProgressBar(JProgressBar.HORIZONTAL, min, max);
176    {
177        _cpu_user.setStringPainted(true);
178    }
179    JProgressBar _cpu_kernel = new JProgressBar(JProgressBar.HORIZONTAL, min, max);
180    {
181        _cpu_kernel.setStringPainted(true);
182    }
183    JProgressBar _cpu_iowait = new JProgressBar(JProgressBar.HORIZONTAL, min, max);
184    {
185        _cpu_iowait.setStringPainted(true);
186    }
187    JProgressBar _cpu_swap = new JProgressBar(JProgressBar.HORIZONTAL, min, max);
188    {
189        _cpu_swap.setStringPainted(true);
190    }
191    
192    JLabel _memory_real = new JLabel();
193    JLabel _memory_free = new JLabel();
194    JLabel _memory_swapinuse = new JLabel();
195    JLabel _memory_swapfree = new JLabel();
163      DataReader _data;
164      JLabel _status = new JLabel();
165      ImageIcon _serverIcon = new ImageIcon("server.gif");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines