|
|
package com.sitech.ismp.coll;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.sitech.ismp.check.downtime.CheckConnectionState;
|
|
|
import com.sitech.ismp.check.downtime.ParamterBean;
|
|
|
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import com.sitech.util.DES3;
|
|
|
import com.sitech.util.Formater;
|
|
|
import com.sitech.util.JSONUtil;
|
|
|
import com.sitech.util.upload.RomoteController;
|
|
|
import com.sitech.util.upload.SSHThread;
|
|
|
import com.sitech.util.upload.TelnetThread;
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Vector;
|
|
|
|
|
|
public class CollOracleBySql {
|
|
|
|
...
|
...
|
@@ -27,6 +30,7 @@ public class CollOracleBySql { |
|
|
RomoteController tt = null;
|
|
|
|
|
|
private Logger logger = Logger.getLogger("COLL");
|
|
|
private static Logger log = Logger.getLogger(CollOracleBySql.class);
|
|
|
|
|
|
// public void init(HashMap params) {
|
|
|
// String hostip = (String) params.get("IP_ADDR");
|
...
|
...
|
@@ -102,7 +106,7 @@ public class CollOracleBySql { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public java.util.Vector getSystem(String IP_ADDR, String USERNAME,
|
|
|
public Vector getSystem(String IP_ADDR, String USERNAME,
|
|
|
String PASSWORD, String KBP_ID, String SID) throws Exception {
|
|
|
this.KBP_ID = KBP_ID;
|
|
|
this.NEATENSID = Formater.neatenunitid(this.device_id);
|
...
|
...
|
@@ -110,14 +114,9 @@ public class CollOracleBySql { |
|
|
collectiondbbase.init(IP_ADDR, PORT, SID, USERNAME, PASSWORD);
|
|
|
|
|
|
getSystem(collectiondbbase);
|
|
|
collectiondbbase.addKPI(KBP_ID + "-10" + ":" + NEATENSID + "-SYS",
|
|
|
"CM-00-03-001-50", IP_ADDR);
|
|
|
|
|
|
collectiondbbase.addKPI(KBP_ID + "-10" + ":" + NEATENSID + "-SYS","CM-00-03-001-50", IP_ADDR);
|
|
|
Vector aa = collectiondbbase.getKPISet();
|
|
|
// System.out.println(aa.size());
|
|
|
|
|
|
collectiondbbase.release();
|
|
|
// collectiondbbase.displayKPI();
|
|
|
return aa;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -198,8 +197,7 @@ public class CollOracleBySql { |
|
|
return getUndoTableSpaces(hostip, user, passwd, kbp_id, SID);
|
|
|
}
|
|
|
|
|
|
public java.util.Vector getSystem(java.util.HashMap params)
|
|
|
throws Exception {
|
|
|
public java.util.Vector getSystem(java.util.HashMap params)throws Exception {
|
|
|
getParams(params);
|
|
|
return getSystem(hostip, user, passwd, kbp_id, SID);
|
|
|
}
|
...
|
...
|
@@ -327,27 +325,44 @@ public class CollOracleBySql { |
|
|
return getStatus(hostip, user, passwd, kbp_id, SID);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取数据库所在主机的ping状态
|
|
|
* @param params
|
|
|
* @return
|
|
|
*/
|
|
|
public Vector getPingStatus(HashMap params)throws Exception {
|
|
|
getParams(params);
|
|
|
|
|
|
CheckConnectionState server=new CheckConnectionState();
|
|
|
String KBP_ID = "10-11-30-10:" + this.NEATENSID + "-SYS";
|
|
|
log.info("*******************************************************");
|
|
|
log.info("*************KBP_ID= "+KBP_ID+"******************************************");
|
|
|
SQLTarget collectiondbbase = new SQLTarget();
|
|
|
ParamterBean bean=new ParamterBean();
|
|
|
bean.setType("oracle");
|
|
|
bean.setDEVICE_IP(hostip);
|
|
|
String stat=server.getPingState(bean);
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-01-002-999", stat);
|
|
|
log.info("************* execute getPingStatus() ********PingState= "+stat+"**********");
|
|
|
return collectiondbbase.getKPISet();
|
|
|
}
|
|
|
|
|
|
|
|
|
private java.util.Vector getStatus(String IP_ADDR, String USERNAME,
|
|
|
String PASSWORD, String KBP_ID, String SID) throws Exception {
|
|
|
this.KBP_ID = KBP_ID;
|
|
|
//this.NEATENSID = Formater.neatenunitid(SID);
|
|
|
this.NEATENSID = Formater.neatenunitid(this.device_id);
|
|
|
|
|
|
System.out.println("--采集数据库状态--");
|
|
|
KBP_ID = KBP_ID + "-10:" + this.NEATENSID + "-SYS";
|
|
|
SQLTarget collectiondbbase = new SQLTarget();
|
|
|
collectiondbbase.init(IP_ADDR, PORT, SID, USERNAME, PASSWORD);
|
|
|
|
|
|
if (collectiondbbase.getState()) {
|
|
|
// 获取数据库连接状态 UP:连接正常/DOWN:连接异常
|
|
|
if (collectiondbbase.getState()){
|
|
|
logger.info("----db----" + SID + "--state--connected----");
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-04", "connected");
|
|
|
|
|
|
String verionInfo = collectiondbbase.getSQLKPIInfo("select status from v$instance").toLowerCase();
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", verionInfo);
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", "UP");
|
|
|
} else {
|
|
|
logger.error("----db----" + SID + "--state--disconnected----");
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-04", "disconnected");
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", "Unknown");
|
|
|
collectiondbbase.addKPI(KBP_ID, "FM-00-03-001-01", "DOWN");
|
|
|
}
|
|
|
|
|
|
Vector kpi_value = collectiondbbase.getKPISet();
|
...
|
...
|
@@ -394,11 +409,13 @@ public class CollOracleBySql { |
|
|
//add start 活动会话数量
|
|
|
String sqlActiveSession = "select STATUS,count(*) from v$session where status='ACTIVE' group by STATUS";
|
|
|
Vector activeSessionDetail = collectiondbbase.getSQLKPIResult(sqlActiveSession);
|
|
|
|
|
|
/* PM-00-03-009-04 定义的为 JDBC可链接性,这里不统一,注释掉。
|
|
|
int activeSessionNum = 0;
|
|
|
Vector activeSessionDetailVector = (Vector) activeSessionDetail.elementAt(0);
|
|
|
String num = (String) activeSessionDetailVector.get(1);
|
|
|
activeSessionNum = Integer.parseInt(num);
|
|
|
collectiondbbase.addKPI(KBP_ID, "PM-00-03-009-04", String.valueOf(activeSessionNum));
|
|
|
collectiondbbase.addKPI(KBP_ID, "PM-00-03-009-04", String.valueOf(activeSessionNum));*/
|
|
|
//add end
|
|
|
int sessionNum = 0;
|
|
|
for (int i = 0; i < sessionDetail.size(); i++) {
|
...
|
...
|
@@ -683,6 +700,7 @@ public class CollOracleBySql { |
|
|
private void getSystem(SQLTarget collectiondbbase) {
|
|
|
String KBP_ID = this.KBP_ID + "-10" + ":" + NEATENSID + "-SYS";
|
|
|
|
|
|
|
|
|
collectiondbbase.addKPI(KBP_ID, "CM-00-03-001-01", collectiondbbase
|
|
|
.getSQLKPIInfo("select NAME from v$database"));
|
|
|
collectiondbbase
|
...
|
...
|
|