9 |
|
import java.awt.event.*; |
10 |
|
import java.net.*; |
11 |
|
import java.io.*; |
12 |
+ |
import java.util.Date; |
13 |
+ |
import java.text.DateFormat; |
14 |
+ |
import java.util.Locale; |
15 |
|
|
16 |
|
/** |
17 |
|
* NASTY AND BASIC, PLEASE DON'T COMPLAIN |
81 |
|
JPanel panel2 = makeTextPanel("IP : ", _ip); |
82 |
|
JPanel panel3 = makeTextPanel("Date : ", _date); |
83 |
|
JPanel panel4 = makeTextPanel("Sequence Number : ", _seq_no); |
84 |
< |
JPanel panel5 = makeTextPanel("sTime : ", _sTime); |
84 |
> |
JPanel panel5 = makeTextPanel("Host Time : ", _sTime); |
85 |
|
JPanel panel6 = makeTextPanel("Load Average (1 min) : ", _load_load1); |
86 |
|
JPanel panel7 = makeTextPanel("Load Average (5 min) : ", _load_load5); |
87 |
|
JPanel panel8 = makeTextPanel("Load Average (15 min) : ", _load_load15); |
136 |
|
//---PUBLIC METHODS--- |
137 |
|
|
138 |
|
public void run() { |
139 |
+ |
try { |
140 |
|
_data.start(); |
141 |
|
while(true) { |
142 |
+ |
synchronized (_data) { |
143 |
+ |
_data.wait(); |
144 |
+ |
} |
145 |
|
String xml = _data.getXML(); |
146 |
|
if (xml == null) { |
147 |
|
// nothing |
162 |
|
|
163 |
|
_machine_name.setText(packet.getParam("packet.attributes.machine_name")); |
164 |
|
_ip.setText(packet.getParam("packet.attributes.ip")); |
165 |
< |
_date.setText(packet.getParam("packet.attributes.date")); |
165 |
> |
_date.setText(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(packet.getParam("packet.attributes.date"))))); |
166 |
|
_seq_no.setText(packet.getParam("packet.attributes.seq_no")); |
167 |
|
|
168 |
|
_sTime.setText(packet.getParam("packet.sTime")); |
176 |
|
_processes_zombie.setText(packet.getParam("packet.processes.zombie")); |
177 |
|
_processes_stopped.setText(packet.getParam("packet.processes.stopped")); |
178 |
|
|
179 |
< |
_cpu_idle.setText(packet.getParam("packet.cpu.idle")); |
180 |
< |
_cpu_user.setText(packet.getParam("packet.cpu.user")); |
181 |
< |
_cpu_kernel.setText(packet.getParam("packet.cpu.kernel")); |
182 |
< |
_cpu_iowait.setText(packet.getParam("packet.cpu.iowait")); |
183 |
< |
_cpu_swap.setText(packet.getParam("packet.cpu.swap")); |
179 |
> |
_cpu_idle.setString(packet.getParam("packet.cpu.idle") + "%"); |
180 |
> |
_cpu_idle.setValue(new Double(packet.getParam("packet.cpu.idle")).intValue()); |
181 |
> |
_cpu_user.setString(packet.getParam("packet.cpu.user") + "%"); |
182 |
> |
_cpu_user.setValue(new Double(packet.getParam("packet.cpu.user")).intValue()); |
183 |
> |
_cpu_kernel.setString(packet.getParam("packet.cpu.kernel") + "%"); |
184 |
> |
_cpu_kernel.setValue(new Double(packet.getParam("packet.cpu.kernel")).intValue()); |
185 |
> |
_cpu_iowait.setString(packet.getParam("packet.cpu.iowait") + "%"); |
186 |
> |
_cpu_iowait.setValue(new Double(packet.getParam("packet.cpu.iowait")).intValue()); |
187 |
> |
_cpu_swap.setString(packet.getParam("packet.cpu.swap") + "%"); |
188 |
> |
_cpu_swap.setValue(new Double(packet.getParam("packet.cpu.swap")).intValue()); |
189 |
|
|
190 |
|
_memory_real.setText(packet.getParam("packet.memory.real")); |
191 |
|
_memory_free.setText(packet.getParam("packet.memory.free")); |
193 |
|
_memory_swapfree.setText(packet.getParam("packet.memory.swapfree")); |
194 |
|
} |
195 |
|
} |
196 |
+ |
} catch (Exception e) { |
197 |
+ |
System.err.println("ERROR: " + e); |
198 |
+ |
} |
199 |
|
} |
200 |
|
|
201 |
|
//---PRIVATE METHODS--- |
202 |
|
|
203 |
< |
protected JPanel makeTextPanel(String text, JLabel item) { |
203 |
> |
protected JPanel makeTextPanel(String text, Component item) { |
204 |
|
JPanel panel = new JPanel(false); |
205 |
|
JLabel label = new JLabel(text); |
206 |
|
label.setHorizontalAlignment(JLabel.RIGHT); |
207 |
< |
item.setHorizontalAlignment(JLabel.LEFT); |
207 |
> |
//item.setHorizontalAlignment(JLabel.LEFT); |
208 |
|
panel.setLayout(new GridLayout(1, 2)); |
209 |
|
panel.add(label); |
210 |
|
panel.add(item); |
232 |
|
JLabel _processes_zombie = new JLabel(); |
233 |
|
JLabel _processes_stopped = new JLabel(); |
234 |
|
|
235 |
< |
JLabel _cpu_idle = new JLabel(); |
236 |
< |
JLabel _cpu_user = new JLabel(); |
237 |
< |
JLabel _cpu_kernel = new JLabel(); |
238 |
< |
JLabel _cpu_iowait = new JLabel(); |
239 |
< |
JLabel _cpu_swap = new JLabel(); |
235 |
> |
int min = 0; |
236 |
> |
int max = 100; |
237 |
> |
JProgressBar _cpu_idle = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
238 |
> |
{ |
239 |
> |
_cpu_idle.setStringPainted(true); |
240 |
> |
} |
241 |
> |
JProgressBar _cpu_user = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
242 |
> |
{ |
243 |
> |
_cpu_user.setStringPainted(true); |
244 |
> |
} |
245 |
> |
JProgressBar _cpu_kernel = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
246 |
> |
{ |
247 |
> |
_cpu_kernel.setStringPainted(true); |
248 |
> |
} |
249 |
> |
JProgressBar _cpu_iowait = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
250 |
> |
{ |
251 |
> |
_cpu_iowait.setStringPainted(true); |
252 |
> |
} |
253 |
> |
JProgressBar _cpu_swap = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
254 |
> |
{ |
255 |
> |
_cpu_swap.setStringPainted(true); |
256 |
> |
} |
257 |
|
|
258 |
|
JLabel _memory_real = new JLabel(); |
259 |
|
JLabel _memory_free = new JLabel(); |