GXCollTuxedo.java
15.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
package com.sitech.ismp.coll.tivoli;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.Formater;
/*
* ibm所提供的以 UA 插件 使用shell脚本方式采集Tuxedo的方式
*
* IBM出来的是原始数据,IBM将原始数据直接入到它库里丢失了部分标识[咨询过tuxedo专家]
*
* 所以,目前该类暂不启用
*
*/
public class GXCollTuxedo implements GXCollTuxedoMBean {
private boolean debug=false;
private SoapClient soapClient =null;
private String pre_unitid="10-12-12"; //Tuxedo标识
public GXCollTuxedo()
{
String url=SoapParam.getString("SOAP_URL");
soapClient = new SoapClient(url);
}
public Vector getPerformance(java.util.HashMap params) throws Exception
{
String host_name=(String)params.get("HOST_NAME");
String ip_addr=(String)params.get("IP_ADDR");
String neat_host_name = Formater.neatenunitid(host_name);
//String KBP_ID = this.KBP_ID+"-11"+":"+NEATENSID+"-TABLESPACES";
Vector collResult = new Vector();
//返回结果为param_name , param_value 类型, 单实例
String kpi_node="BBSTATS";
String value_node="MetricValue";
String time_node="LocalTimeStamp";
/**
* PM-00-04-001-01 客户端连接的队列个数 交易中间件用于响应客户端请求的进程队列个数
* PM-00-04-001-02 服务个数 交易中间件提供的服务的总数
* lianlian 2006-09-11
* BBSTATS MetricValue LocalTimeStamp
* @param host_name
* @return
*/
//得到soap请求
String soap_performance_TUXEDOBBSTATS00 = GXCollTuxedoSoapHelper.getSoap_performance_TUXEDOBBSTATS00(host_name); //soap消息
//发送soap请求,并返回结果
String soap_performance_TUXEDOBBSTATS00_res = soapClient.getSoapStringResponse(soap_performance_TUXEDOBBSTATS00);
//分析返回结果,得到list
//List TUXEDOBBSTATS00_res_results = CollTuxedoXmlHelper.parseParamsSoapResponse(soap_performance_TUXEDOBBSTATS00_res,kpi_node,value_node, time_node);
List TUXEDOBBSTATS00_res_results = CollTuxedoXmlHelper.parseCommonSoapResponse(soap_performance_TUXEDOBBSTATS00_res);
if( TUXEDOBBSTATS00_res_results == null || TUXEDOBBSTATS00_res_results.size()==0){
System.out.println("@tivoli error, no TUXEDOBBSTATS00_res_results info got by tivoli "+new Date());
}else{
//tivoli名称与规范kpi名称的映射关系
Map kpiMap = new java.util.HashMap();
kpiMap.put("Current number of request queues","PM-00-04-001-01");
kpiMap.put("Current number of servers","PM-00-04-001-02");
String unit_id=pre_unitid+"-11:"+ip_addr+"-"+neat_host_name;
for(int i=0; i<TUXEDOBBSTATS00_res_results.size(); i++)
{
Map resultMap = (Map)TUXEDOBBSTATS00_res_results.get(i);
String bbstats = (String)resultMap.get("BBSTATS");
String metricvalue = (String)resultMap.get("MetricValue");
String cll_time = (String)resultMap.get("LocalTimeStamp");
bbstats = bbstats.replaceAll(" ","");
if(bbstats.equalsIgnoreCase("Currentnumberofrequestqueues"))
{
this.setResult(collResult, unit_id, "PM-00-04-001-01" , metricvalue, this.parseTime(cll_time));
}
else if(bbstats.equalsIgnoreCase("Currentnumberofservices"))
{
this.setResult(collResult, unit_id, "PM-00-04-001-02" , metricvalue, this.parseTime(cll_time));
}
/*String[] kpidetail = (String[])TUXEDOBBSTATS00_res_results.get(i);
String tivoli_kpi_name = kpidetail[0].trim();
String kpi_value = kpidetail[1];
String cll_time = kpidetail[2];
String kpi_id= (String)kpiMap.get(tivoli_kpi_name);
if(kpi_id!=null)
{
//
String unit_id=pre_unitid+"-11:"+ip_addr+"-"+neat_host_name;
this.setResult(collResult, unit_id, kpi_id , kpi_value, this.parseTime(cll_time));
}
*/
}
}
/**
* PM-00-04-01-03 队列等待数 交易中间件工作队列排队数 ProgramName QueueName WorkQueued MachineName
* PM-00-04-01-04 进程队列中消息个数 应用进程队列中消息个数 ProgramName QueueName NumQueued MachineName
* FM-00-04-01-03 客户端连接的队列个数 交易中间件用于响应客户端请求的进程队列个数 ProgramName QueueName WorkQueued MachineName
* lianlian 2006-09-11
*/
//返回结果为普通类型,多实例
//得到soap请求
String soap_performance_TUXEDOQUEUESINFO00 = GXCollTuxedoSoapHelper.getSoap_performance_TUXEDOQUEUESINFO00(host_name); //soap消息
//发送soap请求,并返回结果
String soap_performance_TUXEDOQUEUESINFO00_res = soapClient.getSoapStringResponse(soap_performance_TUXEDOQUEUESINFO00);
//分析返回结果,得到list
List TUXEDOQUEUESINFO00_results = CollTuxedoXmlHelper.parseCommonSoapResponse(soap_performance_TUXEDOQUEUESINFO00_res);
if( TUXEDOQUEUESINFO00_results == null || TUXEDOQUEUESINFO00_results.size()==0){
System.out.println("@tivoli error, no TUXEDOQUEUESINFO00_results info got by tivoli in collCpu "+new Date());
}else{
for(int i=0; i<TUXEDOQUEUESINFO00_results.size(); i++){
Map rowMap = (Map)TUXEDOQUEUESINFO00_results.get(i);
String WorkQueued = (String)rowMap.get("WorkQueued");
String NumQueued = (String)rowMap.get("NumQueued");
String ProgramName = (String)rowMap.get("ProgramName");
String LocalTimeStamp = (String)rowMap.get("LocalTimeStamp");
String neatProgramName = Formater.neatenunitid(ProgramName);
String unit_id=pre_unitid+"-12:"+ip_addr+"-"+neatProgramName;
//System.out.println(unit_id);
this.setResult(collResult,unit_id,"PM-00-04-001-03",WorkQueued,this.parseTime(LocalTimeStamp));
this.setResult(collResult,unit_id,"FM-00-04-001-03",WorkQueued,this.parseTime(LocalTimeStamp));
this.setResult(collResult,unit_id,"PM-00-04-001-04",NumQueued,this.parseTime(LocalTimeStamp));
}
}
/**
* PM-00-04-001-05 应用进程负载 每个应用进程得到数据的服务调用的次数
* FM-00-04-001-02 中间件可用性 中间件代理服务是否正常启动并处于可用状态
* lianlian 2006-09-11
*/
//返回结果为普通类型,多实例
//得到soap请求
String soap_performance_TUXEDOSERVERPROCINFO00= GXCollTuxedoSoapHelper.getSoap_performance_TUXEDOSERVERPROCINFO00(host_name); //soap消息
//发送soap请求,并返回结果
String soap_performance_TUXEDOSERVERPROCINFO00_res = soapClient.getSoapStringResponse(soap_performance_TUXEDOSERVERPROCINFO00);
//分析返回结果,得到list
List TUXEDOSERVERPROCINFO00_results = CollTuxedoXmlHelper.parseCommonSoapResponse(soap_performance_TUXEDOSERVERPROCINFO00_res);
if( TUXEDOSERVERPROCINFO00_results == null || TUXEDOSERVERPROCINFO00_results.size()==0){
System.out.println("@tivoli error, no TUXEDOSERVERPROCINFO00_results info got by tivoli in collCpu "+new Date());
}else{
for(int i=0; i<TUXEDOSERVERPROCINFO00_results.size(); i++){
Map rowMap = (Map)TUXEDOSERVERPROCINFO00_results.get(i);
String CurrentService = (String)rowMap.get("CurrentService");
String RequestDone = (String)rowMap.get("RequestDone");
String ProgramName = (String)rowMap.get("ProgramName");
String LocalTimeStamp = (String)rowMap.get("LocalTimeStamp");
String neatProgramName = Formater.neatenunitid(ProgramName);
String unit_id=pre_unitid+"-12:"+ip_addr+"-"+neatProgramName;
//System.out.println(unit_id);
this.setResult(collResult,unit_id,"FM-00-04-001-02",CurrentService,this.parseTime(LocalTimeStamp));
this.setResult(collResult,unit_id,"PM-00-04-001-05",RequestDone,this.parseTime(LocalTimeStamp));
}
}
/**
* PM-00-04-01-06 客户端活动连接数 正在执行操作的客户端连接个数 ClientName
* lianlian 2006-09-11
*/
String Soap_performance_TUXEDOCLIENTSPROCINFO00 = GXCollTuxedoSoapHelper.getSoap_performance_TUXEDOCLIENTSPROCINFO00(host_name);
String Soap_performance_TUXEDOCLIENTSPROCINFO00_res = soapClient.getSoapStringResponse(Soap_performance_TUXEDOCLIENTSPROCINFO00);
List TUXEDOCLIENTSPROCINFO00_result = CollTuxedoXmlHelper.parseCommonSoapResponse(Soap_performance_TUXEDOCLIENTSPROCINFO00_res);
if( TUXEDOCLIENTSPROCINFO00_result == null || TUXEDOCLIENTSPROCINFO00_result.size()==0)
{
System.out.println("@tivoli error, no TUXEDOCLIENTSPROCINFO00_result info got by tivoli in collCpu "+new Date());
}
else
{
for(int i=0; i<TUXEDOCLIENTSPROCINFO00_result.size(); i++)
{
Map rowMap = (Map)TUXEDOCLIENTSPROCINFO00_result.get(i);
String ClientName = (String)rowMap.get("ClientName");
String LocalTimeStamp = (String)rowMap.get("LocalTimeStamp");
String unit_id=pre_unitid+"-12:"+ip_addr+"-"+neat_host_name;
this.setResult(collResult,unit_id,"PM-00-04-001-06",ClientName,this.parseTime(LocalTimeStamp));
}
}
/**
* FM-00-04-001-01 应用服务状态(可选) 服务是否正常启动并处于可用状态
* lianlian 2006-09-11
*/
String Soap_performance_TUXEDOPRINTSERVICE00 = GXCollTuxedoSoapHelper.getSoap_performance_TUXEDOPRINTSERVICE00(host_name);
String Soap_performance_TUXEDOPRINTSERVICE00_res = soapClient.getSoapStringResponse(Soap_performance_TUXEDOPRINTSERVICE00);
List TUXEDOPRINTSERVICE00_result = CollTuxedoXmlHelper.parseCommonSoapResponse(Soap_performance_TUXEDOPRINTSERVICE00_res);
if( TUXEDOPRINTSERVICE00_result == null || TUXEDOPRINTSERVICE00_result.size()==0)
{
System.out.println("@tivoli error, no TUXEDOPRINTSERVICE00_result info got by tivoli in collCpu "+new Date());
}
else
{
for(int i=0; i<TUXEDOPRINTSERVICE00_result.size(); i++)
{
Map rowMap = (Map)TUXEDOPRINTSERVICE00_result.get(i);
String ProgramName = (String)rowMap.get("ProgramName");
String Status = (String)rowMap.get("Status");
String LocalTimeStamp = (String)rowMap.get("LocalTimeStamp");
String neatProgramName = Formater.neatenunitid(ProgramName);
String unit_id=pre_unitid+"-12:"+ip_addr+"-"+neatProgramName;
this.setResult(collResult,unit_id,"FM-00-04-001-01",Status,this.parseTime(LocalTimeStamp));
}
}
return collResult;
}
public Vector getConfiguration(java.util.HashMap params) throws Exception{
String host_name =(String)params.get("HOST_NAME");// AS A PART OF TIVOLI SOAP MSG, AND UNIT_ID
String ip_addr =(String)params.get("IP_ADDR"); // NOUSE , JUST AS A PART OF UNIT_ID
String neat_host_name = Formater.neatenunitid(host_name);
//String KBP_ID = this.KBP_ID+"-11"+":"+NEATENSID+"-TABLESPACES";
Vector collResult = new Vector();
/**
* CM-00-04-01-03 中间件的系统日志路径 中间件的系统日志路径
* CM-00-04-01-04 中间件的用户日志路径 中间件的用户日志路径
* lianlian 2006-09-11
*/
String Soap_configuration_TSAINFOLOGPATH00 = GXCollTuxedoSoapHelper.getSoap_configuration_TSAINFOLOGPATH00(host_name);
String Soap_configuration_TSAINFOLOGPATH00_res = soapClient.getSoapStringResponse(Soap_configuration_TSAINFOLOGPATH00);
List TSAINFOLOGPATH00_result = CollTuxedoXmlHelper.parseCommonSoapResponse(Soap_configuration_TSAINFOLOGPATH00_res);
if( TSAINFOLOGPATH00_result == null || TSAINFOLOGPATH00_result.size()==0)
{
System.out.println("@tivoli error, no TSAINFOLOGPATH00_result info got by tivoli "+new Date());
}
else
{
for(int i=0; i<TSAINFOLOGPATH00_result.size(); i++)
{
Map rowMap = (Map)TSAINFOLOGPATH00_result.get(i);
String SysLogPath = (String)rowMap.get("SysLogPath");
String UserLogPath = (String)rowMap.get("UserLogPath");
String unit_id=pre_unitid+"-12:"+ip_addr+"-"+neat_host_name;
this.setResult(collResult,unit_id,"CM-00-04-001-03",SysLogPath,new Date());
this.setResult(collResult,unit_id,"CM-00-04-001-04",UserLogPath,new Date());
}
}
/**
* CM-00-04-001-01 中间件最大并发连接数 与数据库连接数
* CM-00-04-001-02 中间件最大并发网络客户端数量 与客户端连接数
* lianlian 2006-09-11
* BBPARMS MetricValue LocalTimeStamp
*/
String soap_configuration_TUXEDOBBPARAMS00 = GXCollTuxedoSoapHelper.getSoap_configuration_TUXEDOBBPARAMS00(host_name); //soap消息
String soap_configuration_TUXEDOBBPARAMS00_res = soapClient.getSoapStringResponse(soap_configuration_TUXEDOBBPARAMS00);
//分析返回结果,得到list
String kpi_node="BBPARMS";
String value_node="MetricValue";
String time_node="LocalTimeStamp";
String unit_id=pre_unitid+"-11:"+ip_addr+"-"+neat_host_name;
//List configuration_TUXEDOBBPARAMS00_results = CollTuxedoXmlHelper.parseParamsSoapResponse(soap_configuration_TUXEDOBBPARAMS00_res,kpi_node,value_node, time_node);
List configuration_TUXEDOBBPARAMS00_results = CollTuxedoXmlHelper.parseCommonSoapResponse(soap_configuration_TUXEDOBBPARAMS00_res);
if( configuration_TUXEDOBBPARAMS00_results == null || configuration_TUXEDOBBPARAMS00_results.size()==0){
System.out.println("@tivoli error, no configuration_TUXEDOBBPARAMS00_results info got by tivoli in collCpu "+new Date());
}
else
{
for(int i=0;i<configuration_TUXEDOBBPARAMS00_results.size(); i++)
{
Map resultMap = (Map)configuration_TUXEDOBBPARAMS00_results.get(i);
String bbparms = (String)resultMap.get("BBPARMS");
String metricvalue = (String)resultMap.get("MetricValue");
String cll_time = (String)resultMap.get("LocalTimeStamp");
if(bbparms.equalsIgnoreCase("MAXSERVERS"))
{
this.setResult(collResult, unit_id, "CM-00-04-001-01" , metricvalue, this.parseTime(cll_time));
}
else if(bbparms.equalsIgnoreCase("MAXACCESSERS"))
{
this.setResult(collResult, unit_id, "CM-00-04-001-02" , metricvalue, this.parseTime(cll_time));
}
}
//tivoli名称与规范kpi名称的映射关系
/*
Map kpiMap = new java.util.HashMap();
kpiMap.put("MAXSERVERS","CM-00-04-001-01");
kpiMap.put("MAXACCESSERS","CM-00-04-001-02");
for(int i=0; i<configuration_TUXEDOBBPARAMS00_results.size(); i++){
String[] kpidetail = (String[])configuration_TUXEDOBBPARAMS00_results.get(i);
String tivoli_kpi_name = kpidetail[0].trim();
String kpi_value = kpidetail[1];
String cll_time = kpidetail[2];
String kpi_id= (String)kpiMap.get(tivoli_kpi_name);
if(kpi_id!=null){
String unit_id=pre_unitid+"-11:"+ip_addr+"-"+neat_host_name;
this.setResult(collResult, unit_id, kpi_id , kpi_value, this.parseTime(cll_time));
}
} */
}
return collResult;
}
/**
* tivoli的时间格式为1060628143502000
* 代表 2006-06-28 14-35-50
* 替换为思特奇的自己规定的时间格式
* @param tivoli_time
* @return
*/
public Date parseTime(String tivoli_time){
String tmp = tivoli_time; //1060628143502000
tmp = tmp.substring(1,tmp.length());//060628143502000
tmp = "20"+tmp;//20060628143502000
tmp = tmp.substring(0,tmp.length()-3);//20060628143502
String pattern = "yyyyMMddHHmmss";
SimpleDateFormat dateFormat = new SimpleDateFormat( pattern);
Date cll_time= new Date();
try{
cll_time= dateFormat.parse(tmp);
}catch(Exception e){
e.printStackTrace();
}
return cll_time;
}
private void setResult(Vector result, String unitID, String kpiID , String value,Date cll_time) {
try {
TblATO_KPIDETAIL record;
record = new TblATO_KPIDETAIL();
record.setCLL_TIME(new Date());
record.setKPI_ID(kpiID);
record.setKPI_VALUE(value);
record.setUNIT_ID(unitID);
record.setCLL_TIME(cll_time);
result.add(record);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) throws Exception{
GXCollTuxedo collTuxedo = new GXCollTuxedo();
java.util.HashMap params = new java.util.HashMap();
//params.put("HOST_NAME","AS1");
params.put("HOST_NAME","AS1");
params.put("IP_ADDR","10.110.x.x");
Vector v1 = collTuxedo.getConfiguration(params);
Vector v2 = collTuxedo.getPerformance(params);
String temp[][] = CheckKPIHelper.Check_Tuxedo_KPI(v1);
for(int i=0;i<temp.length;i++)
{
System.out.println("KPI_ID : " + temp[i][0] + "---" + temp[i][1]);
}
}
}