CollDB2.java
8.01 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
// Decompiled Using: FrontEnd Plus v2.03 and the JAD Engine
// Available From: http://www.reflections.ath.cx
// Decompiler options: packimports(3)
// Source File Name: CollOracle.java
package com.sitech.ismp.coll.tivoli.db2;
import com.sitech.ismp.coll.CollBase;
import com.sitech.ismp.coll.tivoli.linux.CollLinux;
import com.sitech.util.Formater;
import java.io.PrintStream;
import java.util.*;
import org.apache.log4j.Logger;
// Referenced classes of package com.sitech.ismp.coll.tivoli:
// CollOracleMBean, SoapParam, SoapClient, OracleSidHelper,
// CollOracleSoapHelper, CollOracleXmlHelper, UaOracleHelper, CheckKPIHelper
public class CollDB2
implements CollDB2MBean
{
private boolean debug;
private SoapClient soapClient;
private String pre_unitid;
static Logger logger = Logger.getLogger("LOGER");
public CollDB2()
{
debug = false;
soapClient = null;
pre_unitid = "10-11-30";
String url = SoapParam.getString("SOAP_URL");
soapClient = new SoapClient(url);
}
public Vector getPerformance_Thirty_Minute(HashMap params)
throws Exception
{
String host_name = (String)params.get("HOST_NAME");
String sid = DB2SidHelper.getSid(host_name);
String IP_ADDR = (String)params.get("IP_ADDR");
String neat_sid = Formater.neatenunitid(sid);
CollBase collResult = new CollBase();
//得到soap请求 表空间利用率
String soap_tbspaces_Oracle_Tablespaces = CollDB2SoapHelper.getSoap_tbspaces_Oracle_Tablespaces(sid, host_name);
//发送soap请求,并返回结果
String soap_tbspaces_Oracle_Tablespaces_res = soapClient.getSoapStringResponse(soap_tbspaces_Oracle_Tablespaces);
List tbspaces_results = CollDB2XmlHelper.parseSoapResponse(soap_tbspaces_Oracle_Tablespaces_res);
if(tbspaces_results == null || tbspaces_results.size() == 0)
{
System.out.println("@tivoli error, no tablespace info got by tivoli in collCpu " + new Date());
} else
{
for(int i = 0; i < tbspaces_results.size(); i++)
{
Map rowMap = (Map)tbspaces_results.get(i);
String tbs_used_percent = (String)rowMap.get("SPACE_USED_DMS_TABLE_PCT");
String Tablespace_Name = (String)rowMap.get("TABLESPACE_NAME");
String neatTablespace_Name = Formater.neatenunitid(Tablespace_Name);
String Tablespace_Status = (String)rowMap.get("tbsp_state_name");
if (Tablespace_Status != null
&& Tablespace_Status.equalsIgnoreCase("NORMAL")) {
collResult
.addKPI(pre_unitid + "-11:" + neat_sid
+ "-TABLESPACES" + "-"
+ neatTablespace_Name, "PM-00-03-004-01",
String.valueOf(tbs_used_percent));
System.out.println(pre_unitid + "-11:" + neat_sid
+ "-TABLESPACES" + "-"
+ neatTablespace_Name+ " PM-00-03-004-01 " +
String.valueOf(tbs_used_percent));
} else {
collResult.addKPI(pre_unitid + "-11:" + neat_sid
+ "-TABLESPACES" + "-" + neatTablespace_Name,
"PM-00-03-004-01", "offline@"
+ String.valueOf(tbs_used_percent));
}
}
}
//等待锁数量
String soap_total_Oracle_Session_Summary = CollDB2SoapHelper.getSoap_total_Oracle_Session_Summary(sid, host_name);
String soap_total_Oracle_Session_Summary_res = soapClient.getSoapStringResponse(soap_total_Oracle_Session_Summary);
List Oracle_Session_Summary_res_results = CollDB2XmlHelper.parseSoapResponse(soap_total_Oracle_Session_Summary_res);
if(Oracle_Session_Summary_res_results == null || Oracle_Session_Summary_res_results.size() == 0)
{
System.out.println("@tivoli error, no Oracle_Session_Summary_res_results info got by tivoli in collCpu " + new Date());
} else
{
int total_invalue = 0;
for(int j=0;j<Oracle_Session_Summary_res_results.size();j++){
Map row_map = (Map)Oracle_Session_Summary_res_results.get(0);
String locks_held = (String)row_map.get("locks_held");
int intNumQueued = Integer.parseInt(locks_held);
total_invalue = total_invalue + intNumQueued;
}
String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
collResult.addKPI(unit_id, "PM-10-12-10-23", String.valueOf(total_invalue));
}
return collResult.getKPISet();
}
//数据库会话数量 暂不监控
public Vector getPerformance_One_Hour(HashMap params)
throws Exception
{
String host_name = (String)params.get("HOST_NAME");
String ua_oracle_name = UaDB2Helper.getUaOracleName(host_name);
String sid = DB2SidHelper.getSid(host_name);
String IP_ADDR = (String)params.get("IP_ADDR");
String neat_sid = Formater.neatenunitid(sid);
CollBase collResult = new CollBase();
String soap_total_Oracle_Session_Summary = CollDB2SoapHelper.getSoap_total_Oracle_Session_Summary(sid, host_name);
String soap_total_Oracle_Session_Summary_res = soapClient.getSoapStringResponse(soap_total_Oracle_Session_Summary);
List Oracle_Session_Summary_res_results = CollDB2XmlHelper.parseSoapResponse(soap_total_Oracle_Session_Summary_res);
if(Oracle_Session_Summary_res_results == null || Oracle_Session_Summary_res_results.size() == 0)
{
System.out.println("@tivoli error, no Oracle_Session_Summary_res_results info got by tivoli in collCpu " + new Date());
} else
{
Map row_map = (Map)Oracle_Session_Summary_res_results.get(0);
String Total_Sessions = (String)row_map.get("Total_Sessions");
String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
collResult.addKPI(unit_id, "PM-00-03-009-03", Total_Sessions);
}
return collResult.getKPISet();
}
public Vector getFailure(HashMap params)
throws Exception
{
String host_name = (String)params.get("HOST_NAME");
String sid = DB2SidHelper.getSid(host_name);
String IP_ADDR = (String)params.get("IP_ADDR");
String neat_sid = Formater.neatenunitid(sid);
CollBase collResult = new CollBase();
String soap_total_Oracle_Server = CollDB2SoapHelper.getSoap_total_Oracle_Server(sid, host_name);
String soap_total_Oracle_Server_res = soapClient.getSoapStringResponse(soap_total_Oracle_Server);
List Oracle_Server_res_results = CollDB2XmlHelper.parseSoapResponse(soap_total_Oracle_Server_res);
if(Oracle_Server_res_results == null || Oracle_Server_res_results.size() == 0)
{
System.out.println("@tivoli error, no Oracle_Server_res_results info got by tivoli in collCpu " + new Date());
String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
collResult.addKPI(unit_id, "FM-00-03-900-01", "DOWN");
} else
{
Map row_map = (Map)Oracle_Server_res_results.get(0);
String Server_Status = (String)row_map.get("db2_status");
String unit_id = pre_unitid + "-10:" + neat_sid + "-SYS";
if("".equals(Server_Status.trim()) || Server_Status.trim().length() == 0){
logger.info("databaseStatus SoAPRequest == " + soap_total_Oracle_Server);
logger.info("databaseStatus SoAPResponse== " + soap_total_Oracle_Server_res);
}
collResult.addKPI(unit_id, "FM-00-03-001-01", Server_Status.trim());
collResult.addKPI(unit_id, "FM-00-03-900-01", "UP");
}
return collResult.getKPISet();
}
public static void main(String args[])
throws Exception
{
CollDB2 aix = new CollDB2();
HashMap params = new HashMap();
params.put("HOST_NAME","linux2");
params.put("IP_ADDR","10.110.16.215");
Vector v = new Vector();
//v.addAll(aix.getFailure(params));
//v.addAll(aix.getPerformance_Fifteen_Minute(params));
v.addAll(aix.getPerformance_Thirty_Minute(params));
}
}