Authored by zhangmingm

修改getPingStatus方法。

... ... @@ -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;
}
... ...