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); |
158 |
|
|
159 |
|
_machine_name.setText(packet.getParam("packet.attributes.machine_name")); |
160 |
|
_ip.setText(packet.getParam("packet.attributes.ip")); |
161 |
< |
_date.setText(packet.getParam("packet.attributes.date")); |
161 |
> |
_date.setText(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(packet.getParam("packet.attributes.date"))))); |
162 |
|
_seq_no.setText(packet.getParam("packet.attributes.seq_no")); |
163 |
|
|
164 |
|
_sTime.setText(packet.getParam("packet.sTime")); |
172 |
|
_processes_zombie.setText(packet.getParam("packet.processes.zombie")); |
173 |
|
_processes_stopped.setText(packet.getParam("packet.processes.stopped")); |
174 |
|
|
175 |
< |
_cpu_idle.setText(packet.getParam("packet.cpu.idle")); |
176 |
< |
_cpu_user.setText(packet.getParam("packet.cpu.user")); |
177 |
< |
_cpu_kernel.setText(packet.getParam("packet.cpu.kernel")); |
178 |
< |
_cpu_iowait.setText(packet.getParam("packet.cpu.iowait")); |
179 |
< |
_cpu_swap.setText(packet.getParam("packet.cpu.swap")); |
175 |
> |
_cpu_idle.setString(packet.getParam("packet.cpu.idle") + "%"); |
176 |
> |
_cpu_idle.setValue(new Double(packet.getParam("packet.cpu.idle")).intValue()); |
177 |
> |
_cpu_user.setString(packet.getParam("packet.cpu.user") + "%"); |
178 |
> |
_cpu_user.setValue(new Double(packet.getParam("packet.cpu.user")).intValue()); |
179 |
> |
_cpu_kernel.setString(packet.getParam("packet.cpu.kernel") + "%"); |
180 |
> |
_cpu_kernel.setValue(new Double(packet.getParam("packet.cpu.kernel")).intValue()); |
181 |
> |
_cpu_iowait.setString(packet.getParam("packet.cpu.iowait") + "%"); |
182 |
> |
_cpu_iowait.setValue(new Double(packet.getParam("packet.cpu.iowait")).intValue()); |
183 |
> |
_cpu_swap.setString(packet.getParam("packet.cpu.swap") + "%"); |
184 |
> |
_cpu_swap.setValue(new Double(packet.getParam("packet.cpu.swap")).intValue()); |
185 |
|
|
186 |
|
_memory_real.setText(packet.getParam("packet.memory.real")); |
187 |
|
_memory_free.setText(packet.getParam("packet.memory.free")); |
193 |
|
|
194 |
|
//---PRIVATE METHODS--- |
195 |
|
|
196 |
< |
protected JPanel makeTextPanel(String text, JLabel item) { |
196 |
> |
protected JPanel makeTextPanel(String text, Component item) { |
197 |
|
JPanel panel = new JPanel(false); |
198 |
|
JLabel label = new JLabel(text); |
199 |
|
label.setHorizontalAlignment(JLabel.RIGHT); |
200 |
< |
item.setHorizontalAlignment(JLabel.LEFT); |
200 |
> |
//item.setHorizontalAlignment(JLabel.LEFT); |
201 |
|
panel.setLayout(new GridLayout(1, 2)); |
202 |
|
panel.add(label); |
203 |
|
panel.add(item); |
225 |
|
JLabel _processes_zombie = new JLabel(); |
226 |
|
JLabel _processes_stopped = new JLabel(); |
227 |
|
|
228 |
< |
JLabel _cpu_idle = new JLabel(); |
229 |
< |
JLabel _cpu_user = new JLabel(); |
230 |
< |
JLabel _cpu_kernel = new JLabel(); |
231 |
< |
JLabel _cpu_iowait = new JLabel(); |
232 |
< |
JLabel _cpu_swap = new JLabel(); |
228 |
> |
int min = 0; |
229 |
> |
int max = 100; |
230 |
> |
JProgressBar _cpu_idle = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
231 |
> |
{ |
232 |
> |
_cpu_idle.setStringPainted(true); |
233 |
> |
} |
234 |
> |
JProgressBar _cpu_user = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
235 |
> |
{ |
236 |
> |
_cpu_user.setStringPainted(true); |
237 |
> |
} |
238 |
> |
JProgressBar _cpu_kernel = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
239 |
> |
{ |
240 |
> |
_cpu_kernel.setStringPainted(true); |
241 |
> |
} |
242 |
> |
JProgressBar _cpu_iowait = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
243 |
> |
{ |
244 |
> |
_cpu_iowait.setStringPainted(true); |
245 |
> |
} |
246 |
> |
JProgressBar _cpu_swap = new JProgressBar(JProgressBar.HORIZONTAL, min, max); |
247 |
> |
{ |
248 |
> |
_cpu_swap.setStringPainted(true); |
249 |
> |
} |
250 |
|
|
251 |
|
JLabel _memory_real = new JLabel(); |
252 |
|
JLabel _memory_free = new JLabel(); |