CollVPN.java
3.04 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
package com.sitech.ismp.coll.VPN;
import com.sitech.database.dao.TbTmpInterfaceDao;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.DES3;
import com.sitech.util.LogUtil;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Vector;
/**
* Created by IntelliJ IDEA.
* User: liush_bj
* Date: 2014-10-16
*/
public class CollVPN implements CollVPNMBean {
static{
// 初始化MBean时清理临时表
new TbTmpInterfaceDao().clean();
}
public Vector<TblATO_KPIDETAIL> getTotal(HashMap<String, String> params) {
try {
return new CollVPNWithSNMP().getTotal(params);
} catch (Exception e) {
LogUtil.error("Exception while getArray()", e);
}
return null;
}
public Vector<TblATO_KPIDETAIL> getArraySPX(HashMap<String, String> params) {
try {
return new CollVPNWithSNMP().getArraySPX(params);
} catch (Exception e) {
LogUtil.error("Exception while getArraySPX()", e);
}
return null;
}
public static void main(String[] args) {
System.out.println("***************Net Device Collect Test Begin*********************");
String ipAddr = "127.0.0.1";
String port = "161";
String community = "public";
String deviceName = "DELL";
String kbpClass = "10-19-10";
String type = "0";
// FIREWALL CISCO PIX 535
// String ipAddr = "192.168.1.43";
// String port = "161";
// String community = "public";
// String deviceName = "PIX_535";
// String kbpClass = "10-16-11";
// String type = "1";
// // SWITCH Quidway S8505
// String ipAddr = "192.168.1.1";
// String port = "161";
// String community = "public";
// String deviceName = "hw_quidway";
// String kbpClass = "10-16-10";
// String type = "1";
System.out.println("IP_ADDR=" + ipAddr + ", SNMP_PORT=" + port
+ ", READ_COMMUNITY=" + community + ", DEVICE_NAME=" + deviceName);
HashMap<String, String> params = new HashMap<String, String>();
// 网络设备IP地址
params.put("IP", ipAddr);
// SNMP端口
params.put("PORT", port);
// SNMP Read Community
params.put("COMMUNITY", DES3.encrypt(community));
// 网络设备名称
params.put("HOST_NAME", deviceName);
// 网络设备类型代表的KBP_CLASS
params.put("KBP_CLASS", kbpClass);
Vector<TblATO_KPIDETAIL> result = new Vector<TblATO_KPIDETAIL>();
CollVPN collector = new CollVPN();
int method = Integer.parseInt(type);
switch (method) {
case 0:
result.addAll(collector.getArraySPX(params));
result.addAll(collector.getTotal(params));
break;
default:
break;
}
System.out.println("***************Net Device Collect Test End*********************");
for (int i = 0; i < result.size(); i++) {
TblATO_KPIDETAIL record = (TblATO_KPIDETAIL) result.get(i);
System.out.println(record.UNIT_ID + "\t" + record.KPI_ID + "\t"
+ record.KPI_VALUE);
}
}
private static String read(String prompt) {
Scanner scanner = new Scanner(System.in);
System.out.print(prompt);
return scanner.nextLine();
}
}