CollWeblogic8WithSNMP.java
30.3 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
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
package com.sitech.ismp.coll.middleware.weblogic.impl;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
import org.apache.log4j.Logger;
import com.adventnet.snmp.beans.SnmpTarget;
import com.adventnet.snmp.snmp2.SnmpOID;
import com.sitech.ismp.coll.CollBase;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import org.springframework.util.CollectionUtils;
public class CollWeblogic8WithSNMP implements ICollWebLogic {
static Logger logger = Logger.getLogger("LOGER");
SnmpTarget target = null;
private boolean DEBUG = false;
private String servicename = "";
public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params) {
return null;
}
/**
* 服务器运行状态
*
*/
public Vector<TblATO_KPIDETAIL> collRunState(HashMap<String, String> params) {
String unitID = "10-12-11-11-10:"; // update by 2006-9-12 in
// 10-12-11-11-13
String hostName = "";
String domainName = "";
boolean bool = true;
String logPath = "";
String serverName = "";
String serverip = (String) params.get("SERVERIP");
CollBase collResult = new CollBase();
init(params);
try {
// Vector vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45",
// false); // domain name
// String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
// domainName = domain[domain.length - 2]; // get Domain
//
// Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70",
// false); // host name
// hostName = (String) vc_hostName.elementAt(0);
unitID = unitID + serverip + "-" + this.servicename + "-RunState";
// hostName + "-" + domainName + "-" + "RunState";
Vector stateRun = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.60", bool);// logPath
// and
// logFileName
String state = (String) stateRun.elementAt(0);
if (state != null && state.length() > 0
&& state.toUpperCase().equals("RUNNING")) {
state = "UP";
} else {
state = "DOWN";
}
if (stateRun.size() > 0) {
collResult.addKPI(unitID, "FM-00-04-001-01",state);
//setResult(state, unitID, "FM-00-04-001-01");
}
} catch (Exception e) {
logger.error("collRunState fail", e);
}
return collResult.KPISet;
}
/**
* @author pc103
* @date 2006-07-21
* @param oid
* @param bool
* @return vector 参数说明书: oid-----对应weblogic控制台监控的性能指标id(关键) bool----无多大用处
* 功能:储存各采集结果 返回类型:vector
*
*/
public Vector<String> walkKPIInfo(String oid, boolean bool) {
Vector<String> tmp_result = new Vector<String>();
try {
Vector<String> tmp_oid = new Vector<String>();
target.setObjectID(oid);
target.oidList[0] = new SnmpOID(oid);
int maxtry = 0;
SnmpOID[] oidList = target.getSnmpOIDList();
if (oidList == null) {
System.out.println("oidList is null");
return null;
} else {
SnmpOID rootoid = oidList[0];
SnmpOID curroid = null;
while (maxtry++ < 3000) {
String result1[] = target.snmpGetNextList();
if (result1 == null) {
target.oidList[0] = curroid;
continue;
}
if (!SnmpTarget.isInSubTree(rootoid, target.getSnmpOID()))
break;
for (int i = 0; i < result1.length; i++) {
tmp_result.add(result1[i]);
tmp_oid.add(target.getObjectID(i));
}
if (result1[0].compareTo("NULL") == 0)
break;
}
if (maxtry == 1) {
System.err
.println("Request failed, timed out or no available data("
+ oid + "). \n " + target.getErrorString());
}
}
} catch (Exception e) {
logger.error("walkKPIInfo fail", e);
}
return tmp_result;
}
/**
* @exception
* @express 建立与weblogic8.0的初始连接,特别注意port指的是weblogic的snmp的port,并非weblogic所开服务监听的port
*/
private void init(HashMap<String, String> params) {
try {
String serverip = (String) params.get("SERVERIP");
int port = Integer.parseInt((String) params.get("PORT"));
String snmp_version = (String) params.get("SNMPV");
String community = (String) params.get("COMMUNITY");
servicename = (String) params.get("SERVERNAME");
target = new SnmpTarget();
// target.setLoadFromCompiledMibs(true);
target.setDebug(DEBUG);
if (snmp_version.equals("1")) {
target.setSnmpVersion(SnmpTarget.VERSION1);
} else if (snmp_version.equals("2")) {
target.setSnmpVersion(SnmpTarget.VERSION2C);
} else if (snmp_version.equals("3")) {
target.setSnmpVersion(SnmpTarget.VERSION3);
}
target.setTargetHost(serverip); // set the agent hostname
target.setCommunity(community.trim());
/**
* 关于weblogic多服务器情况下,如何采集不同的server的值的方法,主要就是设置COMMUNITY的值
* 在这个我以admin server with clustered servers的情况来说明
* domain name = mydomain2,administrtation server = myserver, managed server = server1
* 1.如果取myserver的相关的OID的值,COMMUNITY = "public"
* 2.如果取server1的相关的OID的值,COMMUNITY = "public@server1"
* 3.如果取整个domain的所有server的相关的OID的值,COMMUNITY = "public@mydomain2"
*/
target.setTargetPort(port);
} catch (Exception e) {
logger.error(params+"weblogic8 init fail", e);
}
}
/**
* 释放initWeblogic(String weblogicip,String servername,int port, String hostname,String community)申请的资源
*/
public void release() {
if (target != null) {
target.releaseResources();
}
}
public static void main(String[] argv) {
CollWeblogic8WithSNMP web = new CollWeblogic8WithSNMP();
HashMap<String, String> params = new HashMap<String, String>();
params.put("SERVERIP", "172.21.0.203");
params.put("PORT", "161");
params.put("SNMPV", "2");
params.put("SERVERNAME", "BOSS");
params.put("COMMUNITY", "public");
//Vector<TblATO_KPIDETAIL> vector_ds = web.getJMS(params);
// Vector<TblATO_KPIDETAIL> vector_ds = web.collRunState(params);
Vector<TblATO_KPIDETAIL> vector_ds = web.getExecuteQueue(params);
for (int i = 0; i < vector_ds.size(); i++) {
TblATO_KPIDETAIL ato = (TblATO_KPIDETAIL) vector_ds.get(i);
System.out.println(ato.UNIT_ID + " | " + ato.KPI_ID + " | " + ato.KPI_VALUE + " | " + ato.CLL_TIME);
}
}
@Override
public Vector<TblATO_KPIDETAIL> getExecuteQueue(HashMap<String, String> params) {
logger.info("Begin getExecuteQueue...");
init(params);
// 消息队列
String unitId = "10-12-11-15:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Execute_Queue = walkKPIInfo(".1.3.6.1.4.1.140.625.180", false);
int count = vc_Execute_Queue.size() / 10;
for (int i = 0; i < count; i++) {
String execqueuename = vc_Execute_Queue.get(i + count * 3);
String executethreadcurrentidlecount = vc_Execute_Queue.get(i + count * 5);
String servicedrequesttotalcount = vc_Execute_Queue.get(i + count * 8);
String pendingrequestcurrentcount = vc_Execute_Queue.get(i + count * 7);
String _unitId = unitId + execqueuename;
collResult.addKPI(_unitId, "CM-00-04-009-17", execqueuename);
collResult.addKPI(_unitId, "PM-00-05-009-27", executethreadcurrentidlecount);
collResult.addKPI(_unitId, "PM-00-05-009-26", servicedrequesttotalcount);
collResult.addKPI(_unitId, "PM-00-05-009-29", pendingrequestcurrentcount);
}
} catch (Exception e) {
logger.error(params+"getExecuteQueue fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getJDBC(HashMap<String, String> params) {
logger.info("Begin getJDBC...");
CollBase collResult = new CollBase();
collResult.addKPISet(getjdbcConnectionPoolMaxCapacity(params));
collResult.addKPISet(getJdbcPoolUseRate(params));
collResult.addKPISet(getjdbcConnectionPoolActiveConnectionsCurrentCount(params));
return collResult.KPISet;
}
/**
* JDBC连接池的最大容量: 1.3.6.1.4.1.140.625.190.1.15
* CM-00-04-003-04 配置的数据库连接池大小
* @return
*/
private Vector<TblATO_KPIDETAIL> getjdbcConnectionPoolMaxCapacity(HashMap<String, String> params) {
logger.info("Begin getjdbcConnectionPoolMaxCapacity...");
init(params);
// JDBC连接池
String unitId = "10-12-11-13:" + this.servicename + "-";
CollBase collResult = new CollBase();
// String connPoolName = "";
String connDomain = "";
// String connServerName = "";
// String hostName = "";
String count[] = null;
int i = 0;
int j = 0;
try {
Vector<String> vc_Max = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.60", false);
count = new String[vc_Max.size()];
for (Iterator tt = vc_Max.iterator(); tt.hasNext();) {
count[i] = (String) tt.next();
i++;
}
// connPool Name
Vector<String> vc_ConnPollName = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.15", false);
// domain name
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false);
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
connDomain = domain[domain.length - 2];
/*if(!CollectionUtils.isEmpty(vc_Domain)){
String[] domain = ((String) vc_Domain.elementAt(0)).split("/");
connDomain = domain[domain.length - 2];
}else {
logger.info(params+"domain is empty!");
}*/
// server name.
// Vector<String> vc_ServerName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.15.32", false);
// connServerName = (String) vc_ServerName.elementAt(0);
// host name
// Vector<String> vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false);
// hostName = (String) vc_hostName.elementAt(0);
for (Iterator connName = vc_ConnPollName.iterator(); connName.hasNext();) {
String temp = (String) connName.next();
String _unitId = unitId + connDomain + "-" + temp;
collResult.addKPI(_unitId, "CM-00-04-003-04", count[j]);
j++;
}
} catch (Exception e) {
logger.error(params+"getjdbcConnectionPoolMaxCapacity fail", e);
} finally {
release();
}
return collResult.KPISet;
}
/**
* 1. JDBC 连接池的连接使用率=JDBC连接池的已经激活的连接数/JDBC连接池的最大容量*100
* (.1.3.6.1.4.1.140.625.190.1.25) * 100F/(.1.3.6.1.4.1.140.625.190.1.60)
* 2. JDBC连接池的已经激活的连接数:.1.3.6.1.4.1.140.625.190.1.25
* 3. JDBC连接池的最大容量:.1.3.6.1.4.1.140.625.190.1.60
*/
private Vector<TblATO_KPIDETAIL> getJdbcPoolUseRate(HashMap<String, String> params) {
logger.info("Begin getJdbcPoolUseRate...");
init(params);
// JDBC连接池
String unitId = "10-12-11-13:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
// String connPoolName = "";
String connDomain = "";
// String connServerName = "";
// String hostName = "";
String[] max_ = null;
String[] active_ = null;
Vector<String> vc_Max = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.60", false);
// connPool Name
Vector<String> vc_ConnPollName = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.15", false);
// domain name
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false);
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
// get Domain
connDomain = domain[domain.length - 2];
// server name
Vector<String> vc_ServerName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.15.32", false);
String[] connName = new String[vc_ConnPollName.size()];
int m = 0;
for (Iterator itera = vc_ConnPollName.iterator(); itera.hasNext();) {
connName[m] = itera.next().toString();
m++;
}
// connServerName = (String) vc_ServerName.elementAt(0);
// Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host name
// hostName = (String) vc_hostName.elementAt(0);
max_ = new String[vc_Max.size()];
int i = 0;
int j = 0;
if (vc_Max.size() > 0) {
int Max_num = Integer.parseInt(((String) vc_Max.elementAt(0)).trim());// get max conn count
Vector<String> vc_Active = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.25", false);
active_ = new String[vc_Active.size()];
for (Iterator active = vc_Active.iterator(); active.hasNext();) {
active_[i] = (String) active.next();
i++;
}
for (Iterator max = vc_Max.iterator(); max.hasNext();) {
max_[j] = (String) max.next();
j++;
}
if (vc_Active.size() > 0) {
int Active_num = Integer.parseInt(((String) vc_Active.elementAt(0)).trim());// get active conn count
float userate = 0;
if (Max_num != 0) {
for (int k = 0, l = 0; k < max_.length; k++) {
String _unitID = unitId + connDomain + "-" + connName[k];
userate = Float.parseFloat(active_[k]) * 100F / Float.parseFloat(max_[k]);
collResult.addKPI(_unitID, "PM-00-04-003-02", String.valueOf(userate));
collResult.addKPI(_unitID, "CM-00-04-001-17", connName[k]);
}
}
}
}
} catch (Exception e) {
logger.error(params+"getJdbcPoolUseRate fail", e);
} finally {
release();
}
return collResult.KPISet;
}
/**
* JDBC 连接池的已经激活的连接数: .1.3.6.1.4.1.140.625.190.1.25
*/
private Vector<TblATO_KPIDETAIL> getjdbcConnectionPoolActiveConnectionsCurrentCount(HashMap<String, String> params) {
logger.info("Begin getjdbcConnectionPoolActiveConnectionsCurrentCount...");
init(params);
// JDBC连接池
String unitId = "10-12-11-13:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
// String connDomain = "";
// String connServerName = "";
// String hostName = "";
// String[] active = null;
Vector<String> vc_active = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.25", true);
// connPool Name
Vector<String> vc_ConnPollName = walkKPIInfo(".1.3.6.1.4.1.140.625.190.1.15", false);
int k = 0;
String[] active = new String[vc_active.size()];
for (Iterator activee = vc_active.iterator(); activee.hasNext();) {
active[k] = (String) activee.next();
k++;
}
int j = 0;
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain
// name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String connDomain = domain[domain.length - 2]; // get Domain
// Vector<String> vc_ServerName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.15.32", false); // server name.
// connServerName = (String) vc_ServerName.elementAt(0);
// Vector vc_hostName = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.70", false); // host
// name
// hostName = (String) vc_hostName.elementAt(0);
for (Iterator connName = vc_ConnPollName.iterator(); connName.hasNext();) {
String temp = (String) connName.next();
String _unitID = unitId + connDomain + "-" + temp;
collResult.addKPI(_unitID, "PM-00-04-003-03", active[j]);
j++;
}
} catch (Exception e) {
logger.error(params+"getjdbcConnectionPoolActiveConnectionsCurrentCount fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getJMS(HashMap<String, String> params) {
logger.info("Begin getJMS...");
init(params);
// JMS消息队列
String unitId = "10-12-11-16:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-";
Vector<String> vc_Jms = walkKPIInfo(".1.3.6.1.4.1.140.625.610.1", false); // JMS name
int count = vc_Jms.size() / 16;
for (int i = 0; i < count; i++) {
String jmsname = vc_Jms.get(i + count * 3);
String jndiname = vc_Jms.get(i + count * 5);
String cliendid = vc_Jms.get(i + count * 6);
String _unitId = unitId + jmsname;
collResult.addKPI(_unitId, "CM-00-05-009-22", jmsname);
collResult.addKPI(_unitId, "CM-00-05-009-28", jndiname);
collResult.addKPI(_unitId, "CM-00-05-009-29", cliendid);
}
} catch (Exception e) {
logger.error(params+"getJMS fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getJVM(HashMap<String, String> params) {
logger.info("Begin getJVM...");
CollBase collResult = new CollBase();
collResult.addKPISet(getJVMMEM(params));
collResult.addKPISet(getFreeJVMMEM(params));
collResult.addKPISet(getUsedJVMMEM(params));
collResult.addKPISet(getJVMMEMUseRate(params));
return collResult.KPISet;
}
/**
* 当前JVM中的堆内存值: .1.3.6.1.4.1.140.625.340.1.30
*/
private Vector<TblATO_KPIDETAIL> getJVMMEM(HashMap<String, String> params) {
logger.info("Begin getJVMMEM...");
init(params);
// JVM内存堆
String unitId = "10-12-11-12:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-HeapSize";
Vector<String> JVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.30", false);
if (JVMMEM.size() > 0) {
String state = String.valueOf(JVMMEM.elementAt(0));
collResult.addKPI(unitId, "PM-00-05-009-03", state);
}
} catch (Exception e) {
logger.error(params+"getJVMMEM fail", e);
} finally {
release();
}
return collResult.KPISet;
}
/**
* JVM 中free memory值: .1.3.6.1.4.1.140.625.340.1.25
*/
private Vector<TblATO_KPIDETAIL> getFreeJVMMEM(HashMap<String, String> params) {
logger.info("Begin getFreeJVMMEM...");
init(params);
// JVM内存堆
String unitId = "10-12-11-12:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-HeapSize";
Vector<String> FreeJVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.25", false);
if (FreeJVMMEM.size() > 0) {
String state = String.valueOf(FreeJVMMEM.elementAt(0));
collResult.addKPI(unitId, "PM-00-05-009-02", state);
}
} catch (Exception e) {
logger.error(params+"getFreeJVMMEM fail", e);
} finally {
release();
}
return collResult.KPISet;
}
/**
* JVM 中的使用的内存值 = JVM中的堆内存值 - JVM 中的剩余内存
* (.1.3.6.1.4.1.140.625.340.1.30)-(.1.3.6.1.4.1.140.625.340.1.25)
*/
private Vector<TblATO_KPIDETAIL> getUsedJVMMEM(HashMap<String, String> params) {
logger.info("Begin getUsedJVMMEM...");
init(params);
// JVM内存堆
String unitId = "10-12-11-12:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-HeapSize";
Vector<String> JVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.30", false);
if (JVMMEM.size() > 0) {
int state_all = Integer.parseInt((String) JVMMEM.elementAt(0));
Vector<String> FreeJVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.25", false);
if (FreeJVMMEM.size() > 0) {
int state_free = Integer.parseInt((String) FreeJVMMEM.elementAt(0));
int state_use = state_all - state_free;
collResult.addKPI(unitId, "PM-00-04-009-05", String.valueOf(state_use));
}
}
} catch (Exception e) {
logger.error(params+"getUsedJVMMEM fail", e);
} finally {
release();
}
return collResult.KPISet;
}
private Vector<TblATO_KPIDETAIL> getJVMMEMUseRate(HashMap<String, String> params) {
logger.info("Begin getJVMMEMUseRate...");
init(params);
// JVM内存堆
String unitId = "10-12-11-12:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-HeapSize";
Vector<String> JVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.30", false);
if (JVMMEM.size() > 0) {
int state_all = Integer.parseInt((String) JVMMEM.elementAt(0));
Vector<String> FreeJVMMEM = walkKPIInfo(".1.3.6.1.4.1.140.625.340.1.25", false);
if (FreeJVMMEM.size() > 0) {
int state_free = Integer.parseInt((String) FreeJVMMEM.elementAt(0));
int state_use = state_all - state_free;
if (state_all != 0) {
float userate = state_use * 100F / state_all;
collResult.addKPI(unitId, "PM-00-04-003-01", String.valueOf(userate));
float freerate = state_free * 100F / state_all;
collResult.addKPI(unitId, "PM-00-05-009-04", String.valueOf(freerate));
}
}
}
} catch (Exception e) {
logger.error(params+"getJVMMEMUseRate fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getServers(HashMap<String, String> params) {
logger.info("Begin getServers...");
init(params);
// SERVER
String unitId = "10-12-11-10:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
// server name
Vector<String> vc_Servers = walkKPIInfo(".1.3.6.1.4.1.140.625.730", false);
int count = vc_Servers.size() / 57;
for (int i = 0; i < count; i++) {
String servername = vc_Servers.get(i + count * 3);
String listenport = vc_Servers.get(i + count * 24);
String servercluster = vc_Servers.get(i + count * 26);
String _unitId = unitId + servername + "-server";
collResult.addKPI(_unitId, "CM-00-04-001-10", servername);
collResult.addKPI(_unitId, "CM-00-04-009-06", listenport);
collResult.addKPI(_unitId, "CM-00-05-009-16", servercluster);
}
} catch (Exception e) {
logger.error(params+"getServers fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getCluster(HashMap<String, String> params) {
logger.info("Begin getCluster...");
init(params);
// 集群
String unitId = "10-12-11-14:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-";
Vector<String> vc_Cluster = walkKPIInfo(".1.3.6.1.4.1.140.625.510", false);
int count = vc_Cluster.size() / 16;
for (int i = 0; i < count; i++) {
String clustername = vc_Cluster.get(i + count * 3);
String serversip = vc_Cluster.get(i + count * 6);
String serversconf = vc_Cluster.get(i + count * 5);
String multicastaddress = vc_Cluster.get(i + count * 7);
String loadalgorithm = vc_Cluster.get(i + count * 10);
String multicastport = vc_Cluster.get(i + count * 13);
String _unitId = unitId + clustername;
collResult.addKPI(_unitId, "CM-00-05-009-16", clustername);
collResult.addKPI(_unitId, "CM-00-05-009-17", serversip);
collResult.addKPI(_unitId, "CM-00-05-009-30", serversconf);
collResult.addKPI(_unitId, "CM-00-05-009-19", multicastaddress);
collResult.addKPI(_unitId, "CM-00-05-009-31", loadalgorithm);
collResult.addKPI(_unitId, "CM-00-05-009-18", multicastport);
}
} catch (Exception e) {
logger.error(params+"getCluster fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getWebApps(HashMap<String, String> params) {
logger.info("Begin getWebApps...");
init(params);
// WEBAPPS
String unitId = "10-12-11-11:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-";
Vector<String> vc_Webapps = walkKPIInfo(".1.3.6.1.4.1.140.625.430", false);
int count = vc_Webapps.size() / 34;
for (int i = 0; i < count; i++) {
String webappsname = vc_Webapps.get(i + count * 3);
String contextroot = vc_Webapps.get(i + count * 27);
String sourceinfo = vc_Webapps.get(i + count * 7);
String status = vc_Webapps.get(i + count * 6);
String opensessionscurrentcount = vc_Webapps.get(i + count * 10);
String sessionsopenedtotalcount = vc_Webapps.get(i + count * 12);
String opensessionshighcount = vc_Webapps.get(i + count * 11);
String _unitId = unitId + webappsname;
collResult.addKPI(_unitId, "CM-00-05-009-01", webappsname);
collResult.addKPI(_unitId, "CM-00-05-009-06", contextroot);
collResult.addKPI(_unitId, "CM-00-05-009-07", sourceinfo);
collResult.addKPI(_unitId, "CM-00-05-009-08", status);
collResult.addKPI(_unitId, "PM-00-05-009-40", opensessionscurrentcount);
collResult.addKPI(_unitId, "PM-00-05-009-41", sessionsopenedtotalcount);
collResult.addKPI(_unitId, "PM-00-05-009-42", opensessionshighcount);
}
} catch (Exception e) {
logger.error(params+"getWebApps fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getChannel(HashMap<String, String> params) {
logger.info("Begin getChannel...");
init(params);
// 协议队列
String unitId = "10-12-11-18:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-";
Vector<String> vc_Channel = walkKPIInfo(".1.3.6.1.4.1.140.625.366", false);
int count = vc_Channel.size() / 13;
for (int i = 0; i < count; i++) {
String channelname = vc_Channel.get(i + count * 3);
String acceptcount = vc_Channel.get(i + count * 9);
String bytesreceivedcount = vc_Channel.get(i + count * 5);
String bytessentcount = vc_Channel.get(i + count * 6);
String connectionscount = vc_Channel.get(i + count * 8);
String messagesreceivedcount = vc_Channel.get(i + count * 10);
String messagessentcount = vc_Channel.get(i + count * 11);
String _unitId = unitId + channelname;
collResult.addKPI(_unitId, "CM-00-05-009-27", channelname);
collResult.addKPI(_unitId, "PM-00-05-009-34", acceptcount);
collResult.addKPI(_unitId, "PM-00-05-009-35", bytesreceivedcount);
collResult.addKPI(_unitId, "PM-00-05-009-36", bytessentcount);
collResult.addKPI(_unitId, "PM-00-05-009-37", connectionscount);
collResult.addKPI(_unitId, "PM-00-05-009-38", messagesreceivedcount);
collResult.addKPI(_unitId, "PM-00-05-009-39", messagessentcount);
}
} catch (Exception e) {
logger.error(params+"getChannel fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public Vector<TblATO_KPIDETAIL> getThreads(HashMap<String, String> params) {
logger.info("Begin getThreads...");
init(params);
// 线程池
String unitId = "10-12-11-17:" + this.servicename + "-";
CollBase collResult = new CollBase();
try {
Vector<String> vc_Domain = walkKPIInfo(".1.3.6.1.4.1.140.625.360.1.45", false); // domain name
String dir = (String) vc_Domain.elementAt(0);
String[] domain = null;
if(dir.indexOf("/") != -1){
domain = dir.split("/");
}else{
domain = dir.split("\\\\");
}
String domainName = domain[domain.length - 2]; // get Domain
unitId += domainName + "-";
Vector<String> vc_Thread_Pool = walkKPIInfo(".1.3.6.1.4.1.140.625.367", false);
int count = vc_Thread_Pool.size() / 16;
int totalThreads = 0;
for (int i = 0; i < count; i++) {
String tpname = vc_Thread_Pool.get(i + count * 3);
String compreqcount = vc_Thread_Pool.get(i + count * 10);
String execthreadidle = vc_Thread_Pool.get(i + count * 6);
String execthreadtotal = vc_Thread_Pool.get(i + count * 5);
totalThreads += Integer.valueOf(execthreadtotal);
String penduserreqcount = vc_Thread_Pool.get(i + count * 8);
String standbythreadcount = vc_Thread_Pool.get(i + count * 12);
String throughput = vc_Thread_Pool.get(i + count * 13);
String queuelength = vc_Thread_Pool.get(i + count * 7);
String hogthreadcount = vc_Thread_Pool.get(i + count * 11);
String _unitId = unitId + tpname;
collResult.addKPI(_unitId, "CM-00-05-009-25", tpname);
collResult.addKPI(_unitId, "PM-00-05-009-26", compreqcount);
collResult.addKPI(_unitId, "PM-00-05-009-27", execthreadidle);
collResult.addKPI(_unitId, "PM-00-05-009-28", execthreadtotal);
collResult.addKPI(_unitId, "PM-00-05-009-29", penduserreqcount);
collResult.addKPI(_unitId, "PM-00-05-009-30", standbythreadcount);
collResult.addKPI(_unitId, "PM-00-05-009-31", throughput);
collResult.addKPI(_unitId, "PM-00-05-009-32", queuelength);
collResult.addKPI(_unitId, "PM-00-05-009-33", hogthreadcount);
}
} catch (Exception e) {
logger.error(params+"getThreads fail", e);
} finally {
release();
}
return collResult.KPISet;
}
@Override
public void collWeblogic10WithJMX(HashMap<String, String> map) {
}
@Override
public Vector<TblATO_KPIDETAIL> collWeblogic10ForSX(HashMap<String, String> params) {
return null;
}
}