Showing
6 changed files
with
134 additions
and
122 deletions
@@ -29,6 +29,11 @@ public class CollMySQL implements CollMySQLMBean { | @@ -29,6 +29,11 @@ public class CollMySQL implements CollMySQLMBean { | ||
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | + /** | ||
33 | + * 获取数据库jdbc的连接状态。 | ||
34 | + * @param params | ||
35 | + * @return | ||
36 | + */ | ||
32 | @Override | 37 | @Override |
33 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params) { | 38 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params) { |
34 | try { | 39 | try { |
@@ -40,6 +45,22 @@ public class CollMySQL implements CollMySQLMBean { | @@ -40,6 +45,22 @@ public class CollMySQL implements CollMySQLMBean { | ||
40 | } | 45 | } |
41 | } | 46 | } |
42 | 47 | ||
48 | + /** | ||
49 | + * 获取数据库ping状态。 | ||
50 | + * @param params | ||
51 | + * @return | ||
52 | + */ | ||
53 | + @Override | ||
54 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params) { | ||
55 | + try { | ||
56 | + CollMySQLBySql collector = new CollMySQLBySql(); | ||
57 | + return collector.getPingStatus(params); | ||
58 | + } catch (Exception e) { | ||
59 | + logger.error("Exception while getPingStatus", e); | ||
60 | + return new Vector<TblATO_KPIDETAIL>(); | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
43 | @Override | 64 | @Override |
44 | public Vector<TblATO_KPIDETAIL> getPerformance(HashMap<String, String> params) { | 65 | public Vector<TblATO_KPIDETAIL> getPerformance(HashMap<String, String> params) { |
45 | try { | 66 | try { |
1 | package com.sitech.ismp.coll; | 1 | package com.sitech.ismp.coll; |
2 | 2 | ||
3 | +import com.sitech.ismp.check.downtime.CheckConnectionState; | ||
4 | +import com.sitech.ismp.check.downtime.ParamterBean; | ||
3 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | 5 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; |
4 | import com.sitech.util.DES3; | 6 | import com.sitech.util.DES3; |
5 | import com.sitech.util.Formater; | 7 | import com.sitech.util.Formater; |
6 | import com.sitech.util.JSONUtil; | 8 | import com.sitech.util.JSONUtil; |
7 | import org.apache.log4j.Logger; | 9 | import org.apache.log4j.Logger; |
8 | 10 | ||
9 | -import java.text.DecimalFormat; | ||
10 | import java.util.HashMap; | 11 | import java.util.HashMap; |
11 | import java.util.Vector; | 12 | import java.util.Vector; |
12 | 13 | ||
@@ -27,12 +28,16 @@ public class CollMySQLBySql { | @@ -27,12 +28,16 @@ public class CollMySQLBySql { | ||
27 | private String dburl = null; | 28 | private String dburl = null; |
28 | private String dbuser = null; | 29 | private String dbuser = null; |
29 | private String passwd = null; | 30 | private String passwd = null; |
31 | + private String ip = null; // 2017-04-24 frank 添加,用于获取数据库所在主机的ping状态 | ||
30 | private String device_id = null; | 32 | private String device_id = null; |
31 | private String NEATENSID = null; | 33 | private String NEATENSID = null; |
32 | 34 | ||
33 | private boolean getParams(HashMap<String, String> params) { | 35 | private boolean getParams(HashMap<String, String> params) { |
34 | try { | 36 | try { |
35 | dburl = params.get("DB_URL"); | 37 | dburl = params.get("DB_URL"); |
38 | + int start=dburl.indexOf("/"); | ||
39 | + int end=dburl.lastIndexOf(":"); | ||
40 | + ip=dburl.substring(start+2,end); | ||
36 | dbuser = params.get("USERNAME"); | 41 | dbuser = params.get("USERNAME"); |
37 | passwd = DES3.decrypt(params.get("PASSWORD")); | 42 | passwd = DES3.decrypt(params.get("PASSWORD")); |
38 | device_id = (String) params.get("DEVICE_ID"); | 43 | device_id = (String) params.get("DEVICE_ID"); |
@@ -43,6 +48,12 @@ public class CollMySQLBySql { | @@ -43,6 +48,12 @@ public class CollMySQLBySql { | ||
43 | return true; | 48 | return true; |
44 | } | 49 | } |
45 | 50 | ||
51 | + /** | ||
52 | + * 获取数据库基本信息,frank 2017-04-24 修改,添加设备状态(UP/DOWN)即主机ping的结果。 | ||
53 | + * @param params | ||
54 | + * @return | ||
55 | + * @throws Exception | ||
56 | + */ | ||
46 | public Vector<TblATO_KPIDETAIL> getSystem(HashMap<String, String> params) throws Exception { | 57 | public Vector<TblATO_KPIDETAIL> getSystem(HashMap<String, String> params) throws Exception { |
47 | getParams(params); | 58 | getParams(params); |
48 | SQLTarget colldb = new SQLTarget(); | 59 | SQLTarget colldb = new SQLTarget(); |
@@ -53,6 +64,10 @@ public class CollMySQLBySql { | @@ -53,6 +64,10 @@ public class CollMySQLBySql { | ||
53 | return sets; | 64 | return sets; |
54 | } | 65 | } |
55 | 66 | ||
67 | + /** | ||
68 | + * 获取数据库基本信息 | ||
69 | + * @param colldb | ||
70 | + */ | ||
56 | private void getSystem(SQLTarget colldb) { | 71 | private void getSystem(SQLTarget colldb) { |
57 | String UNIT_ID = KBP_CLASS + "-10" + ":" + NEATENSID + "-SYS"; | 72 | String UNIT_ID = KBP_CLASS + "-10" + ":" + NEATENSID + "-SYS"; |
58 | // CM-00-03-001-02 | 73 | // CM-00-03-001-02 |
@@ -228,21 +243,40 @@ public class CollMySQLBySql { | @@ -228,21 +243,40 @@ public class CollMySQLBySql { | ||
228 | return sets; | 243 | return sets; |
229 | } | 244 | } |
230 | 245 | ||
246 | + /** | ||
247 | + * 获取数据库ping状态。 | ||
248 | + * @param params | ||
249 | + * @return | ||
250 | + */ | ||
251 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String,String> params) { | ||
252 | + getParams(params); | ||
253 | + CheckConnectionState server=new CheckConnectionState(); | ||
254 | + SQLTarget colldb = new SQLTarget(); | ||
255 | + String UNIT_ID = KBP_CLASS + "-10" + ":" + NEATENSID + "-SYS"; | ||
256 | + ParamterBean bean=new ParamterBean(); | ||
257 | + bean.setType("mysql"); | ||
258 | + bean.setDEVICE_IP(ip); | ||
259 | + String stat=server.getPingState(bean); | ||
260 | + colldb.addKPI(UNIT_ID, "FM-00-11-001-999",stat); | ||
261 | + return colldb.getKPISet(); | ||
262 | + } | ||
263 | + | ||
264 | + | ||
231 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String,String> params) { | 265 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String,String> params) { |
232 | getParams(params); | 266 | getParams(params); |
233 | SQLTarget colldb = new SQLTarget(); | 267 | SQLTarget colldb = new SQLTarget(); |
234 | colldb.initWithClassname(DB_TYPE, CLASSNAME, dburl, dbuser, passwd); | 268 | colldb.initWithClassname(DB_TYPE, CLASSNAME, dburl, dbuser, passwd); |
235 | 269 | ||
236 | String UNIT_ID = KBP_CLASS + "-10" + ":" + NEATENSID + "-SYS"; | 270 | String UNIT_ID = KBP_CLASS + "-10" + ":" + NEATENSID + "-SYS"; |
271 | + // 修改状态的值 UP:连接正常/DOWN:连接异常 | ||
237 | if (colldb.getState()) { | 272 | if (colldb.getState()) { |
238 | - colldb.addKPI(UNIT_ID, "FM-00-03-001-01", "active"); | 273 | + colldb.addKPI(UNIT_ID, "FM-00-03-001-01", "UP"); |
239 | } else { | 274 | } else { |
240 | - colldb.addKPI(UNIT_ID, "FM-00-03-001-01", "disconnected"); | 275 | + colldb.addKPI(UNIT_ID, "FM-00-03-001-01", "DOWN"); |
241 | logger.error("----mysql--- " + device_id + "--state--err----"); | 276 | logger.error("----mysql--- " + device_id + "--state--err----"); |
242 | } | 277 | } |
243 | 278 | ||
244 | Vector sets = colldb.getKPISet(); | 279 | Vector sets = colldb.getKPISet(); |
245 | - colldb.release(); | ||
246 | return sets; | 280 | return sets; |
247 | } | 281 | } |
248 | 282 |
@@ -18,6 +18,12 @@ public abstract interface CollMySQLMBean { | @@ -18,6 +18,12 @@ public abstract interface CollMySQLMBean { | ||
18 | 18 | ||
19 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params); | 19 | public Vector<TblATO_KPIDETAIL> getStatus(HashMap<String, String> params); |
20 | 20 | ||
21 | + /** | ||
22 | + * 获取数据库所在主机的ping状态 | ||
23 | + * @param params | ||
24 | + */ | ||
25 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params); | ||
26 | + | ||
21 | public Vector<TblATO_KPIDETAIL> getPerformance(HashMap<String, String> params); | 27 | public Vector<TblATO_KPIDETAIL> getPerformance(HashMap<String, String> params); |
22 | 28 | ||
23 | public Vector<TblATO_KPIDETAIL> getInnodb(HashMap<String, String> params); | 29 | public Vector<TblATO_KPIDETAIL> getInnodb(HashMap<String, String> params); |
1 | package com.sitech.ismp.coll; | 1 | package com.sitech.ismp.coll; |
2 | 2 | ||
3 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | 3 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; |
4 | -import com.sitech.util.DES3; | ||
5 | import com.sitech.util.JSONUtil; | 4 | import com.sitech.util.JSONUtil; |
6 | import org.apache.log4j.Logger; | 5 | import org.apache.log4j.Logger; |
7 | 6 | ||
@@ -96,6 +95,22 @@ public class CollOracle implements CollOracleMBean { | @@ -96,6 +95,22 @@ public class CollOracle implements CollOracleMBean { | ||
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
98 | + /** | ||
99 | + * 获取数据库所在主机的ping状态 | ||
100 | + * @param params | ||
101 | + * @return | ||
102 | + */ | ||
103 | + @Override | ||
104 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params) { | ||
105 | + try { | ||
106 | + CollOracleBySql collector = new CollOracleBySql(); | ||
107 | + return collector.getPingStatus(params); | ||
108 | + } catch (Exception e) { | ||
109 | + logger.error("Exception while getPingStatus", e); | ||
110 | + return new Vector<TblATO_KPIDETAIL>(); | ||
111 | + } | ||
112 | + } | ||
113 | + | ||
99 | @Override | 114 | @Override |
100 | public Vector<TblATO_KPIDETAIL> getSpecialTable( | 115 | public Vector<TblATO_KPIDETAIL> getSpecialTable( |
101 | HashMap<String, String> params) { | 116 | HashMap<String, String> params) { |
@@ -174,93 +189,4 @@ public class CollOracle implements CollOracleMBean { | @@ -174,93 +189,4 @@ public class CollOracle implements CollOracleMBean { | ||
174 | return scanner.nextLine(); | 189 | return scanner.nextLine(); |
175 | } | 190 | } |
176 | 191 | ||
177 | - public static void main(String[] args) { | ||
178 | - System.out.println("***************ORACLE Collect Test Begin*********************"); | ||
179 | - /*String ipAddr = "172.21.0.69"; | ||
180 | - String username = "ssdbomc"; | ||
181 | - String password = "ssdbomc"; | ||
182 | - String port = "1525"; | ||
183 | - String sid = "e3cloud"; | ||
184 | - String deviceId = "bnms"; | ||
185 | - String methodStr = "9"; | ||
186 | - String methodStr = "6";*/ | ||
187 | - String ipAddr = read("IP_ADDR(remote oracle service ip):\n"); | ||
188 | - String username = read("USERNAME:\n"); | ||
189 | - String password = read("PASSWORD:\n"); | ||
190 | - String port = read("PORT:\n"); | ||
191 | - String sid = read("SID:\n"); | ||
192 | - String deviceId = read("DEVICE_ID\n"); | ||
193 | - String methodStr = read("METHOD(0:getAll, 1:getExtendKPI, 2:getStatus, 3:getSystem, 4:getTableSpaces, 5:getTableSpacesSpecial, 6:getTotalData):\n"); | ||
194 | -// String methodStr = read("METHOD(0:getAll, 1:getExtendKPI, 2:getStatus, 3:getSystem, | ||
195 | -// 4:getTableSpaces, 5:getTableSpacesSpecial, 6:getTotalData, 7:getHeadroom, 8:getAsmDiskGroup):\n"); | ||
196 | - | ||
197 | - HashMap params = new HashMap(); | ||
198 | - params.put("IP_ADDR", ipAddr); | ||
199 | - params.put("USERNAME", username); | ||
200 | - params.put("PASSWORD", DES3.encrypt(password)); | ||
201 | - params.put("PORT", port); | ||
202 | - params.put("DEVICE_ID", deviceId); | ||
203 | - params.put("SID", sid); | ||
204 | - | ||
205 | - CollOracle coll = new CollOracle(); | ||
206 | - Vector lst = new Vector<TblATO_KPIDETAIL>(); | ||
207 | - | ||
208 | - int method = Integer.parseInt(methodStr); | ||
209 | - switch (method) { | ||
210 | - case 0: | ||
211 | - lst.addAll(coll.getExtendKPI(params)); | ||
212 | - lst.addAll(coll.getStatus(params)); | ||
213 | - lst.addAll(coll.getSystem(params)); | ||
214 | - lst.addAll(coll.getTableSpaces(params)); | ||
215 | - lst.addAll(coll.getTableSpacesSpecial(params)); | ||
216 | - lst.addAll(coll.getTotalData(params)); | ||
217 | - lst.addAll(coll.getHeadroom(params)); | ||
218 | - lst.addAll(coll.getAsmDiskGroup(params)); | ||
219 | - lst.addAll(coll.getSessionWait(params)); | ||
220 | - break; | ||
221 | - case 1: | ||
222 | - lst.addAll(coll.getExtendKPI(params)); | ||
223 | - break; | ||
224 | - case 2: | ||
225 | - lst.addAll(coll.getStatus(params)); | ||
226 | - break; | ||
227 | - case 3: | ||
228 | - lst.addAll(coll.getSystem(params)); | ||
229 | - break; | ||
230 | - case 4: | ||
231 | - lst.addAll(coll.getTableSpaces(params)); | ||
232 | - break; | ||
233 | - case 5: | ||
234 | - lst.addAll(coll.getTableSpacesSpecial(params)); | ||
235 | - break; | ||
236 | - case 6: | ||
237 | - lst.addAll(coll.getTotalData(params)); | ||
238 | - break; | ||
239 | - case 7: | ||
240 | - lst.addAll(coll.getHeadroom(params)); | ||
241 | - break; | ||
242 | - case 8: | ||
243 | - lst.addAll(coll.getAsmDiskGroup(params)); | ||
244 | - break; | ||
245 | - case 9: | ||
246 | - lst.addAll(coll.getSessionWait(params)); | ||
247 | - break; | ||
248 | - default: | ||
249 | - break; | ||
250 | - } | ||
251 | - System.out.println("***************ORACLE Collect Test End*********************"); | ||
252 | - | ||
253 | - System.out.println("lst.size() is " + lst.size()); | ||
254 | - for (int i = 0; i < lst.size(); i++) { | ||
255 | - TblATO_KPIDETAIL record = (TblATO_KPIDETAIL) lst.get(i); | ||
256 | -// System.out.println(kpidetail.UNIT_ID + "|" + kpidetail.KPI_ID + "|" + kpidetail.CLL_TIME + "|" + kpidetail.KPI_VALUE); | ||
257 | - String insSql = "INSERT INTO TB_ATO_KPIDETAIL (KPI_ID, UNIT_ID, CLL_TIME, KPI_VALUE, EXT_INFO, DB_TIME, EXT_UNIT_ID, INTERVAL) " + | ||
258 | - "VALUES ('#KPI_ID#', '#UNIT_ID#', sysdate, '#KPI_VALUE#', 'null', sysdate, '10-11-30:bnms', #INTERVAL#);"; | ||
259 | - insSql = insSql.replace("#KPI_ID#", record.KPI_ID); | ||
260 | - insSql = insSql.replace("#UNIT_ID#", record.UNIT_ID); | ||
261 | - insSql = insSql.replace("#KPI_VALUE#", record.KPI_VALUE); | ||
262 | - insSql = insSql.replace("#INTERVAL#", record.INTERVAL); | ||
263 | - System.out.println(insSql); | ||
264 | - } | ||
265 | - } | ||
266 | } | 192 | } |
1 | package com.sitech.ismp.coll; | 1 | package com.sitech.ismp.coll; |
2 | 2 | ||
3 | -import java.util.*; | ||
4 | - | 3 | +import com.sitech.ismp.check.downtime.CheckConnectionState; |
4 | +import com.sitech.ismp.check.downtime.ParamterBean; | ||
5 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | 5 | import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; |
6 | -import org.apache.log4j.Logger; | ||
7 | - | ||
8 | import com.sitech.util.DES3; | 6 | import com.sitech.util.DES3; |
9 | import com.sitech.util.Formater; | 7 | import com.sitech.util.Formater; |
10 | import com.sitech.util.JSONUtil; | 8 | import com.sitech.util.JSONUtil; |
11 | import com.sitech.util.upload.RomoteController; | 9 | import com.sitech.util.upload.RomoteController; |
12 | -import com.sitech.util.upload.SSHThread; | ||
13 | -import com.sitech.util.upload.TelnetThread; | 10 | +import org.apache.log4j.Logger; |
11 | + | ||
12 | +import java.util.ArrayList; | ||
13 | +import java.util.HashMap; | ||
14 | +import java.util.List; | ||
15 | +import java.util.Map; | ||
16 | +import java.util.Vector; | ||
14 | 17 | ||
15 | public class CollOracleBySql { | 18 | public class CollOracleBySql { |
16 | 19 | ||
@@ -27,6 +30,7 @@ public class CollOracleBySql { | @@ -27,6 +30,7 @@ public class CollOracleBySql { | ||
27 | RomoteController tt = null; | 30 | RomoteController tt = null; |
28 | 31 | ||
29 | private Logger logger = Logger.getLogger("COLL"); | 32 | private Logger logger = Logger.getLogger("COLL"); |
33 | + private static Logger log = Logger.getLogger(CollOracleBySql.class); | ||
30 | 34 | ||
31 | // public void init(HashMap params) { | 35 | // public void init(HashMap params) { |
32 | // String hostip = (String) params.get("IP_ADDR"); | 36 | // String hostip = (String) params.get("IP_ADDR"); |
@@ -102,7 +106,7 @@ public class CollOracleBySql { | @@ -102,7 +106,7 @@ public class CollOracleBySql { | ||
102 | return result; | 106 | return result; |
103 | } | 107 | } |
104 | 108 | ||
105 | - public java.util.Vector getSystem(String IP_ADDR, String USERNAME, | 109 | + public Vector getSystem(String IP_ADDR, String USERNAME, |
106 | String PASSWORD, String KBP_ID, String SID) throws Exception { | 110 | String PASSWORD, String KBP_ID, String SID) throws Exception { |
107 | this.KBP_ID = KBP_ID; | 111 | this.KBP_ID = KBP_ID; |
108 | this.NEATENSID = Formater.neatenunitid(this.device_id); | 112 | this.NEATENSID = Formater.neatenunitid(this.device_id); |
@@ -110,14 +114,9 @@ public class CollOracleBySql { | @@ -110,14 +114,9 @@ public class CollOracleBySql { | ||
110 | collectiondbbase.init(IP_ADDR, PORT, SID, USERNAME, PASSWORD); | 114 | collectiondbbase.init(IP_ADDR, PORT, SID, USERNAME, PASSWORD); |
111 | 115 | ||
112 | getSystem(collectiondbbase); | 116 | getSystem(collectiondbbase); |
113 | - collectiondbbase.addKPI(KBP_ID + "-10" + ":" + NEATENSID + "-SYS", | ||
114 | - "CM-00-03-001-50", IP_ADDR); | ||
115 | - | 117 | + collectiondbbase.addKPI(KBP_ID + "-10" + ":" + NEATENSID + "-SYS","CM-00-03-001-50", IP_ADDR); |
116 | Vector aa = collectiondbbase.getKPISet(); | 118 | Vector aa = collectiondbbase.getKPISet(); |
117 | - // System.out.println(aa.size()); | ||
118 | - | ||
119 | collectiondbbase.release(); | 119 | collectiondbbase.release(); |
120 | - // collectiondbbase.displayKPI(); | ||
121 | return aa; | 120 | return aa; |
122 | } | 121 | } |
123 | 122 | ||
@@ -198,8 +197,7 @@ public class CollOracleBySql { | @@ -198,8 +197,7 @@ public class CollOracleBySql { | ||
198 | return getUndoTableSpaces(hostip, user, passwd, kbp_id, SID); | 197 | return getUndoTableSpaces(hostip, user, passwd, kbp_id, SID); |
199 | } | 198 | } |
200 | 199 | ||
201 | - public java.util.Vector getSystem(java.util.HashMap params) | ||
202 | - throws Exception { | 200 | + public java.util.Vector getSystem(java.util.HashMap params)throws Exception { |
203 | getParams(params); | 201 | getParams(params); |
204 | return getSystem(hostip, user, passwd, kbp_id, SID); | 202 | return getSystem(hostip, user, passwd, kbp_id, SID); |
205 | } | 203 | } |
@@ -327,27 +325,44 @@ public class CollOracleBySql { | @@ -327,27 +325,44 @@ public class CollOracleBySql { | ||
327 | return getStatus(hostip, user, passwd, kbp_id, SID); | 325 | return getStatus(hostip, user, passwd, kbp_id, SID); |
328 | } | 326 | } |
329 | 327 | ||
328 | + /** | ||
329 | + * 获取数据库所在主机的ping状态 | ||
330 | + * @param params | ||
331 | + * @return | ||
332 | + */ | ||
333 | + public Vector getPingStatus(HashMap params)throws Exception { | ||
334 | + getParams(params); | ||
335 | + | ||
336 | + CheckConnectionState server=new CheckConnectionState(); | ||
337 | + String KBP_ID = "10-11-30-10:" + this.NEATENSID + "-SYS"; | ||
338 | + log.info("*******************************************************"); | ||
339 | + log.info("*************KBP_ID= "+KBP_ID+"******************************************"); | ||
340 | + SQLTarget collectiondbbase = new SQLTarget(); | ||
341 | + ParamterBean bean=new ParamterBean(); | ||
342 | + bean.setType("oracle"); | ||
343 | + bean.setDEVICE_IP(hostip); | ||
344 | + String stat=server.getPingState(bean); | ||
345 | + collectiondbbase.addKPI(KBP_ID, "FM-00-01-002-999", stat); | ||
346 | + log.info("************* execute getPingStatus() ********PingState= "+stat+"**********"); | ||
347 | + return collectiondbbase.getKPISet(); | ||
348 | + } | ||
349 | + | ||
350 | + | ||
330 | private java.util.Vector getStatus(String IP_ADDR, String USERNAME, | 351 | private java.util.Vector getStatus(String IP_ADDR, String USERNAME, |
331 | String PASSWORD, String KBP_ID, String SID) throws Exception { | 352 | String PASSWORD, String KBP_ID, String SID) throws Exception { |
332 | this.KBP_ID = KBP_ID; | 353 | this.KBP_ID = KBP_ID; |
333 | - //this.NEATENSID = Formater.neatenunitid(SID); | ||
334 | this.NEATENSID = Formater.neatenunitid(this.device_id); | 354 | this.NEATENSID = Formater.neatenunitid(this.device_id); |
335 | - | ||
336 | System.out.println("--采集数据库状态--"); | 355 | System.out.println("--采集数据库状态--"); |
337 | KBP_ID = KBP_ID + "-10:" + this.NEATENSID + "-SYS"; | 356 | KBP_ID = KBP_ID + "-10:" + this.NEATENSID + "-SYS"; |
338 | SQLTarget collectiondbbase = new SQLTarget(); | 357 | SQLTarget collectiondbbase = new SQLTarget(); |
339 | collectiondbbase.init(IP_ADDR, PORT, SID, USERNAME, PASSWORD); | 358 | collectiondbbase.init(IP_ADDR, PORT, SID, USERNAME, PASSWORD); |
340 | - | ||
341 | - if (collectiondbbase.getState()) { | 359 | + // 获取数据库连接状态 UP:连接正常/DOWN:连接异常 |
360 | + if (collectiondbbase.getState()){ | ||
342 | logger.info("----db----" + SID + "--state--connected----"); | 361 | logger.info("----db----" + SID + "--state--connected----"); |
343 | - collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-04", "connected"); | ||
344 | - | ||
345 | - String verionInfo = collectiondbbase.getSQLKPIInfo("select status from v$instance").toLowerCase(); | ||
346 | - collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", verionInfo); | 362 | + collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", "UP"); |
347 | } else { | 363 | } else { |
348 | logger.error("----db----" + SID + "--state--disconnected----"); | 364 | logger.error("----db----" + SID + "--state--disconnected----"); |
349 | - collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-04", "disconnected"); | ||
350 | - collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", "Unknown"); | 365 | + collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", "DOWN"); |
351 | } | 366 | } |
352 | 367 | ||
353 | Vector kpi_value = collectiondbbase.getKPISet(); | 368 | Vector kpi_value = collectiondbbase.getKPISet(); |
@@ -394,11 +409,13 @@ public class CollOracleBySql { | @@ -394,11 +409,13 @@ public class CollOracleBySql { | ||
394 | //add start 活动会话数量 | 409 | //add start 活动会话数量 |
395 | String sqlActiveSession = "select STATUS,count(*) from v$session where status='ACTIVE' group by STATUS"; | 410 | String sqlActiveSession = "select STATUS,count(*) from v$session where status='ACTIVE' group by STATUS"; |
396 | Vector activeSessionDetail = collectiondbbase.getSQLKPIResult(sqlActiveSession); | 411 | Vector activeSessionDetail = collectiondbbase.getSQLKPIResult(sqlActiveSession); |
412 | + | ||
413 | + /* PM-00-03-009-04 定义的为 JDBC可链接性,这里不统一,注释掉。 | ||
397 | int activeSessionNum = 0; | 414 | int activeSessionNum = 0; |
398 | Vector activeSessionDetailVector = (Vector) activeSessionDetail.elementAt(0); | 415 | Vector activeSessionDetailVector = (Vector) activeSessionDetail.elementAt(0); |
399 | String num = (String) activeSessionDetailVector.get(1); | 416 | String num = (String) activeSessionDetailVector.get(1); |
400 | activeSessionNum = Integer.parseInt(num); | 417 | activeSessionNum = Integer.parseInt(num); |
401 | - collectiondbbase.addKPI(KBP_ID, "PM-00-03-009-04", String.valueOf(activeSessionNum)); | 418 | + collectiondbbase.addKPI(KBP_ID, "PM-00-03-009-04", String.valueOf(activeSessionNum));*/ |
402 | //add end | 419 | //add end |
403 | int sessionNum = 0; | 420 | int sessionNum = 0; |
404 | for (int i = 0; i < sessionDetail.size(); i++) { | 421 | for (int i = 0; i < sessionDetail.size(); i++) { |
@@ -683,6 +700,7 @@ public class CollOracleBySql { | @@ -683,6 +700,7 @@ public class CollOracleBySql { | ||
683 | private void getSystem(SQLTarget collectiondbbase) { | 700 | private void getSystem(SQLTarget collectiondbbase) { |
684 | String KBP_ID = this.KBP_ID + "-10" + ":" + NEATENSID + "-SYS"; | 701 | String KBP_ID = this.KBP_ID + "-10" + ":" + NEATENSID + "-SYS"; |
685 | 702 | ||
703 | + | ||
686 | collectiondbbase.addKPI(KBP_ID, "CM-00-03-001-01", collectiondbbase | 704 | collectiondbbase.addKPI(KBP_ID, "CM-00-03-001-01", collectiondbbase |
687 | .getSQLKPIInfo("select NAME from v$database")); | 705 | .getSQLKPIInfo("select NAME from v$database")); |
688 | collectiondbbase | 706 | collectiondbbase |
1 | package com.sitech.ismp.coll; | 1 | package com.sitech.ismp.coll; |
2 | 2 | ||
3 | +import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | ||
4 | + | ||
3 | import java.util.HashMap; | 5 | import java.util.HashMap; |
4 | import java.util.Vector; | 6 | import java.util.Vector; |
5 | 7 | ||
6 | -import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL; | ||
7 | - | ||
8 | public abstract interface CollOracleMBean { | 8 | public abstract interface CollOracleMBean { |
9 | 9 | ||
10 | public Vector<TblATO_KPIDETAIL> getDataFile(HashMap<String,String> params); | 10 | public Vector<TblATO_KPIDETAIL> getDataFile(HashMap<String,String> params); |
@@ -35,4 +35,11 @@ public abstract interface CollOracleMBean { | @@ -35,4 +35,11 @@ public abstract interface CollOracleMBean { | ||
35 | 35 | ||
36 | public Vector<TblATO_KPIDETAIL> getSessionWait(HashMap<String, String> params); | 36 | public Vector<TblATO_KPIDETAIL> getSessionWait(HashMap<String, String> params); |
37 | 37 | ||
38 | + /** | ||
39 | + * 获取数据库所在主机的ping状态 | ||
40 | + * @param params | ||
41 | + * @return | ||
42 | + */ | ||
43 | + public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params); | ||
44 | + | ||
38 | } | 45 | } |
-
Please register or login to post a comment