CollTuxedoWithShell.java
9.73 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
/*
KPI_ID KPI名称 KPI描述 Tuxedo
PM-00-04-01-01 客户端连接的队列个数 交易中间件用于响应客户端请求的进程队列个数 tuxTmachine.tuxTmachineActive获取,但得不到 1.3.6.1.4.1.140.300.1.2 WSL信息
PM-00-04-01-02 服务个数 交易中间件提供的服务的总数 1.3.6.1.4.1.140.300.20.1.1.1 总个数
PM-00-04-01-03 队列等待数 交易中间件工作队列排队数 tuxTmachine.tuxTmachineActive获取,但得不到
PM-00-04-01-04 进程队列中消息个数 应用进程队列中消息个数 tuxTmachine.tuxTmachineActive获取,但得不到 none
PM-00-04-01-05 应用进程负载 每个应用进程完成的服务调用的次数 tuxTmachine.tuxTmachineActive获取,但得不到
PM-00-04-01-06 客户端活动连接数 正在执行操作的客户端连接个数 tuxTmachine.tuxTmachineActive获取,但得不到
FM-00-04-01-01 应用服务状态(可选) 服务是否正常启动并处于可用状态 1.3.6.1.4.1.140.300.20.1.1.5.0 "1.3.6.1.4.1.140.300.20.1.1.3.0 server的名字
针对单个service"
FM-00-04-01-02 中间件可用性 中间件代理服务是否正常启动并处于可用状态 1.3.6.1.4.1.140.300.5.1.1.4.0
FM-00-04-01-03 客户端连接的队列个数 交易中间件用于响应客户端请求的进程队列个数 tuxTmachine.tuxTmachineActive获取,但得不到
CM-00-04-01-01 中间件最大并发连接数 与数据库连接数 1.3.6.1.4.1.140.300.5.1.1.16.0
CM-00-04-01-02 中间件最大并发网络客户端数量 与客户端连接数 1.3.6.1.4.1.140.300.5.1.1.13.0
CM-00-04-01-03 中间件的系统日志路径 中间件的系统日志路径 1.3.6.1.4.1.140.300.5.1.1.4.0
CM-00-04-01-04 中间件的用户日志路径 中间件的用户日志路径 1.3.6.1.4.1.140.300.5.1.1.11.0
*
*/
/*
* usage:以启动tuxedo应用的用户登录,进入到tuxedo/udataobj/snmp/etc目录下,执行命令tux_snmpd -s -p 5161
*/
package com.sitech.ismp.coll;
import com.sitech.util.DES3;
import com.sitech.util.Formater;
import com.sitech.util.upload.RomoteController;
import com.sitech.util.upload.SSHThread;
import com.sitech.util.upload.TelnetThread;
import java.util.HashMap;
import java.util.Vector;
public class CollTuxedoWithShell implements CollTuxedoWithShellMBean {
String KBP_ID = "10-12-12"; // Tuxedo标识
// String kbp_id = "10-11-12";
String routerip = null;
String ObjectIP = null;
String SHELLPATH = null;
String communication = "public";
String username = null;
String deviceid = null;
// String password = null;
String cPort = null;
int port = 5161;
RomoteController tt = null;
boolean isConnect = false;
public CollTuxedoWithShell() {
}
public void init(HashMap params) {
String passwd = null;
String protol = null;
ObjectIP = (String)params.get("IP_ADDR");
username = (String)params.get("USERNAME");
passwd = (String)params.get("PASSWORD");
protol = (String)params.get("PROTOCOL");
passwd = DES3.decrypt(passwd);
deviceid = (String)params.get("DEVICEID");
SHELLPATH = (String) params.get("SHELLPATH");
// password = com.sitech.util.DES3.decrypt(password);
if (SHELLPATH == null) {
SHELLPATH = "";
}
String protocolPort = null;
if (params.get("PROTOCOL_PORT") != null) {
protocolPort = ((String) params.get("PROTOCOL_PORT")).trim();
}
if (protol != null && protol.equals("telnet")) {
if(null != protocolPort && !"".equals(protocolPort)){
tt = new TelnetThread(ObjectIP, Integer.parseInt(protocolPort), username, passwd);
}else{
tt = new TelnetThread(ObjectIP, 23, username, passwd);
}
} else {
if(null != protocolPort && !"".equals(protocolPort)){
tt = new SSHThread(ObjectIP, Integer.parseInt(protocolPort), username, passwd);
}else{
tt = new SSHThread(ObjectIP, 22, username, passwd);
}
}
tt.initial();
this.isConnect = tt.isAuthorized();
}
public void release() {
if (tt != null){
tt.close();
tt=null;
}
System.gc();
}
public Vector getConfiguration(String IP, String username, String shellPath) {
Vector result = null;
try {
this.ObjectIP = IP;
CMDTarget cmdTarget = new CMDTarget();
cmdTarget.init(ObjectIP, username, shellPath);
result = getConfiguration(cmdTarget);
cmdTarget.release();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public Vector getPerformance(String IP, String username, String shellPath) {
Vector result = null;
try {
this.ObjectIP = IP;
CMDTarget cmdTarget = new CMDTarget();
cmdTarget.init(ObjectIP, username, shellPath);
result = getPerformance(cmdTarget);
cmdTarget.release();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private boolean getParams(java.util.HashMap params) {
username = (String) params.get("USERNAME");
// password = (String)params.get("PASSWORD");
ObjectIP = (String) params.get("IP_ADDR");
SHELLPATH = (String) params.get("SHELLPATH");
// password = com.sitech.util.DES3.decrypt(password);
if (SHELLPATH == null) {
SHELLPATH = "";
}
return true;
}
public java.util.Vector getConfiguration(java.util.HashMap params)
throws Exception {
init(params);
// return getConfiguration(ObjectIP,username,password);
return getConfiguration(ObjectIP, username, SHELLPATH);
}
public java.util.Vector getPerformance(java.util.HashMap params)
throws Exception {
init(params);
// return getPerformance(ObjectIP,username,password);
return getPerformance(ObjectIP, username, SHELLPATH);
}
/*
* CM-00-04-001-01 中间件最大并发连接数 1.3.6.1.4.1.140.300.5.1.1.16.0 CM-00-04-001-02
* 中间件最大并发网络客户端数量 1.3.6.1.4.1.140.300.5.1.1.13.0 CM-00-04-001-03 中间件的系统日志路径
* 1.3.6.1.4.1.140.300.5.1.1.4.0 CM-00-04-001-04 中间件的用户日志路径
* 1.3.6.1.4.1.140.300.5.1.1.11.0
*/
private Vector getConfiguration(CMDTarget cmdTarget) {
CollBase collbase = new CollBase();
String KBP_ID = this.KBP_ID + "-10" + ":" + deviceid + "-" + username;
// CM-00-04-001-50 常用ip
collbase.addKPI(KBP_ID, "CM-00-04-001-50", cmdTarget.ObjectIP);
try {
collbase.addKPI(KBP_ID, "CM-00-04-001-01", tt.getResultAsStr(SHELLPATH + "CM-00-04-001-01.sh").trim());
collbase.addKPI(KBP_ID, "CM-00-04-001-02", tt.getResultAsStr(SHELLPATH + "CM-00-04-001-02.sh").trim());
collbase.addKPI(KBP_ID, "CM-00-04-001-03", tt.getResultAsStr(SHELLPATH + "CM-00-04-001-03.sh").trim());
collbase.addKPI(KBP_ID, "CM-00-04-001-04", tt.getResultAsStr(SHELLPATH + "CM-00-04-001-01.sh").trim());
} catch (Exception e) {
e.printStackTrace();
}finally {
release();
}
return collbase.KPISet;
}
/*
* PM-00-04-001-01 客户端连接的队列个数 ,取正运行的Queue Name的个数TuxedoTotalQueued.sh
* PM-00-04-001-02 服务个数 1.3.6.1.4.1.140.300.20.1.1.1 FM-00-04-001-01
* 应用服务状态(可选) 1.3.6.1.4.1.140.300.20.1.1.5.0 FM-00-04-001-02 中间件可用性
* 1.3.6.1.4.1.140.300.5.1.1.4.0 FM-00-04-001-03 客户端连接的队列个数 ,取正运行的Queue
* Name的个数 PM-00-04-001-03 队列等待数 TuxedoTotalQueued.sh PM-00-04-001-04
* 进程队列中消息个数 NaN PM-00-04-001-05 应用进程负载 ,Queued求和 PM-00-04-001-06 客户端活动连接数
* ,取正运行的server的个数
*/
private Vector getPerformance(CMDTarget cmdTarget) {
String KBP_ID = this.KBP_ID + "-11" + ":" + deviceid + "-" + username;
CollBase collbase = new CollBase();
try {
collbase.addKPI(KBP_ID, "FM-00-04-001-01", tt.getResultAsStr(SHELLPATH + "FM-00-04-001-01.sh").trim()); // 有WSL进程
collbase.addKPI(KBP_ID, "FM-00-04-001-02", tt.getResultAsStr(SHELLPATH + "FM-00-04-001-02.sh").trim()); // 有BBL进程
// collbase.addKPI(KBP_ID,"FM-00-04-001-03",cmdTarget.getCommandResult(SHELLPATH+"FM-00-04-001-03.sh"));
// //
collbase.addKPI(KBP_ID, "PM-00-04-001-01", tt.getResultAsStr(SHELLPATH + "PM-00-04-001-01.sh").trim());
collbase.addKPI(KBP_ID, "PM-00-04-001-02", tt.getResultAsStr(SHELLPATH + "PM-00-04-001-02.sh").trim());
collbase.addKPI(KBP_ID, "PM-00-04-001-03", tt.getResultAsStr(SHELLPATH + "PM-00-04-001-03.sh").trim());
collbase.addKPI(KBP_ID, "PM-00-04-001-04", tt.getResultAsStr(SHELLPATH + "PM-00-04-001-04.sh").trim());
collbase.addKPI(KBP_ID, "PM-00-04-001-05", tt.getResultAsStr(SHELLPATH + "PM-00-04-001-05.sh").trim());
collbase.addKPI(KBP_ID, "PM-00-04-001-06", tt.getResultAsStr(SHELLPATH + "PM-00-04-001-06.sh").trim());
} catch (Exception e) {
e.printStackTrace();
}finally {
release();
}
return collbase.KPISet;
}
public static void main(String[] argv) throws Exception {
CollTuxedoWithShell colltuxedo = new CollTuxedoWithShell();
HashMap params = new HashMap();
/*
* params.put("IP_ADDR","10.161.1.183");
* params.put("USERNAME","iboss1");
* params.put("PASSWORD","54413f00fe06ef3628e659848f4f9055fbbad619e3b5cb7a");
* params.put("SHELLPATH","/ibnms/ismp/bnms_agent/tuxedo/");
*/
params.put("IP_ADDR", "172.21.0.201");
params.put("DEVICEID","tuxedo201");
params.put("USERNAME", "tuxedo10");
params.put("PASSWORD", DES3.encrypt("tuxedo10"));
params.put("PROTOCOL", "ssh");
params.put("PROTOCOL_PORT", "22");
// params.put("PASSWORD","54413f00fe06ef3628e659848f4f9055fbbad619e3b5cb7a");
params.put("SHELLPATH", "tuxedo/shell/");
Vector result = new Vector();
result = colltuxedo.getConfiguration(params);
CollBase collbase = new CollBase();
collbase.displayKPI(result);
result = colltuxedo.getPerformance(params);
collbase.displayKPI(result);
}
}