ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/HostDisplayPanel.java
Revision: 1.52
Committed: Sun Aug 1 10:40:06 2004 UTC (19 years, 9 months ago) by tdb
Branch: MAIN
Changes since 1.51: +3 -3 lines
Log Message:
Catch a lot of old URL's and update them. Also remove a couple of old files
that aren't used.

File Contents

# User Rev Content
1 tdb 1.41 /*
2     * i-scream central monitoring system
3 tdb 1.52 * http://www.i-scream.org
4 tdb 1.41 * Copyright (C) 2000-2002 i-scream
5     *
6     * This program is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19     */
20    
21 ajm 1.1 //---PACKAGE DECLARATION---
22 tdb 1.39 package uk.org.iscream.cms.conient;
23 ajm 1.1
24     //---IMPORTS---
25 tdb 1.46 import uk.org.iscream.cms.util.*;
26 tdb 1.39 import uk.org.iscream.cms.conient.datacomponents.*;
27 ajm 1.4 import java.util.HashMap;
28     import java.util.Set;
29     import java.util.Collections;
30     import java.util.Iterator;
31     import javax.swing.BoxLayout;
32     import javax.swing.JPanel;
33     import javax.swing.JProgressBar;
34 ajm 1.13 import javax.swing.JButton;
35     import javax.swing.JLabel;
36     import javax.swing.JFrame;
37     import javax.swing.Box;
38     import java.awt.event.*;
39 ajm 1.31 import java.awt.*;
40 ajm 1.15 import javax.swing.SwingUtilities;
41 tdb 1.17 import javax.swing.ImageIcon;
42 ajm 1.1
43     /**
44 ajm 1.7 * A HostDisplayPanel is simply a JPanel containing
45     * DataComponents which relate to various host
46     * attributes. Once created, it can be asked to
47     * update the data it displays by passing it an XML
48     * packet for the host it displaying for.
49     * This then updates all the DataComponents with the
50     * values in the packet.
51 ajm 1.1 *
52 tdb 1.41 * @author $Author: tdb $
53 tdb 1.52 * @version $Id: HostDisplayPanel.java,v 1.51 2003/03/11 21:41:25 tdb Exp $
54 ajm 1.1 */
55     public class HostDisplayPanel extends JPanel {
56    
57     //---FINAL ATTRIBUTES---
58    
59     /**
60     * The current CVS revision of this class
61     */
62 tdb 1.52 public final String REVISION = "$Revision: 1.51 $";
63 ajm 1.1
64     //---STATIC METHODS---
65    
66     //---CONSTRUCTORS---
67    
68     /**
69 ajm 1.7 * Creates a new Host Display Panel and adds
70     * all the appropriate DataComponents
71 ajm 1.1 */
72 ajm 1.13 public HostDisplayPanel(String hostName) {
73 ajm 1.33 super();
74    
75 ajm 1.7 // set up the Panel
76 ajm 1.4 setLayout(new BorderLayout());
77 ajm 1.13 _hostName = hostName;
78    
79 ajm 1.16 // check to config to see if we want extra data or not
80 ajm 1.25 if(Configuration.getInstance().getProperty("displayExtraData").equals("1")) {
81 ajm 1.27 _extraData = true;
82 ajm 1.16 }
83 ajm 1.13
84 ajm 1.31 GridBagLayout gridbag = new GridBagLayout();
85     GridBagConstraints c = new GridBagConstraints();
86     c.fill = GridBagConstraints.HORIZONTAL;
87     c.anchor = GridBagConstraints.NORTH;
88     c.weighty = 1.0;
89     _center.setLayout(gridbag);
90    
91 ajm 1.32 JPanel centerHolder = new JPanel();
92     centerHolder.add(_center);
93     add(centerHolder, "Center");
94 ajm 1.13 add(_north, "North");
95 ajm 1.29
96 ajm 1.13 addDataComponent(new StringDataComponent("Packet Type", "packet.attributes.type"));
97    
98     final StringDataComponent machineName = new StringDataComponent("Host Name", "packet.attributes.machine_name");
99     addDataComponent(machineName );
100     final StringDataComponent ip = new StringDataComponent("IP Address", "packet.attributes.ip");
101     addDataComponent(ip);
102 ajm 1.18 final UptimeDataComponent uptime = new UptimeDataComponent("Uptime", "packet.os.uptime");
103 ajm 1.13 addDataComponent(uptime);
104 ajm 1.15 final StringDataComponent seq_no = new StringDataComponent("Packets since host started", "packet.attributes.seq_no");
105     addDataComponent(seq_no);
106 ajm 1.13
107     final StringDataComponent osName = new StringDataComponent("Operating System", "packet.os.name");
108     addDataComponent(osName );
109     final StringDataComponent osVer = new StringDataComponent("Operating System Version", "packet.os.version");
110     addDataComponent(osVer);
111     final StringDataComponent osRelease = new StringDataComponent("Operating System Release", "packet.os.release");
112     addDataComponent(osRelease);
113     final StringDataComponent osSysName = new StringDataComponent("System Name", "packet.os.sysname");
114     addDataComponent(osSysName );
115 ajm 1.32 final StringDataComponent netbiosName = new StringDataComponent("NetBIOS Name", "packet.os.netbios_name");
116     addDataComponent(netbiosName );
117 ajm 1.13 final StringDataComponent osPlatform = new StringDataComponent("System Architecture", "packet.os.platform");
118     addDataComponent(osPlatform );
119    
120     JButton info = new JButton("Platform Information");
121     info.addActionListener(new ActionListener() {
122     public void actionPerformed(ActionEvent e) {
123     final JFrame infoFrame = new JFrame("Host platform information for - " + _hostName);
124     Box content = Box.createVerticalBox();
125     content.add(machineName);
126     content.add(ip);
127     content.add(uptime);
128 ajm 1.15 content.add(seq_no);
129 ajm 1.13 content.add(osName);
130     content.add(osVer);
131     content.add(osRelease);
132     content.add(osSysName);
133 ajm 1.32 content.add(netbiosName);
134 ajm 1.13 content.add(osPlatform);
135     infoFrame.getContentPane().add(content, "Center");
136     JButton close = new JButton("Close Window");
137     close.addActionListener(new ActionListener() {
138     public void actionPerformed(ActionEvent e) {
139     infoFrame.dispose();
140     }
141     });
142     infoFrame.getContentPane().add(close, "South");
143 tdb 1.45 infoFrame.setIconImage((new ImageIcon(getClass().getResource("/resources/server.gif"))).getImage());
144 ajm 1.13 infoFrame.pack();
145     infoFrame.setVisible(true);
146     }
147     });
148 ajm 1.29 try {
149 ajm 1.35 _dataTimer = new PacketTimer("Next Data", Integer.parseInt(Configuration.getInstance().getServerProperty("Host." + hostName, "Host.UDPUpdateTime")));
150 ajm 1.29 } catch (NumberFormatException e) {
151 tdb 1.47 throw new NumberFormatException("unable to obtain a valid value for Host.UDPUpdateTime");
152 ajm 1.29 }
153 tdb 1.47 _north.setLayout(new GridLayout(3,1));
154     _north.add(new JLabel("Showing data from - " + hostName, JLabel.CENTER));
155     _north.add(_dataTimer);
156     _north.add(info);
157 ajm 1.36
158 ajm 1.13
159 ajm 1.19 JPanel date = new JPanel();
160     addVisibleDataComponent(date, new DateDataComponent("Host Time", "packet.attributes.date"));
161 ajm 1.31 c.gridy = 0;
162     gridbag.setConstraints(date, c);
163 ajm 1.19 _center.add(date);
164 ajm 1.13
165 ajm 1.31 // holder for labels
166     JLabel label;
167    
168     label = new javax.swing.JLabel("--- CPU ---", JLabel.CENTER);
169     c.gridy = 1;
170     gridbag.setConstraints(label, c);
171     _center.add(label);
172 tdb 1.6
173 ajm 1.7 // add all the DataComponents that we know about
174 ajm 1.13 JPanel cpu = new JPanel();
175     cpu.setLayout(new BoxLayout(cpu, BoxLayout.Y_AXIS));
176     addVisibleDataComponent(cpu, new CPUDataComponent("CPU Idle", "packet.cpu.idle"));
177     addVisibleDataComponent(cpu, new CPUDataComponent("CPU User", "packet.cpu.user"));
178     addVisibleDataComponent(cpu, new CPUDataComponent("CPU Kernel", "packet.cpu.kernel"));
179     addVisibleDataComponent(cpu, new CPUDataComponent("CPU i/o wait", "packet.cpu.iowait"));
180     addVisibleDataComponent(cpu, new CPUDataComponent("CPU swapping", "packet.cpu.swap"));
181 ajm 1.31 c.gridy = 2;
182     gridbag.setConstraints(cpu, c);
183 ajm 1.13 _center.add(cpu);
184    
185 ajm 1.31 label = new javax.swing.JLabel("--- Load ---", JLabel.CENTER);
186     c.gridy = 3;
187     gridbag.setConstraints(label, c);
188     _center.add(label);
189 ajm 1.13
190     Box loadData = Box.createHorizontalBox();
191     addVisibleDataComponent(loadData, new ProcessesDataComponent("1 minute", "packet.load.load1"));
192     addVisibleDataComponent(loadData, new ProcessesDataComponent("5 minutes", "packet.load.load5"));
193     addVisibleDataComponent(loadData, new ProcessesDataComponent("15 minutes", "packet.load.load15"));
194 ajm 1.31
195     c.gridy = 4;
196     gridbag.setConstraints(loadData, c);
197 ajm 1.13 _center.add(loadData);
198    
199 ajm 1.31 label = new javax.swing.JLabel("--- Processes ---", JLabel.CENTER);
200     c.gridy = 5;
201     gridbag.setConstraints(label, c);
202     _center.add(label);
203 ajm 1.13
204     Box processesData = Box.createHorizontalBox();
205     addVisibleDataComponent(processesData, new ProcessesDataComponent("Total", "packet.processes.total"));
206     addVisibleDataComponent(processesData, new ProcessesDataComponent("Running", "packet.processes.cpu"));
207     addVisibleDataComponent(processesData, new ProcessesDataComponent("Sleeping", "packet.processes.sleeping"));
208     addVisibleDataComponent(processesData, new ProcessesDataComponent("Stopped", "packet.processes.stopped"));
209     addVisibleDataComponent(processesData, new ProcessesDataComponent("Zombie", "packet.processes.zombie"));
210 ajm 1.31 c.gridy = 6;
211     gridbag.setConstraints(processesData, c);
212 ajm 1.13 _center.add(processesData);
213 ajm 1.30
214 ajm 1.31 label = new javax.swing.JLabel("--- Memory ---", JLabel.CENTER);
215     c.gridy = 7;
216     gridbag.setConstraints(label, c);
217     _center.add(label);
218 tdb 1.6
219 ajm 1.7 // these next two are passed the non-visible datacomponents
220 ajm 1.13 JPanel memory = new JPanel();
221     memory.setLayout(new BoxLayout(memory, BoxLayout.Y_AXIS));
222 tdb 1.48 addVisibleDataComponent(memory, new StorageDataComponent("Memory in use", "packet.memory.free", "packet.memory.total", "Mb", 1024*1024));
223     addVisibleDataComponent(memory, new StorageDataComponent("Swap in use", "packet.swap.free", "packet.swap.total", "Mb", 1024*1024));
224 tdb 1.49 addVisibleDataComponent(memory, new IODataComponent("Pages in/out", "packet.pages.pageins", "packet.pages.pageouts"));
225 ajm 1.30 // theses next two are DataComponents, but not VisibleDataComponents
226     // this is because they hold the value but do NOT display it
227     // just so we ignore the data, because the StorageDataComponent handles it
228 tdb 1.51 addDataComponent(new StringDataComponent("packet.pages.pageouts", "packet.pages.pageouts"));
229 ajm 1.30 addDataComponent(new StringDataComponent("packet.memory.total", "packet.memory.total"));
230 tdb 1.43 addDataComponent(new StringDataComponent("packet.memory.used", "packet.memory.used"));
231     // maybe this one should be used somewhere?
232     addDataComponent(new StringDataComponent("packet.memory.cache", "packet.memory.cache"));
233 ajm 1.30 addDataComponent(new StringDataComponent("packet.swap.total", "packet.swap.total"));
234 tdb 1.43 addDataComponent(new StringDataComponent("packet.swap.used", "packet.swap.used"));
235 ajm 1.31 c.gridy = 8;
236     gridbag.setConstraints(memory, c);
237 ajm 1.13 _center.add(memory);
238 tdb 1.48
239     label = new javax.swing.JLabel("--- Network ---", JLabel.CENTER);
240     c.gridy = 9;
241     gridbag.setConstraints(label, c);
242     _center.add(label);
243     c.gridy = 10;
244     gridbag.setConstraints(_net, c);
245     _center.add(_net);
246 ajm 1.19
247 ajm 1.31 label = new javax.swing.JLabel("--- Users ---", JLabel.CENTER);
248 tdb 1.48 c.gridy = 11;
249 ajm 1.31 gridbag.setConstraints(label, c);
250     _center.add(label);
251    
252 ajm 1.19 JPanel users = new JPanel();
253 ajm 1.31 users.setLayout(new BoxLayout(users, BoxLayout.Y_AXIS));
254 ajm 1.19 addVisibleDataComponent(users, new StringDataComponent("Number of users", "packet.users.count"));
255     UsersDataComponent userList = new UsersDataComponent("User List", "packet.users.list");
256     addVisibleDataComponent(users, userList);
257 tdb 1.48 c.gridy = 12;
258 ajm 1.31 gridbag.setConstraints(users, c);
259 ajm 1.19 _center.add(users);
260 ajm 1.31
261     label = new javax.swing.JLabel("--- Disks ---", JLabel.CENTER);
262 tdb 1.48 c.gridy = 13;
263 ajm 1.31 gridbag.setConstraints(label, c);
264     _center.add(label);
265 tdb 1.48 c.gridy = 14;
266 ajm 1.31 gridbag.setConstraints(_disks, c);
267 ajm 1.14 _center.add(_disks);
268 tdb 1.48 c.gridy = 15;
269     gridbag.setConstraints(_diskio, c);
270     _center.add(_diskio);
271 ajm 1.14
272 ajm 1.31 label = new javax.swing.JLabel("--- System Services ---", JLabel.CENTER);
273 tdb 1.48 c.gridy = 16;
274 ajm 1.31 gridbag.setConstraints(label, c);
275     _center.add(label);
276 tdb 1.48 c.gridy = 17;
277 ajm 1.31 gridbag.setConstraints(_services, c);
278 ajm 1.20 _center.add(_services);
279    
280 ajm 1.16 // everything else we get is "extra", but we may still want to display it
281 ajm 1.27 if (_extraData) {
282 ajm 1.31 label = new javax.swing.JLabel("--- Extra Data ---", JLabel.CENTER);
283 tdb 1.48 c.gridy = 18;
284 ajm 1.31 gridbag.setConstraints(label, c);
285     _center.add(label);
286 tdb 1.48 c.gridy = 19;
287 ajm 1.31 gridbag.setConstraints(_extra, c);
288 ajm 1.20 _center.add(_extra);
289 ajm 1.16 }
290 ajm 1.37
291     // a bit of a gap, then a banner to advertise the product
292 tdb 1.48 c.gridy=20;
293 ajm 1.37 Component spacer = Box.createRigidArea(new Dimension(468, 30));
294     gridbag.setConstraints(spacer,c);
295     _center.add(spacer);
296 tdb 1.48 c.gridy=21;
297 tdb 1.45 JLabel image = new JLabel(new ImageIcon(getClass().getResource("/resources/banner3.gif")));
298 ajm 1.37 gridbag.setConstraints(image,c);
299     _center.add(image);
300 ajm 1.1 }
301    
302     //---PUBLIC METHODS---
303    
304 ajm 1.7 /**
305     * This method takes an XMLPacket containing
306     * information about the host this HostDisplayPanel
307     * is currently displaying. It then updates all of the
308     * components with the new values.
309     *
310     * It also adds a standard StringDataComponent, should
311     * an attribute come up that there are no DataComponents
312     * associated with.
313     *
314     * @param packet the XML packet
315     * @return if the update was sucessful
316     */
317     public boolean updateHost(XMLPacket packet) {
318     // set that everything is ok so far
319 ajm 1.20 boolean displaySucessful = true;
320 ajm 1.7
321     // must be a normal data packet, update the display
322 tdb 1.47 if((packet.getParam("packet.attributes.type")).equals("data")) {
323 ajm 1.27 displaySucessful = processPacket(packet);
324 ajm 1.12 _dataTimer.reset();
325     if(_dataTimerThread == null){
326     _dataTimerThread = new Thread(_dataTimer);
327     _dataTimerThread.start();
328     }
329 ajm 1.20 }
330     return displaySucessful;
331     }
332    
333     //---PRIVATE METHODS---
334    
335     /**
336     * Process an incoming packet, updates the components.
337     * If extra data is configured to be displayed, it will
338     * create a new StringDataComponent to display the data.
339     *
340     * @param packet the packet to process
341     *
342     * @return if the proceesing was successful
343     */
344 ajm 1.27 private boolean processPacket(XMLPacket packet) {
345 ajm 1.20 // iterate over the packets data
346     boolean displaySucessful = true;
347     Set packetSet = packet.getSet();
348     Iterator i = packetSet.iterator();
349     while (i.hasNext()) {
350     String dataKey = (String) i.next();
351    
352     // if there are no components looking after this data
353     // create a new StringDataComponent for it
354     if(!_components.containsKey(dataKey)) {
355     // check if its a disk drive, if it is then we need to deal with it
356     if(dataKey.startsWith("packet.disk.p")) {
357 tdb 1.40 createDiskPanel(dataKey, packet);
358 tdb 1.48 // check for diskio stats
359     } else if(dataKey.startsWith("packet.diskio.p")) {
360     createDiskIOPanel(dataKey, packet);
361     // check for network stats
362     } else if(dataKey.startsWith("packet.net.p")) {
363     createNetworkPanel(dataKey, packet);
364 ajm 1.20 // !check for services here! to display
365 ajm 1.27 } else if(dataKey.startsWith("packet.services.")) {
366     createServicesPanel(dataKey);
367 tdb 1.48 // otherwise we don't know about it...
368 ajm 1.27 } else if (_extraData) {
369     addVisibleDataComponent(_extra, new StringDataComponent(dataKey, dataKey));
370 ajm 1.4 }
371 ajm 1.20 }
372 ajm 1.22
373 ajm 1.20 // try and update the component, if it doesn't like what it gets
374     // warn the user and set that this was an unsucessful display
375 ajm 1.22 if(_components.containsKey(dataKey)) {
376    
377     try {
378 ajm 1.30 ((DataComponent) _components.get(dataKey)).setValue(packet);
379 ajm 1.22 } catch (DataFormatException e) {
380     Conient.addMessage("WARNING{host display}: " + e.getMessage());
381     displaySucessful = false;
382     }
383 ajm 1.4 }
384 ajm 1.3 }
385 ajm 1.20 return displaySucessful;
386 ajm 1.4 }
387 ajm 1.15
388 ajm 1.7 /**
389     * Adds a DataComponent to the list of already
390     * known data components. The list is aware of
391     * what packet attributes that a DataComponent
392     * is looking after.
393     *
394     * @param ref the packet attribute that this Component looks after
395     * @param dataComponent the actual DataComponent
396     */
397 ajm 1.13 private void addDataComponent(DataComponent dataComponent) {
398     _components.put(dataComponent.getPacketAttribute(), dataComponent);
399 ajm 1.7 }
400    
401     /**
402     * Adds a DataComponent to the list of already
403     * known data components. The list is aware of
404     * what packet attributes that a DataComponent
405     * is looking after.
406     *
407     * Used for VISIBLE data components, as they are added to the display.
408     *
409     * @param ref the packet attribute that this Component looks after
410     * @param dataComponent the actual DataComponent
411     */
412 ajm 1.13 public void addVisibleDataComponent(Container holder, VisibleDataComponent dataComponent) {
413     _components.put(((DataComponent) dataComponent).getPacketAttribute(), (DataComponent) dataComponent);
414 ajm 1.15 SwingSafeAdd task = new SwingSafeAdd(holder, dataComponent);
415     SwingUtilities.invokeLater(task);
416     }
417    
418     /**
419     * Creates the disk components and adds them
420     * do the list of components. It also displays
421     * any relavant component.
422     *
423     * When a packet attribute is new to the system
424     * and when it starts "packet.disk.p" then this
425     * method is called. Thus it then accounts for
426     * all attributes relating to that new disk.
427     *
428 tdb 1.48 * @param attribute the name of the attribute first encountered
429 tdb 1.40 * @param packet the XMLPacket the data is being pulled from
430 ajm 1.15 */
431 tdb 1.40 private void createDiskPanel(String attribute, XMLPacket packet) {
432 ajm 1.15 String diskNumber = "";
433    
434     // pos is after "packet.disk.p"
435     int pos = 13;
436     while (attribute.charAt(pos) != '.') {
437     diskNumber = diskNumber + attribute.charAt(pos);
438     pos++;
439     }
440 ajm 1.30 String devAttribute = "packet.disk.p" + diskNumber + ".attributes.name";
441     String mountAttribute = "packet.disk.p" + diskNumber + ".attributes.mount";
442 tdb 1.48 String totalAttribute = "packet.disk.p" + diskNumber + ".attributes.total";
443 ajm 1.30
444     // the only visible component
445     String availAttribute = "packet.disk.p" + diskNumber + ".attributes.avail";
446 tdb 1.48 DiskDataComponent disk = new DiskDataComponent("Disk", availAttribute, totalAttribute, mountAttribute, devAttribute , "Mb", 1024*1024);
447 ajm 1.30 addVisibleDataComponent(_disks, disk);
448 ajm 1.15
449 ajm 1.16 // currently this data isn't useful, so we don't display it
450     // but we add it so that it is forgotten about
451 ajm 1.30 addDataComponent(new StringDataComponent(devAttribute, devAttribute));
452     addDataComponent(new StringDataComponent(mountAttribute, mountAttribute));
453     addDataComponent(new StringDataComponent(totalAttribute, totalAttribute));
454 tdb 1.40
455     // add any further bits of data about this disk so we
456     // don't try and do something with them later
457     // -- this is not that tidy ;)
458     Set packetSet = packet.getSet();
459     Iterator i = packetSet.iterator();
460     while (i.hasNext()) {
461     String dataKey = (String) i.next();
462     if(dataKey.startsWith("packet.disk.p" + diskNumber +".") && !_components.containsKey(dataKey)) {
463     addDataComponent(new StringDataComponent(dataKey, dataKey));
464     }
465     }
466 ajm 1.1 }
467 ajm 1.27
468     /**
469 tdb 1.48 * Creates the diskio components and adds them
470     * do the list of components.
471     *
472     * When a packet attribute is new to the system
473     * and when it starts "packet.diskio.p" then this
474     * method is called. Thus it then accounts for
475     * all attributes relating to that new diskio.
476     *
477     * @param attribute the name of the attribute first encountered
478     * @param packet the XMLPacket the data is being pulled from
479     */
480     private void createDiskIOPanel(String attribute, XMLPacket packet) {
481     String diskNumber = "";
482    
483     // pos is after "packet.diskio.p"
484     int pos = 15;
485     while (attribute.charAt(pos) != '.') {
486     diskNumber = diskNumber + attribute.charAt(pos);
487     pos++;
488     }
489    
490     // grab the attributes
491     String nameAttribute = "packet.diskio.p" + diskNumber + ".attributes.name";
492     String wbytesAttribute = "packet.diskio.p" + diskNumber + ".attributes.wbytes";
493     String rbytesAttribute = "packet.diskio.p" + diskNumber + ".attributes.rbytes";
494    
495     // use an IODataComponent to display the diskio
496     IODataComponent diskio = new IODataComponent(packet.getParam(nameAttribute), rbytesAttribute, wbytesAttribute);
497     addVisibleDataComponent(_diskio, diskio);
498    
499     // these attributes are also used, so we hold on to them
500     // (as a side note, this way of "holding on" to attributes sucks ;)
501     addDataComponent(new StringDataComponent(nameAttribute, nameAttribute));
502     addDataComponent(new StringDataComponent(wbytesAttribute, wbytesAttribute));
503     }
504    
505     /**
506     * Creates the netwrok components and adds them
507     * do the list of components.
508     *
509     * When a packet attribute is new to the system
510     * and when it starts "packet.net.p" then this
511     * method is called. Thus it then accounts for
512     * all attributes relating to that network device.
513     *
514     * @param attribute the name of the attribute first encountered
515     * @param packet the XMLPacket the data is being pulled from
516     */
517     private void createNetworkPanel(String attribute, XMLPacket packet) {
518     String netNumber = "";
519    
520     // pos is after "packet.net.p"
521     int pos = 12;
522     while (attribute.charAt(pos) != '.') {
523     netNumber = netNumber + attribute.charAt(pos);
524     pos++;
525     }
526    
527     // grab the attributes
528     String nameAttribute = "packet.net.p" + netNumber + ".attributes.name";
529     String txAttribute = "packet.net.p" + netNumber + ".attributes.tx";
530     String rxAttribute = "packet.net.p" + netNumber + ".attributes.rx";
531    
532     // use an IODataComponent to display the diskio
533     IODataComponent net = new IODataComponent(packet.getParam(nameAttribute), rxAttribute, txAttribute);
534     addVisibleDataComponent(_net, net);
535    
536     // these attributes are also used, so we hold on to them
537     addDataComponent(new StringDataComponent(nameAttribute, nameAttribute));
538     addDataComponent(new StringDataComponent(txAttribute, txAttribute));
539     }
540    
541     /**
542     * Creates the servicecheck components and adds them
543 ajm 1.27 * do the list of components. It also displays
544     * any relavant component.
545     *
546     * When a packet attribute is new to the system
547 tdb 1.48 * and when it starts "packet.services." then this
548 ajm 1.27 * method is called. Thus it then accounts for
549 tdb 1.48 * all attributes relating to that service.
550 ajm 1.27 *
551 tdb 1.48 * @param attribute the name of the attribute first encountered
552 ajm 1.27 */
553     private void createServicesPanel(String attribute) {
554     String serviceType = "";
555    
556     // pos is after "packet.services."
557     int pos = 16;
558     while (attribute.charAt(pos) != '.') {
559     serviceType = serviceType + attribute.charAt(pos);
560     pos++;
561     }
562 ajm 1.30
563     String statusAttribute = "packet.services." + serviceType + ".attributes.status";
564     // we hide this as the service data component uses this attribute
565     addDataComponent(new StringDataComponent(serviceType + " service status", statusAttribute));
566 ajm 1.27
567 ajm 1.30 ServiceDataComponent service = new ServiceDataComponent(serviceType, "packet.services." + serviceType + ".attributes.message", statusAttribute);
568 ajm 1.27 addVisibleDataComponent(_services, service);
569     }
570 ajm 1.15
571     //---ACCESSOR/MUTATOR METHODS---
572 ajm 1.1
573 ajm 1.7 //---ATTRIBUTES---
574    
575     /**
576     * The components that we already know about
577     * connected with the attributes they care about
578     * are stored here.
579     */
580     private HashMap _components = new HashMap();
581 ajm 1.12
582 ajm 1.7 /**
583 ajm 1.13 * The north panel, currently used for the platform info button.
584     */
585     private final JPanel _north = new JPanel();
586 ajm 1.12
587     /**
588 ajm 1.7 * The centre panel, where all the data is displayed.
589     */
590 ajm 1.11 private final JPanel _center = new JPanel();
591 ajm 1.1
592 ajm 1.16 /**
593     * The countdown timer for normal data packets
594     */
595 ajm 1.12 private final PacketTimer _dataTimer;
596 ajm 1.16
597     /**
598     * A place for the data timer thread
599     */
600 ajm 1.12 private Thread _dataTimerThread = null;
601 ajm 1.16
602     /**
603     * The hostname this instance is keeping data for
604     */
605 ajm 1.13 private final String _hostName;
606 ajm 1.16
607     /**
608     * The disks panel
609     */
610 ajm 1.20 private final JPanel _disks = new JPanel();
611     {
612     _disks.setLayout(new BoxLayout(_disks, BoxLayout.Y_AXIS));
613 tdb 1.48 }
614    
615     /**
616     * The diskio panel
617     */
618     private final JPanel _diskio = new JPanel();
619     {
620     _diskio.setLayout(new BoxLayout(_diskio, BoxLayout.Y_AXIS));
621     }
622    
623     /**
624     * The network panel
625     */
626     private final JPanel _net = new JPanel();
627     {
628     _net.setLayout(new BoxLayout(_net, BoxLayout.Y_AXIS));
629 ajm 1.20 }
630    
631     /**
632     * The extra panel, used to display unknown data in the packet
633     */
634     private final JPanel _extra = new JPanel();
635     {
636     _extra.setLayout(new BoxLayout(_extra, BoxLayout.Y_AXIS));
637     }
638    
639     /**
640     * The services panel, currently used to display host service information
641     * from heartbeat packets.
642     */
643     private final JPanel _services = new JPanel();
644     {
645     _services.setLayout(new BoxLayout(_services, BoxLayout.Y_AXIS));
646     }
647 ajm 1.16
648     /**
649     * Whether we a worrying about "extra" data
650 ajm 1.25 * by default we don't, but we look in the configuration
651 ajm 1.16 * in the constructor.
652     */
653 ajm 1.27 private boolean _extraData = false;
654 ajm 1.14
655 ajm 1.1 //---STATIC ATTRIBUTES---
656    
657 ajm 1.3 }