CollWindowsWithTivoliSoap.java
27.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
package com.sitech.ismp.coll.tivoli;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.log4j.Logger;
import com.sitech.ismp.coll.CollBase;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.Formater;
public class CollWindowsWithTivoliSoap {
private Logger logger = Logger.getLogger("COLL");
public String kbp_class = "10-10-23";
public String neat_host_name = "";
public String host_name = "";
private boolean debug = false;
private SoapClient soapClient = null;
public CollWindowsWithTivoliSoap(HashMap params) {
this.host_name = (String) params.get("HOST_NAME");
this.neat_host_name = Formater.neatenunitid(host_name);
String url = SoapParam.getString("SOAP_URL");
soapClient = new SoapClient(url);
}
public Vector coll() {
Vector result = new Vector();
return result;
}
public Vector getPerformance_Ten_Minute() {
CollBase collResult = new CollBase();
System.out.println("HOST_NAME=" + this.host_name);
String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
logger.info("========================================ten min===");
try {
logger.info("collwindows 10min");
try {
String soap_cpu_getNT_System = CollWindowsSoapHelper
.getNT_System(soap_host_name);
String soap_cpu_SMPCPU_res = soapClient
.getSoapStringResponse(soap_cpu_getNT_System);
if (debug)
System.out.println(new Date()
+ soap_cpu_SMPCPU_res);
List cpu_results = CollHostXmlHelper
.parseSoapResponse(soap_cpu_SMPCPU_res);
Map cpu_total = null;
if (cpu_results != null && cpu_results.size() > 0) {
cpu_total = (Map) cpu_results.get(0);
}
if (cpu_total == null) {
logger
.info("@tivoli , no cpu info got by tivoli in collCpu "
+ new Date());
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "FM-00-01-900-02", "DOWN");
} else {
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "FM-00-01-900-02", "UP");
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "FM-00-01-900-02", "UP");
String privileged_time = (String) cpu_total
.get("Total_Privileged_Time");
String processor_time = (String) cpu_total
.get("Total_Processor_Time");
String user_time = (String) cpu_total
.get("Total_User_Time");
double priv = 0;
double processor = 0;
double user = 0;
double processor_busy = 0;
double processor_idle = 0;
try {
priv = Double.valueOf(privileged_time).doubleValue();
processor = Double.valueOf(processor_time)
.doubleValue();
user = Double.valueOf(user_time).doubleValue();
processor_busy = priv + processor + user;
processor_idle = 100 - processor_busy;
} catch (Exception e) {
e.printStackTrace();
}
// cpu空闲百分比
collResult.addKPI(kbp_class + "-11:" + neat_host_name
+ "-cpu", "PM-00-01-001-01", String
.valueOf(processor_idle));
collResult.addKPI(kbp_class + "-11:" + neat_host_name
+ "-cpu", "PM-00-01-001-02", String.valueOf(priv
+ processor));
collResult.addKPI(kbp_class + "-11:" + neat_host_name
+ "-cpu", "PM-00-01-001-03", (String) cpu_total
.get("Total_User_Time"));
// processor 等待硬件时间
// collResult.addKPI(kbp_class+"-11:"+neat_host_name+"-cpu","PM-00-01-001-04",(String)cpu_total.get("Total_InterruptsSec"));
// cpu忙 百分比
collResult.addKPI(kbp_class + "-11:" + neat_host_name
+ "-cpu", "PM-00-01-001-05", String
.valueOf(processor_busy));
collResult.addKPI(kbp_class + "-11:" + neat_host_name
+ "-cpu", "PM-00-01-001-06", (String) cpu_total
.get("Processor_Queue_Length"));
}
} catch (Exception e) {
e.printStackTrace();
logger.error("collwindows cpu error1");
}
try {
String soap_cpu = CollWindowsSoapHelper
.getSoap_cpu_SMPCPU(soap_host_name);
String soap_cpu_res = soapClient
.getSoapStringResponse(soap_cpu);
if (debug)
System.out.println(new Date() + soap_cpu_res);
List processor_results = CollHostXmlHelper
.parseSoapResponse(soap_cpu_res);
Map processor_total = null;
if (processor_results != null && processor_results.size() > 0) {
for (int j = 0; j < processor_results.size(); j++) {
Map processorMap = (Map) processor_results.get(j);
String processor = (String) processorMap
.get("Processor");
if ("_Total".equals(processor)) {
processor_total = processorMap;
}
}
}
if (processor_total != null) {
String Interrupt_Time = (String) processor_total
.get("Interrupt_Time");
// processor 等待硬件时间
collResult.addKPI(kbp_class + "-11:" + neat_host_name
+ "-cpu", "PM-00-01-001-04", Interrupt_Time);
}
} catch (Exception e) {
logger.error("collwindows getcpu error");
}
try {
String soap_NT_memory = CollWindowsSoapHelper
.getSoap_NT_Memory(soap_host_name);
String soap_NT_memory_res = soapClient
.getSoapStringResponse(soap_NT_memory);
List memory_results = CollHostXmlHelper
.parseSoapResponse(soap_NT_memory_res);
if (debug)
System.out.println(new Date()
+ soap_NT_memory_res);
Map memory_map = null;
if (memory_results != null && memory_results.size() > 0) {
memory_map = (Map) memory_results.get(0);
logger.info("collwindows map !=null");
}
if (memory_map == null) {
logger
.info("@tivoli , no Memroy info got by tivoli in collMemory "
+ new Date());
} else {
String Pages_OutputSec = (String) memory_map
.get("Pages_OutputSec");
String Pages_InputSec = (String) memory_map
.get("Pages_InputSec");
String Pagessec = (String) memory_map.get("Pagessec");
String Total_Memory_mBytes = (String) memory_map
.get("Total_Memory_mBytes");
String Memory_Usage_Percentage = (String) memory_map
.get("Memory_Usage_Percentage");
collResult.addKPI(kbp_class + "-12:" + neat_host_name
+ "-memory", "PM-00-01-002-01",
Memory_Usage_Percentage);
collResult.addKPI(kbp_class + "-12:" + neat_host_name
+ "-memory", "PM-00-01-002-02", Pagessec);
collResult.addKPI(kbp_class + "-12:" + neat_host_name
+ "-memory", "PM-00-01-002-03", Pages_InputSec);
collResult.addKPI(kbp_class + "-12:" + neat_host_name
+ "-memory", "PM-00-01-002-04", Pages_OutputSec);
}
} catch (Exception e) {
logger.error("collwindows memory error");
}
} catch (Exception e) {
e.printStackTrace();
}
logger.info("========================================ten min=+=="
+ collResult.getKPISet().size());
return collResult.getKPISet();
}
public Vector getPerformance_Fifteen_Minute() {
CollBase collResult = new CollBase();
System.out.println("HOST_NAME=" + this.host_name);
String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
try {
// 获取逻辑分区信息
String disk_logic = CollWindowsSoapHelper
.getSoap_NT_Disk(soap_host_name);
String str_disk_logic_res = this.soapClient
.getSoapStringResponse(disk_logic);
if (debug) {
System.out.println(str_disk_logic_res);
}
List disk_logic_result = CollHostXmlHelper
.parseSoapResponse(str_disk_logic_res);
Map disk_logic_map = null;
if (disk_logic_result != null && disk_logic_result.size() > 0) {
for (int i = 0; i < disk_logic_result.size(); i++) {
Map disk_map = (Map) disk_logic_result.get(i);
String disk_name = (String) disk_map.get("Disk_Name");
if (disk_name.equals("_Total")) {
// 为总体指标
disk_logic_map = disk_map;
} else {
String neat_disk_name = Formater
.neatenunitid(disk_name);
String used = (String) disk_map.get("Used");
collResult
.addKPI(kbp_class + "-14:" + neat_host_name
+ "-" + neat_disk_name,
"PM-00-01-004-03", used);
collResult.addKPI(kbp_class + "-14:" + neat_host_name
+ "-" + neat_disk_name, "CM-00-01-001-16",
neat_disk_name);
}
}
}
if (disk_logic_map != null) {
String used = (String) disk_logic_map.get("Used");
// 磁盘总利用率
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "PM-00-01-004-01", used);
}
String nt_memory = CollWindowsSoapHelper
.getSoap_NT_Memory(soap_host_name);
String str_nt_memory_res = this.soapClient
.getSoapStringResponse(nt_memory);
if (debug) {
System.out.println(str_nt_memory_res);
}
List memory_result = CollHostXmlHelper
.parseSoapResponse(str_nt_memory_res);
Map memory_map = null;
if (memory_result != null && memory_result.size() > 0) {
memory_map = (Map) memory_result.get(0);
}
if (memory_map != null) {
// 虚拟内存利用率
String v_memory_usage_percentage = (String) memory_map
.get("Available_Usage_Percentage");
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "PM-00-01-004-02",
v_memory_usage_percentage);
}
// NT_process
String nt_process = CollWindowsSoapHelper
.getSoap_NT_Process(soap_host_name);
String str_nt_process_res = this.soapClient
.getSoapStringResponse(nt_process);
if (debug) {
System.out.println(str_nt_process_res);
}
List process_result = CollHostXmlHelper
.parseSoapResponse(str_nt_process_res);
Map user_process_count = new HashMap();
if (process_result != null && process_result.size() > 0) {
for (int i = 0; i < process_result.size(); i++) {
Map processMap = (Map) process_result.get(i);
String process_name = (String) processMap
.get("Process_Name");
String Command = Formater.neatenunitid(process_name);
if (!process_name.equals("_Total")) {
String process_time = (String) processMap
.get("Avg__Processor_Time");
String binary_path = (String) processMap
.get("Binary_Path");
String elapsed_time = (String) processMap
.get("Elapsed_Time");
String Private_kBytes = (String) processMap
.get("Private_kBytes");
String user = (String) processMap.get("User");
String Process_Count = (String) processMap
.get("Process_Count");
String timestamp = (String) processMap.get("Timestamp");
// 统计用户进程个数 map,key=user,value = Process_Count
setUserProcessCount(user_process_count, user,
Process_Count);
double memory_used = 0;
try {
memory_used = Double.valueOf(Private_kBytes)
.doubleValue() / 1024;
} catch (Exception e) {
e.printStackTrace();
}
collResult.addKPI(kbp_class + "-15:" + neat_host_name
+ "-" + Command, "PM-00-01-005-01",
process_time);
// collResult.addKPI(pre_unitid+"-15:"+neat_host_name+"-"+Command,"PM-00-01-005-02",Execution_State);
collResult
.addKPI(kbp_class + "-15:" + neat_host_name
+ "-" + Command, "PM-00-01-005-03",
binary_path);
// 需要修改,根据采集时间戳和运行了多长时间,可以算出启动时间
collResult.addKPI(kbp_class + "-15:" + neat_host_name
+ "-" + Command, "PM-00-01-005-04", this
.getDate(timestamp, elapsed_time));
collResult.addKPI(kbp_class + "-15:" + neat_host_name
+ "-" + Command, "PM-00-01-005-05", String
.valueOf(memory_used));
}
}
if (user_process_count.size() > 0) {
Iterator it = user_process_count.keySet().iterator();
while (it.hasNext()) {
String user = (String) it.next();
String process_count = (String) user_process_count
.get(user);
String username = Formater.neatenunitid(user);
collResult.addKPI(kbp_class + "-18:" + neat_host_name
+ "-" + username, "PM-00-01-005-06",
process_count);
collResult.addKPI(kbp_class + "-18:" + neat_host_name
+ "-" + username, "CM-00-01-900-03", user);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return collResult.getKPISet();
}
public Vector getPerformance_One_Hour() {
CollBase collResult = new CollBase();
System.out.println("HOST_NAME=" + this.host_name);
String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
try {
String physical_disk = CollWindowsSoapHelper
.getSoap_NT_Physic_Disk(soap_host_name);
String str_physical_disk_res = this.soapClient
.getSoapStringResponse(physical_disk);
if (debug) {
System.out.println(str_physical_disk_res);
}
List disk_result = CollHostXmlHelper
.parseSoapResponse(str_physical_disk_res);
if (disk_result != null && disk_result.size() > 0) {
for (int i = 0; i < disk_result.size(); i++) {
Map diskMap = (Map) disk_result.get(i);
String disk_name = (String) diskMap.get("Disk_Name");
if (!disk_name.equals("_Total")) {
String Disk_Number = (String) diskMap
.get("Disk_Number");
String Disk_TransfersSec = (String) diskMap
.get("Disk_TransfersSec");
String Disk_Read_BytesSec = (String) diskMap
.get("Disk_Read_BytesSec");
String Disk_Write_BytesSec = (String) diskMap
.get("Disk_Write_BytesSec");
String Disk_Time = (String) diskMap.get("Disk_Time");
collResult.addKPI(kbp_class + "-13:" + neat_host_name
+ "-" + Disk_Number, "CM-00-01-900-01",
disk_name);
collResult.addKPI(kbp_class + "-13:" + neat_host_name
+ "-" + Disk_Number, "PM-00-01-003-01",
Disk_TransfersSec);
collResult.addKPI(kbp_class + "-13:" + neat_host_name
+ "-" + Disk_Number, "PM-00-01-003-03",
Disk_Time);
collResult.addKPI(kbp_class + "-13:" + neat_host_name
+ "-" + Disk_Number, "PM-00-01-003-04",
Disk_Read_BytesSec);
collResult.addKPI(kbp_class + "-13:" + neat_host_name
+ "-" + Disk_Number, "PM-00-01-003-05",
Disk_Write_BytesSec);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return collResult.getKPISet();
}
public Vector getConfiguration_One_Day() {
CollBase collResult = new CollBase();
System.out.println("HOST_NAME=" + this.host_name);
String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
try {
String soap_NT_memory = CollWindowsSoapHelper
.getSoap_NT_Memory(soap_host_name);
String soap_NT_memory_res = soapClient
.getSoapStringResponse(soap_NT_memory);
List memory_results = CollHostXmlHelper
.parseSoapResponse(soap_NT_memory_res);
if (debug)
System.out.println(new Date() + soap_NT_memory_res);
Map memory_map = null;
if (memory_results != null && memory_results.size() > 0) {
memory_map = (Map) memory_results.get(0);
}
if (memory_map == null) {
logger
.info("@tivoli , no Memroy info got by tivoli in collMemory "
+ new Date());
} else {
String Available_kBytes = (String) memory_map
.get("Available_kBytes");
double available = 0;
try {
available = Double.valueOf(Available_kBytes).doubleValue() / 1024;
} catch (Exception e) {
e.printStackTrace();
}
collResult.addKPI(this.kbp_class + "-10" + ":" + neat_host_name
+ "-total", "CM-00-01-001-13", String
.valueOf(available));
}
String soap_NT_System = CollWindowsSoapHelper
.getNT_System(soap_host_name);
String soap_NT_System_res = soapClient
.getSoapStringResponse(soap_NT_System);
List system_results = CollHostXmlHelper
.parseSoapResponse(soap_NT_System_res);
if (debug)
System.out.println(new Date() + soap_NT_System_res);
Map system_map = null;
if (system_results != null && system_results.size() > 0) {
system_map = (Map) system_results.get(0);
}
if (memory_map == null) {
logger
.info("@tivoli , no System info got by tivoli in collMemory "
+ new Date());
} else {
String IP_ADDR = (String) memory_map.get("Network_Address");
collResult.addKPI(this.kbp_class + "-10" + ":" + neat_host_name
+ "-total", "CM-00-01-001-50", IP_ADDR);
}
} catch (Exception e) {
e.printStackTrace();
}
return collResult.getKPISet();
}
public Vector getFailure() {
CollBase collResult = new CollBase();
System.out.println("HOST_NAME=" + this.host_name);
String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
try {
if (HaHostHelper.isHaHost(host_name)) {
String ha_host_name = HaHostHelper.getHaHostName(host_name);
String Soap_HACMPCLUSTER = CollHostSoapHelper
.getSoap_HACMPCLUSTER00(ha_host_name);
String Soap_HACMPCLUSTER_res = soapClient
.getSoapStringResponse(Soap_HACMPCLUSTER);
List HACMPCLUSTER_result = CollHostXmlHelper
.parseSoapResponse(Soap_HACMPCLUSTER_res);
if (HACMPCLUSTER_result == null
|| HACMPCLUSTER_result.size() == 0) {
System.out
.println("@tivoli error, no getSoap_HACMPCLUSTER00 info got by tivoli in CollHost "
+ new Date());
} else {
for (int i = 0; i < HACMPCLUSTER_result.size(); i++) {
Map resultMap = (Map) HACMPCLUSTER_result.get(i);
String clusterState = (String) resultMap
.get("clusterState");
clusterState = clusterState.toUpperCase();
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "FM-00-01-001-04", clusterState);
}
}
} else {
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "FM-00-01-001-04", "UNKNOW");
}
String soap_network_Network = CollWindowsSoapHelper
.getSoap_NT_network(soap_host_name); // soap消息
String soap_network_Network_res = soapClient
.getSoapStringResponse(soap_network_Network);
List network_results = CollHostXmlHelper
.parseSoapResponse(soap_network_Network_res);
if (network_results != null) {
// 获取每个网卡的信息
for (int i = 0; i < network_results.size(); i++) {
Map networkMap = (Map) network_results.get(i);
String IPv4 = (String) networkMap.get("IPv4_Address");
// String Interface_Status =
// (String)networkMap.get("Network_Interface_Instance");
if ("No_DNS_Entry".equals(IPv4)) {
collResult.addKPI(kbp_class + "-16:" + neat_host_name
+ "-" + IPv4, "FM-00-01-001-03", "DOWN");
} else {
collResult.addKPI(kbp_class + "-16:" + neat_host_name
+ "-" + IPv4, "FM-00-01-001-03", "UP");
}
collResult.addKPI(kbp_class + "-16:" + neat_host_name + "-"
+ IPv4, "CM-00-01-900-02", IPv4);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return collResult.getKPISet();
}
public Vector getConfig() {
CollBase collResult = new CollBase();
System.out.println("HOST_NAME=" + this.host_name);
String soap_host_name = SOAPITCMNameHelper.getSoapHostName(host_name);
try {
String soap_system = CollWindowsSoapHelper
.getNT_System(soap_host_name); // soap消息
String soap_system_res = soapClient
.getSoapStringResponse(soap_system);
List system_result = CollHostXmlHelper
.parseSoapResponse(soap_system_res);
Map systemMap = null;
if (system_result != null && system_result.size() > 0) {
systemMap = (Map) system_result.get(0);
}
if (systemMap != null) {
String server_name = (String) systemMap.get("Server_Name");
String Operating_System_Type = (String) systemMap
.get("Operating_System_Type");
String Operating_System_Version = (String) systemMap
.get("Operating_System_Version");
String Number_of_Processors = (String) systemMap
.get("Number_of_Processors");
String Network_Address = (String) systemMap
.get("Network_Address");
String Total_Memory_Size = (String) systemMap
.get("Total_Memory_Size");
if (!"".equals(server_name) && server_name != null) {
String[] host_name = server_name.split(":");
if (host_name != null && host_name.length > 2) {
// 主机名
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-01", host_name[1]);
}
}
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-02", Network_Address);
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-03", "Microsoft");
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-04", Number_of_Processors);
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-07", Total_Memory_Size);
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-08", Operating_System_Type
+ " " + Operating_System_Version);
}
String soap_processor = CollWindowsSoapHelper
.getSoap_processor_Information(soap_host_name);
String str_soap_processor_res = this.soapClient
.getSoapStringResponse(soap_processor);
if (debug) {
System.out.println(str_soap_processor_res);
}
List processor_List = CollHostXmlHelper
.parseSoapResponse(str_soap_processor_res);
Map processor_map = null;
if (processor_List != null && processor_List.size() > 0) {
processor_map = (Map) processor_List.get(0);
}
if (processor_map != null) {
String Current_Clock_Speed = (String) processor_map
.get("Current_Clock_Speed");
String Processor_Name = (String) processor_map
.get("Processor_Name");
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-05", Processor_Name);
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-06", Current_Clock_Speed);
}
// 获取逻辑分区信息
String disk_logic = CollWindowsSoapHelper
.getSoap_NT_Disk(soap_host_name);
String str_disk_logic_res = this.soapClient
.getSoapStringResponse(disk_logic);
if (debug) {
System.out.println(str_disk_logic_res);
}
List disk_logic_result = CollHostXmlHelper
.parseSoapResponse(str_disk_logic_res);
Map disk_logic_map = null;
if (disk_logic_result != null && disk_logic_result.size() > 0) {
for (int i = 0; i < disk_logic_result.size(); i++) {
Map disk_map = (Map) disk_logic_result.get(i);
String disk_name = (String) disk_map.get("Disk_Name");
if (disk_name.equals("_Total")) {
// 为总体指标
disk_logic_map = disk_map;
// String neat_disk_name =
// Formater.neatenunitid(disk_name);
String total_size = (String) disk_map.get("Total_Size");
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-09", total_size);
}
}
}
String soap_network_Network = CollWindowsSoapHelper
.getSoap_NT_network(soap_host_name); // soap消息
String soap_network_Network_res = soapClient
.getSoapStringResponse(soap_network_Network);
List network_results = CollHostXmlHelper
.parseSoapResponse(soap_network_Network_res);
if (network_results != null) {
// 网络接口数
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-10", String
.valueOf(network_results.size()));
}
String nt_memory = CollWindowsSoapHelper
.getSoap_NT_Memory(soap_host_name);
String str_nt_memory_res = this.soapClient
.getSoapStringResponse(nt_memory);
if (debug) {
System.out.println(str_nt_memory_res);
}
List memory_result = CollHostXmlHelper
.parseSoapResponse(str_nt_memory_res);
Map memory_map = null;
if (memory_result != null && memory_result.size() > 0) {
memory_map = (Map) memory_result.get(0);
}
if (memory_map != null) {
// 虚拟内存
String Available_kBytes = (String) memory_map
.get("Available_kBytes");
double size = 0;
try {
size = Double.valueOf(Available_kBytes).doubleValue() / 1023;
} catch (Exception e) {
e.printStackTrace();
}
collResult.addKPI(kbp_class + "-10:" + neat_host_name
+ "-total", "CM-00-01-001-13", String.valueOf(size));
}
} catch (Exception e) {
e.printStackTrace();
}
return collResult.getKPISet();
}
private void setUserProcessCount(Map map, String user, String count) {
try {
int int_count = 0;
if (count != null && !count.equals("")) {
int_count = Integer.valueOf(count).intValue();
}
String total_count = (String) map.get(user);
if (total_count == null || total_count.equals("")) {
map.put(user, String.valueOf(int_count));
} else {
int int_total = Integer.valueOf(total_count).intValue();
int_total += int_count;
map.put(user, String.valueOf(int_total));
}
} catch (Exception e) {
// e.printStackTrace();
}
}
public String getDate(String timestamp, String run_time) {
// //这个字符串1090909134903015表示的时间是2009-09-09 13:49:03
String yy = timestamp.substring(1, 3);
String mm = timestamp.substring(3, 5);
String dd = timestamp.substring(5, 7);
String hh = timestamp.substring(7, 9);
String MM = timestamp.substring(9, 11);
String ss = timestamp.substring(11, 13);
String mmm = timestamp.substring(13);
String begin_time = "";
String str_time = "20" + yy + "-" + mm + "-" + dd + " " + hh + ":" + MM
+ ":" + ss;
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
Date date1 = sdf.parse(str_time);
long time = date1.getTime() + Long.valueOf(mmm).longValue();
time = time - Long.valueOf(run_time).longValue() * 1000;
begin_time = sdf.format((new Date(time)));
// System.out.println(sdf.format((new Date(time))));
} catch (Exception e) {
e.printStackTrace();
begin_time = str_time;
}
return begin_time;
}
public static void main(String[] args) {
HashMap params = new HashMap();
params.put("HOST_NAME", "PS1");
CollWindowsWithTivoliSoap coll = new CollWindowsWithTivoliSoap(params);
Vector dataVector = coll.getPerformance_Ten_Minute();
System.out
.println("===============getPerformance_Ten_Minute==============");
for (int i = 0; i < dataVector.size(); i++) {
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL) dataVector
.get(i);
System.out.println(tblato_kpidetail.UNIT_ID + " | "
+ tblato_kpidetail.KPI_ID + " | "
+ tblato_kpidetail.KPI_VALUE);
}
dataVector = coll.getPerformance_Fifteen_Minute();
System.out
.println("===============getPerformance_Fifteen_Minute==============");
for (int i = 0; i < dataVector.size(); i++) {
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL) dataVector
.get(i);
System.out.println(tblato_kpidetail.UNIT_ID + " | "
+ tblato_kpidetail.KPI_ID + " | "
+ tblato_kpidetail.KPI_VALUE);
}
dataVector = coll.getPerformance_One_Hour();
System.out
.println("===============getPerformance_One_Hour==============");
for (int i = 0; i < dataVector.size(); i++) {
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL) dataVector
.get(i);
System.out.println(tblato_kpidetail.UNIT_ID + " | "
+ tblato_kpidetail.KPI_ID + " | "
+ tblato_kpidetail.KPI_VALUE);
}
dataVector = coll.getConfiguration_One_Day();
System.out
.println("===============getConfiguration_One_Day==============");
for (int i = 0; i < dataVector.size(); i++) {
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL) dataVector
.get(i);
System.out.println(tblato_kpidetail.UNIT_ID + " | "
+ tblato_kpidetail.KPI_ID + " | "
+ tblato_kpidetail.KPI_VALUE);
}
dataVector = coll.getFailure();
System.out.println("===============getFailure==============");
for (int i = 0; i < dataVector.size(); i++) {
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL) dataVector
.get(i);
System.out.println(tblato_kpidetail.UNIT_ID + " | "
+ tblato_kpidetail.KPI_ID + " | "
+ tblato_kpidetail.KPI_VALUE);
}
dataVector = coll.getConfig();
System.out.println("===============getConfig==============");
for (int i = 0; i < dataVector.size(); i++) {
TblATO_KPIDETAIL tblato_kpidetail = (TblATO_KPIDETAIL) dataVector
.get(i);
System.out.println(tblato_kpidetail.UNIT_ID + " | "
+ tblato_kpidetail.KPI_ID + " | "
+ tblato_kpidetail.KPI_VALUE);
}
}
}