Authored by zhangmingm

修改getPingStatus方法。

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