Authored by 王凤

合并分支 'master_zmm' 到 'master'

修改getping方法,添加isPing参数。

修改getping方法,添加isPing参数。

查看合并请求 !9
... ... @@ -253,35 +253,36 @@ public class CollMySQLBySql {
* @return
*/
public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String,String> params) {
String url = params.get("DB_URL");
String deviceId = params.get("DEVICE_ID");
log.info(" ***//////url="+url+"///////////// deviceId="+deviceId+"//////////////////");
int start=url.indexOf("/");
int end=url.lastIndexOf(":");
String ipAddr=url.substring(start+2,end);
log.info(" ***/////////////////// ipAddr="+ipAddr+"//////////////////");
String kpiId="FM-00-10-001-999"; // mysql 主机连接状态
CheckConnectionState server=new CheckConnectionState();
String unitId = KBP_CLASS + "-10" + ":" + deviceId + "-SYS";
ParamterBean bean=new ParamterBean();
bean.setType("mysql");
bean.setDEVICE_IP(ipAddr);
String stat=server.getPingState(bean);
log.info(" **** getPingStatus ****UNIT_ID ="+unitId+"****stat="+stat+"**");
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_ID(kpiId);
kpidetail.setCLL_TIME(new Date());
kpidetail.setKPI_VALUE(stat);
} catch (ParseException e) {
log.error(" ****** kpidetail.setUNIT_ID(unitId) has error!");
e.printStackTrace();
}
String isPing = params.get("isPing"); // frank 2017-05-19 添加。Y进行ping操作,N不执行
Vector<TblATO_KPIDETAIL> vector=new Vector<TblATO_KPIDETAIL>();
vector.add(kpidetail);
if("Y".equals(isPing)){
String url = params.get("DB_URL");
String deviceId = params.get("DEVICE_ID");
log.info(" ***//////url="+url+"///////////// deviceId="+deviceId+"//////////////////");
int start=url.indexOf("/");
int end=url.lastIndexOf(":");
String ipAddr=url.substring(start+2,end);
log.info(" ***/////////////////// ipAddr="+ipAddr+"//////////////////");
String kpiId="FM-00-10-001-999"; // mysql 主机连接状态
CheckConnectionState server=new CheckConnectionState();
String unitId = KBP_CLASS + "-10" + ":" + deviceId + "-SYS";
ParamterBean bean=new ParamterBean();
bean.setType("mysql");
bean.setDEVICE_IP(ipAddr);
String stat=server.getPingState(bean);
log.info(" **** getPingStatus ****UNIT_ID ="+unitId+"****stat="+stat+"**");
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_ID(kpiId);
kpidetail.setCLL_TIME(new Date());
kpidetail.setKPI_VALUE(stat);
} catch (ParseException e) {
log.error(" ****** kpidetail.setUNIT_ID(unitId) has error!");
e.printStackTrace();
}
vector.add(kpidetail);
}
return vector;
}
... ...
... ... @@ -332,17 +332,22 @@ public class CollOracleBySql {
* @return
*/
public Vector getPingStatus(HashMap params)throws Exception {
getParams(params);
CheckConnectionState server=new CheckConnectionState();
String KBP_ID = "10-11-30-10:" + this.NEATENSID + "-SYS";
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-11-001-999", stat);
log.info(" ************************* getPingStatus ****UNIT_ID ="+KBP_ID+"****stat="+stat+"**");
return collectiondbbase.getKPISet();
String isPing = params.get("isPing")+""; // frank 2017-05-19 添加。Y进行ping操作,N不执行
Vector<TblATO_KPIDETAIL> vector=new Vector<TblATO_KPIDETAIL>();
if("Y".equals(isPing)){
getParams(params);
CheckConnectionState server=new CheckConnectionState();
String KBP_ID = "10-11-30-10:" + this.NEATENSID + "-SYS";
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-11-001-999", stat);
log.info(" ************************* getPingStatus ****UNIT_ID ="+KBP_ID+"****stat="+stat+"**");
vector=collectiondbbase.getKPISet();
}
return vector;
}
... ...
... ... @@ -108,36 +108,39 @@ public class CollLinuxHost implements CollLinuxHostMBean {
*/
public Vector getPing(HashMap params) {
Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>();
String ip=params.get("IP_ADDR")+"";
if(!StringUtils.isEmpty(ip)){
String connectStatCode="FM-00-10-001-999"; // linux 主机连接状态
String hostName=params.get("HOSTNAME")+""; // 资源标识
String unitId = kbpClass+":" + hostName + "-total";
ParamterBean bean =new ParamterBean();
bean.setDEVICE_IP(ip);
bean.setType("linux");
log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]*********");
/**
* getPingState 方法执行后会将状态插入到表中,然后取当前时间
* 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。
*/
CheckConnectionState server=new CheckConnectionState();
server.getPingState(bean);
// 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。
String state=server.getPingErrorState(ip);
TblATO_KPIDETAIL kpidetail= new TblATO_KPIDETAIL();
log.info("***** unitId**"+unitId+"** state **"+state+"*******");
try {
kpidetail.setKPI_ID(connectStatCode);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
String isPing = params.get("isPing")+""; // frank 2017-05-19 添加。Y进行ping操作,N不执行
if("Y".equals(isPing)){
String ip=params.get("IP_ADDR")+"";
if(!StringUtils.isEmpty(ip)){
String connectStatCode="FM-00-10-001-999"; // linux 主机连接状态
String hostName=params.get("HOSTNAME")+""; // 资源标识
String unitId = kbpClass+":" + hostName + "-total";
ParamterBean bean =new ParamterBean();
bean.setDEVICE_IP(ip);
bean.setType("linux");
log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]*********");
/**
* getPingState 方法执行后会将状态插入到表中,然后取当前时间
* 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。
*/
CheckConnectionState server=new CheckConnectionState();
server.getPingState(bean);
// 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。
String state=server.getPingErrorState(ip);
TblATO_KPIDETAIL kpidetail= new TblATO_KPIDETAIL();
log.info("***** unitId**"+unitId+"** state **"+state+"*******");
try {
kpidetail.setKPI_ID(connectStatCode);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
}
v.add(kpidetail);
}
v.add(kpidetail);
}
return v;
... ... @@ -153,42 +156,39 @@ public class CollLinuxHost implements CollLinuxHostMBean {
public Vector getSSH(HashMap params) {
Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>();
String ip=params.get("IP_ADDR")+"";
String result=server.getPingResultByIp(ip);
if(!StringUtils.isEmpty(result) && "UP".equals(result)){
String loginStatCode="FM-00-10-001-998"; // linux 主机登录状态
ParamterBean bean =new ParamterBean();
String tempPort=params.get("PROTOCOL_PORT")+"";
int port=0;
if(!StringUtils.isEmpty(tempPort)){
port=Integer.parseInt(tempPort);
}
String hostName=params.get("HOSTNAME")+"";
String username=params.get("USERNAME")+"";
String protocol=params.get("PROTOCOL")+"";
String password=params.get("PASSWORD")+"";
password=DES3.decrypt(password);
String unitId = kbpClass+":" + hostName + "-total";
log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]**port="+port+"***hostName="+hostName+"****");
bean.setDEVICE_IP(ip);
bean.setPROTOCOL_PORT(port);
bean.setUSER_NAME(username);
bean.setPASSWORD(password);
bean.setPROTOCOL(protocol);
String state=server.getConnectionState4SshOrTelnet(bean);
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setKPI_ID(loginStatCode);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
}
v.add(kpidetail);
String loginStatCode="FM-00-10-001-998"; // linux 主机登录状态
ParamterBean bean =new ParamterBean();
String tempPort=params.get("PROTOCOL_PORT")+"";
int port=0;
if(!StringUtils.isEmpty(tempPort)){
port=Integer.parseInt(tempPort);
}
String hostName=params.get("HOSTNAME")+"";
String username=params.get("USERNAME")+"";
String protocol=params.get("PROTOCOL")+"";
String password=params.get("PASSWORD")+"";
password=DES3.decrypt(password);
String unitId = kbpClass+":" + hostName + "-total";
log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]**port="+port+"***hostName="+hostName+"****");
bean.setDEVICE_IP(ip);
bean.setPROTOCOL_PORT(port);
bean.setUSER_NAME(username);
bean.setPASSWORD(password);
bean.setPROTOCOL(protocol);
String state=server.getConnectionState4SshOrTelnet(bean);
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setKPI_ID(loginStatCode);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
}
v.add(kpidetail);
return v;
}
... ...
... ... @@ -30,35 +30,38 @@ public class CollWindows implements CollWindowsMBean {
*/
public Vector<TblATO_KPIDETAIL> getPingState(HashMap<String, String> params){
Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>();
String ip=params.get("IP");
if(!StringUtils.isEmpty(ip)){
String kpiId="FM-00-10-001-999"; // Windows 主机连接状态
String hostName=params.get("HOST_NAME");
String unitId = kbpClass+":" + hostName + "-total";
ParamterBean bean =new ParamterBean();
bean.setDEVICE_IP(ip);
bean.setType("windows");
log.info("*** execute getPingState ** ip=["+ip+"]** unitId=["+unitId+"]*********");
/**
* getPingState 方法执行后会将状态插入到表中,然后取当前时间
* 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。
*/
CheckConnectionState server=new CheckConnectionState();
server.getPingState(bean);
// 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。
String state=server.getPingErrorState(ip);
TblATO_KPIDETAIL kpidetail= new TblATO_KPIDETAIL();
log.info("***** unitId**"+unitId+"** state **"+state+"*******");
try {
kpidetail.setKPI_ID(kpiId);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
String isPing = params.get("isPing")+""; // frank 2017-05-19 添加。Y进行ping操作,N不执行
if("Y".equals(isPing)){
String ip=params.get("IP");
if(!StringUtils.isEmpty(ip)){
String kpiId="FM-00-10-001-999"; // Windows 主机连接状态
String hostName=params.get("HOST_NAME");
String unitId = kbpClass+":" + hostName + "-total";
ParamterBean bean =new ParamterBean();
bean.setDEVICE_IP(ip);
bean.setType("windows");
log.info("*** execute getPingState ** ip=["+ip+"]** unitId=["+unitId+"]*********");
/**
* getPingState 方法执行后会将状态插入到表中,然后取当前时间
* 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。
*/
CheckConnectionState server=new CheckConnectionState();
server.getPingState(bean);
// 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。
String state=server.getPingErrorState(ip);
TblATO_KPIDETAIL kpidetail= new TblATO_KPIDETAIL();
log.info("***** unitId**"+unitId+"** state **"+state+"*******");
try {
kpidetail.setKPI_ID(kpiId);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
}
v.add(kpidetail);
}
v.add(kpidetail);
}
return v;
}
... ... @@ -74,32 +77,28 @@ public class CollWindows implements CollWindowsMBean {
Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>();
String ip=params.get("IP");
if(!StringUtils.isEmpty(ip)){
String result=server.getPingResultByIp(ip);
log.info("@@@@@###### getSnmpState ping result="+ result +"###$$$$$$$$$$%%%%%%%%%%");
if(!StringUtils.isEmpty(result) && "UP".equals(result)){
String kpiId="FM-00-10-001-998"; // Windows 设备登录状态
ParamterBean bean =new ParamterBean();
String tempPort=params.get("PORT");
String community=params.get("COMMUNITY");
int port=Integer.parseInt(tempPort);
String hostName=params.get("HOST_NAME");
log.info("******ip "+ip+"**port "+tempPort+"****hostName "+hostName+"*****");
bean.setDEVICE_IP(ip);
bean.setPROTOCOL_PORT(port);
bean.setCOMMUNITY(community);
String state=server.getConnectionState4Snmp(bean);
String unitId = kbpClass+":" + hostName + "-total";
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setKPI_ID(kpiId);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
}
v.add(kpidetail);
String kpiId="FM-00-10-001-998"; // Windows 设备登录状态
ParamterBean bean =new ParamterBean();
String tempPort=params.get("PORT");
String community=params.get("COMMUNITY");
int port=Integer.parseInt(tempPort);
String hostName=params.get("HOST_NAME");
log.info("******ip "+ip+"**port "+tempPort+"****hostName "+hostName+"*****");
bean.setDEVICE_IP(ip);
bean.setPROTOCOL_PORT(port);
bean.setCOMMUNITY(community);
String state=server.getConnectionState4Snmp(bean);
String unitId = kbpClass+":" + hostName + "-total";
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setKPI_ID(kpiId);
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_VALUE(state);
kpidetail.setCLL_TIME(new Date());
} catch (ParseException e) {
e.printStackTrace();
}
v.add(kpidetail);
}
return v;
}
... ...
... ... @@ -70,31 +70,31 @@ public class CollTomcat implements CollTomcatMBean {
*/
@Override
public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params) {
/**
* 该 kbp_class kpiId 如果不存在,需要在页面添加。
*/
String kbp_class="10-12-13-20";
String kpiId="FM-00-12-001-999";
String isPing = params.get("isPing")+""; // frank 2017-05-19 添加。Y进行ping操作,N不执行
Vector<TblATO_KPIDETAIL> vector=new Vector<TblATO_KPIDETAIL>();
String jmx_url=params.get("JMX_URL");
int start=jmx_url.indexOf("/rmi://");
int end=jmx_url.lastIndexOf(":");
String ip=jmx_url.substring(start+7,end);
/**
* domain_name 实际就是 资源标识。
*/
String domain_name = params.get("DOMAIN_NAME");
String unitId = kbp_class +":"+ Formater.neatenunitid(domain_name) + "-RUNTIME";
CheckConnectionState server=new CheckConnectionState();
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_ID(kpiId);
kpidetail.setKPI_VALUE(server.getPingState(new ParamterBean(ip)));
kpidetail.setCLL_TIME(new Date());
vector.add(kpidetail);
} catch (ParseException e){
e.printStackTrace();
if("Y".equals(isPing)){
String kbp_class="10-12-13-20";
String kpiId="FM-00-12-001-999";
String jmx_url=params.get("JMX_URL");
int start=jmx_url.indexOf("/rmi://");
int end=jmx_url.lastIndexOf(":");
String ip=jmx_url.substring(start+7,end);
/**
* domain_name 实际就是 资源标识。
*/
String domain_name = params.get("DOMAIN_NAME");
String unitId = kbp_class +":"+ Formater.neatenunitid(domain_name) + "-RUNTIME";
CheckConnectionState server=new CheckConnectionState();
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_ID(kpiId);
kpidetail.setKPI_VALUE(server.getPingState(new ParamterBean(ip)));
kpidetail.setCLL_TIME(new Date());
vector.add(kpidetail);
} catch (ParseException e){
e.printStackTrace();
}
}
return vector;
}
... ...
... ... @@ -136,29 +136,25 @@ public class CollWebLogic implements CollWebLogicMBean{
@Override
public Vector<TblATO_KPIDETAIL> getPingStatus(HashMap<String, String> params) {
/**
* 该 kbp_class kpiId 如果不存在,需要在页面添加。
*/
String kbp_class="10-12-11-20";
String kpiId="FM-00-12-001-999";
String isPing = params.get("isPing"); // frank 2017-05-19 添加。Y进行ping操作,N不执行
Vector<TblATO_KPIDETAIL> vector=new Vector<TblATO_KPIDETAIL>();
String serverip=params.get("SERVERIP");
/**
* SERVERNAME 实际就是 资源标识。
*/
String servername = params.get("SERVERNAME");
String unitId = kbp_class +":"+ Formater.neatenunitid(servername) + "-CONFIG";
CheckConnectionState server=new CheckConnectionState();
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_ID(kpiId);
kpidetail.setKPI_VALUE(server.getPingState(new ParamterBean(serverip)));
kpidetail.setCLL_TIME(new Date());
vector.add(kpidetail);
} catch (ParseException e){
e.printStackTrace();
if("Y".equals(isPing)){
String kbp_class="10-12-11-20";
String kpiId="FM-00-12-001-999";
String serverip=params.get("SERVERIP");
String servername = params.get("SERVERNAME");
String unitId = kbp_class +":"+ Formater.neatenunitid(servername) + "-CONFIG";
CheckConnectionState server=new CheckConnectionState();
TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL();
try {
kpidetail.setUNIT_ID(unitId);
kpidetail.setKPI_ID(kpiId);
kpidetail.setKPI_VALUE(server.getPingState(new ParamterBean(serverip)));
kpidetail.setCLL_TIME(new Date());
vector.add(kpidetail);
} catch (ParseException e){
e.printStackTrace();
}
}
return vector;
}
... ...