CollOracle.java
9.64 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
package com.sitech.ismp.coll;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.DES3;
import com.sitech.util.JSONUtil;
import org.apache.log4j.Logger;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Vector;
public class CollOracle implements CollOracleMBean {
private Logger logger = Logger.getLogger(CollOracle.class);
@Override
public Vector<TblATO_KPIDETAIL> getCMStandKPI(HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getCMStandKPI(params);
} catch (Exception e) {
logger.error("Exception while getCMStandKPI", e);
return new Vector<TblATO_KPIDETAIL>();
}
}
@Override
public Vector<TblATO_KPIDETAIL> getDataFile(HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getDataFile(params);
} catch (Exception e) {
logger.error("Exception while getDataFile", e);
return new Vector<TblATO_KPIDETAIL>();
}
}
@Override
public Vector<TblATO_KPIDETAIL> getExtendKPI(HashMap<String, String> params) {
try {
return new CollOracleBySql().getExtendKPI(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getExtendKPI,params=" + JSONUtil.toJSON(params), e);
}
}
//全库数据量 CM-00-03-006-02 单位G 1个月一次
public Vector<TblATO_KPIDETAIL> getTotalData(HashMap<String, String> params) {
try {
return new CollOracleBySql().getTotalData(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getTotalData,params=" + JSONUtil.toJSON(params), e);
}
}
// //数据库Headroom时间 PM-00-03-009-10 ASM归档磁盘组 PM-00-03-001-05
// public Vector<TblATO_KPIDETAIL> getAsmHeadroom(HashMap<String, String> params) {
// try {
// return new CollOracleBySql().getAsmHeadroom(params);
// } catch (Exception e) {
// throw new RuntimeException("Exception while getAsmHeadroom,params=" + JSONUtil.toJSON(params), e);
// }
// }
// 数据库Headroom时间 PM-00-03-009-10
public Vector<TblATO_KPIDETAIL> getHeadroom(HashMap<String,String> params) {
try {
return new CollOracleBySql().getHeadroom(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getHeadroom,params=" + JSONUtil.toJSON(params), e);
}
}
// ASM归档磁盘组 PM-00-03-001-05
public Vector<TblATO_KPIDETAIL> getAsmDiskGroup(HashMap<String,String> params) {
try {
return new CollOracleBySql().getAsmDiskGroup(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getAsmDiskGroup,params=" + JSONUtil.toJSON(params), e);
}
}
public Vector<TblATO_KPIDETAIL> getPMExtendKPI(HashMap<String, String> params) {
try {
return new CollOracleBySql().getPMExtendKPI(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getPMExtendKPI,params=" + JSONUtil.toJSON(params), e);
}
}
@Override
public Vector<TblATO_KPIDETAIL> getSessionWait(HashMap<String, String> params) {
try {
return new CollOracleBySql().getSessionWait(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getSessionWait,params=" + JSONUtil.toJSON(params), e);
}
}
@Override
public Vector<TblATO_KPIDETAIL> getSpecialTable(
HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getSpecialTable(params);
} catch (Exception e) {
logger.error("Exception while getSpecialTable", e);
return new Vector<TblATO_KPIDETAIL>();
}
}
@Override
public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getStatus(params);
} catch (Exception e) {
logger.error("Exception while getStatus", e);
return new Vector<TblATO_KPIDETAIL>();
}
}
@Override
public Vector<TblATO_KPIDETAIL> getSystem(HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getSystem(params);
} catch (Exception e) {
logger.error("Exception while getSystem", e);
return new Vector<TblATO_KPIDETAIL>();
}
}
@Override
public Vector<TblATO_KPIDETAIL> getTableSpaces(HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getTableSpaces(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getTableSpaces, params=" + JSONUtil.toJSON(params), e);
}
}
/**
* 调整oracle数据库回滚段表空间的监控策略
* add by mooker 2014-01-22
* @param params
* @return
*/
@Override
public Vector<TblATO_KPIDETAIL> getTableSpacesSpecial(HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getTableSpacesSpecial(params);
} catch (Exception e) {
throw new RuntimeException("Exception while getTableSpacesSpecial, params=" + JSONUtil.toJSON(params), e);
}
}
@Override
public Vector<TblATO_KPIDETAIL> getUndoTableSpaces(
HashMap<String, String> params) {
try {
CollOracleBySql collector = new CollOracleBySql();
return collector.getUndoTableSpaces(params);
} catch (Exception e) {
logger.error("Exception while getUndoTableSpaces", e);
return new Vector<TblATO_KPIDETAIL>();
}
}
private static String read(String prompt) {
Scanner scanner = new Scanner(System.in);
System.out.print(prompt);
return scanner.nextLine();
}
public static void main(String[] args) {
System.out.println("***************ORACLE Collect Test Begin*********************");
/*String ipAddr = "172.21.0.69";
String username = "ssdbomc";
String password = "ssdbomc";
String port = "1525";
String sid = "e3cloud";
String deviceId = "bnms";
String methodStr = "9";
String methodStr = "6";*/
String ipAddr = read("IP_ADDR(remote oracle service ip):\n");
String username = read("USERNAME:\n");
String password = read("PASSWORD:\n");
String port = read("PORT:\n");
String sid = read("SID:\n");
String deviceId = read("DEVICE_ID\n");
String methodStr = read("METHOD(0:getAll, 1:getExtendKPI, 2:getStatus, 3:getSystem, 4:getTableSpaces, 5:getTableSpacesSpecial, 6:getTotalData):\n");
// String methodStr = read("METHOD(0:getAll, 1:getExtendKPI, 2:getStatus, 3:getSystem,
// 4:getTableSpaces, 5:getTableSpacesSpecial, 6:getTotalData, 7:getHeadroom, 8:getAsmDiskGroup):\n");
HashMap params = new HashMap();
params.put("IP_ADDR", ipAddr);
params.put("USERNAME", username);
params.put("PASSWORD", DES3.encrypt(password));
params.put("PORT", port);
params.put("DEVICE_ID", deviceId);
params.put("SID", sid);
CollOracle coll = new CollOracle();
Vector lst = new Vector<TblATO_KPIDETAIL>();
int method = Integer.parseInt(methodStr);
switch (method) {
case 0:
lst.addAll(coll.getExtendKPI(params));
lst.addAll(coll.getStatus(params));
lst.addAll(coll.getSystem(params));
lst.addAll(coll.getTableSpaces(params));
lst.addAll(coll.getTableSpacesSpecial(params));
lst.addAll(coll.getTotalData(params));
lst.addAll(coll.getHeadroom(params));
lst.addAll(coll.getAsmDiskGroup(params));
lst.addAll(coll.getSessionWait(params));
break;
case 1:
lst.addAll(coll.getExtendKPI(params));
break;
case 2:
lst.addAll(coll.getStatus(params));
break;
case 3:
lst.addAll(coll.getSystem(params));
break;
case 4:
lst.addAll(coll.getTableSpaces(params));
break;
case 5:
lst.addAll(coll.getTableSpacesSpecial(params));
break;
case 6:
lst.addAll(coll.getTotalData(params));
break;
case 7:
lst.addAll(coll.getHeadroom(params));
break;
case 8:
lst.addAll(coll.getAsmDiskGroup(params));
break;
case 9:
lst.addAll(coll.getSessionWait(params));
break;
default:
break;
}
System.out.println("***************ORACLE Collect Test End*********************");
System.out.println("lst.size() is " + lst.size());
for (int i = 0; i < lst.size(); i++) {
TblATO_KPIDETAIL record = (TblATO_KPIDETAIL) lst.get(i);
// System.out.println(kpidetail.UNIT_ID + "|" + kpidetail.KPI_ID + "|" + kpidetail.CLL_TIME + "|" + kpidetail.KPI_VALUE);
String insSql = "INSERT INTO TB_ATO_KPIDETAIL (KPI_ID, UNIT_ID, CLL_TIME, KPI_VALUE, EXT_INFO, DB_TIME, EXT_UNIT_ID, INTERVAL) " +
"VALUES ('#KPI_ID#', '#UNIT_ID#', sysdate, '#KPI_VALUE#', 'null', sysdate, '10-11-30:bnms', #INTERVAL#);";
insSql = insSql.replace("#KPI_ID#", record.KPI_ID);
insSql = insSql.replace("#UNIT_ID#", record.UNIT_ID);
insSql = insSql.replace("#KPI_VALUE#", record.KPI_VALUE);
insSql = insSql.replace("#INTERVAL#", record.INTERVAL);
System.out.println(insSql);
}
}
}