Authored by zhangmingm

修改getSnmpState方法。

... ... @@ -65,7 +65,7 @@ public class CollWindows implements CollWindowsMBean {
/**
* 获取连接状态
* 获取连接状态,在进行连接之前,检查该设备是否能ping通,如果为down就不执行操作了。
* @param params
* @return
*/
... ... @@ -73,30 +73,32 @@ public class CollWindows implements CollWindowsMBean {
public Vector<TblATO_KPIDETAIL> getSnmpState(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-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();
String result=server.getPingResultByIp(ip);
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);
}
v.add(kpidetail);
}
return v;
}
... ...