@SuppressWarnings("unchecked") public Hashtable collect_Data(NodeGatherIndicators nodeGatherIndicators) { WasConfig wasconf = null; String id = nodeGatherIndicators.getNodeid(); SysLogger.info("#######################WebSphere Ping 开始采集###################################"); try { WasConfigDao dao = new WasConfigDao(); try { wasconf = (WasConfig) dao.findByID(id); SysLogger.info( "###############WebSphere Ping 名称:" + wasconf.getName() + " ipaddress:" + wasconf.getIpaddress() + "#####################"); } catch (Exception e) { e.printStackTrace(); } finally { dao.close(); } Hashtable hst = (Hashtable) ShareData.getWasdata().get(wasconf.getIpaddress()); if (hst == null) { hst = new Hashtable(); } UrlConncetWas conWas = new UrlConncetWas(); boolean collectWasIsOK = false; // 采集数据 try { String url = "http://" + wasconf.getIpaddress() + ":" + wasconf.getPortnum() + "/wasPerfTool/servlet/perfservlet?refreshConfig=true"; System.out.println(url); collectWasIsOK = conWas.connectWasIsOK(wasconf.getIpaddress(), wasconf.getPortnum()); } catch (Exception e) { e.printStackTrace(); } String pingValue = "0"; if (collectWasIsOK) { pingValue = "100"; hst.put("ping", "100"); } else { hst.put("ping", "0"); } // 保存数据库 Pingcollectdata hostdata = new Pingcollectdata(); hostdata.setIpaddress(wasconf.getIpaddress()); Calendar date = Calendar.getInstance(); hostdata.setCollecttime(date); hostdata.setCategory("WasPing"); hostdata.setEntity("Utilization"); hostdata.setSubentity("ConnectUtilization"); hostdata.setRestype("dynamic"); hostdata.setUnit("%"); hostdata.setThevalue(pingValue); WasConfigDao wasconfigdao = new WasConfigDao(); try { wasconfigdao.createHostData(wasconf, hostdata); } catch (Exception e) { e.printStackTrace(); } finally { wasconfigdao.close(); } ShareData.getWasdata().put(wasconf.getIpaddress(), hst); // 告警,只告警PING值 if (pingValue != null) { NodeUtil nodeUtil = new NodeUtil(); NodeDTO nodeDTO = nodeUtil.conversionToNodeDTO(wasconf); // 判断是否存在此告警指标 AlarmIndicatorsUtil alarmIndicatorsUtil = new AlarmIndicatorsUtil(); List list = alarmIndicatorsUtil.getAlarmInicatorsThresholdForNode( nodeDTO.getId() + "", nodeDTO.getType(), nodeDTO.getSubtype()); CheckEventUtil checkEventUtil = new CheckEventUtil(); for (int i = 0; i < list.size(); i++) { AlarmIndicatorsNode alarmIndicatorsNode = (AlarmIndicatorsNode) list.get(i); if ("ping".equalsIgnoreCase(alarmIndicatorsNode.getName())) { if (pingValue != null) { checkEventUtil.checkEvent(nodeDTO, alarmIndicatorsNode, pingValue); } } } } } catch (Exception e) { e.printStackTrace(); } return null; }
public Hashtable collect_Data(NodeGatherIndicators alarmIndicatorsNode) { Hashtable returnHash = new Hashtable(); Vector fanVector = new Vector(); Host node = (Host) PollingEngine.getInstance() .getNodeByID(Integer.parseInt(alarmIndicatorsNode.getNodeid())); if (node == null) return returnHash; try { Interfacecollectdata interfacedata = new Interfacecollectdata(); Calendar date = Calendar.getInstance(); Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(node.getIpAddress()); if (ipAllData == null) ipAllData = new Hashtable(); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); com.afunms.polling.base.Node snmpnode = (com.afunms.polling.base.Node) PollingEngine.getInstance().getNodeByIP(node.getIpAddress()); Date cc = date.getTime(); String time = sdf.format(cc); snmpnode.setLastTime(time); } catch (Exception e) { } try { String[][] valueArray = null; String[] oids = new String[] { "1.3.6.1.4.1.116.5.11.4.1.1.7.1.1", // dkuRaidListIndexSerialNumber "1.3.6.1.4.1.116.5.11.4.1.1.7.1.4" // dkuHWEnvironment }; valueArray = SnmpUtils.getTemperatureTableData( node.getIpAddress(), node.getCommunity(), oids, node.getSnmpversion(), node.getSecuritylevel(), node.getSecurityName(), node.getV3_ap(), node.getAuthpassphrase(), node.getV3_privacy(), node.getPrivacyPassphrase(), 3, 1000 * 30); int flag = 0; if (valueArray != null) { for (int i = 0; i < valueArray.length; i++) { String _value = valueArray[i][1]; String index = valueArray[i][2]; String num = valueArray[i][0]; flag = flag + 1; List alist = new ArrayList(); alist.add(index); alist.add(_value); alist.add(num); interfacedata = new Interfacecollectdata(); interfacedata.setIpaddress(node.getIpAddress()); interfacedata.setCollecttime(date); interfacedata.setCategory("Env"); interfacedata.setEntity(index); interfacedata.setSubentity(num); interfacedata.setRestype("dynamic"); interfacedata.setUnit(""); interfacedata.setThevalue(_value); SysLogger.info(node.getIpAddress() + " 索引:" + index + " 环境状态: " + _value); fanVector.addElement(interfacedata); } } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } if (!(ShareData.getSharedata().containsKey(node.getIpAddress()))) { Hashtable ipAllData = new Hashtable(); if (ipAllData == null) ipAllData = new Hashtable(); if (fanVector != null && fanVector.size() > 0) ipAllData.put("eenv", fanVector); ShareData.getSharedata().put(node.getIpAddress(), ipAllData); } else { if (fanVector != null && fanVector.size() > 0) ((Hashtable) ShareData.getSharedata().get(node.getIpAddress())).put("eenv", fanVector); } returnHash.put("env", fanVector); try { AlarmIndicatorsUtil alarmIndicatorsUtil = new AlarmIndicatorsUtil(); List list = alarmIndicatorsUtil.getAlarmInicatorsThresholdForNode( String.valueOf(node.getId()), AlarmConstant.TYPE_STORAGE, "hds", "eenv"); AlarmHelper helper = new AlarmHelper(); Hashtable<String, EnvConfig> envHashtable = helper.getAlarmConfig(node.getIpAddress(), "eenv"); for (int i = 0; i < list.size(); i++) { AlarmIndicatorsNode alarmIndicatorsnode = (AlarmIndicatorsNode) list.get(i); // 对风扇值进行告警检测 CheckEventUtil checkutil = new CheckEventUtil(); if (fanVector.size() > 0) { for (int j = 0; j < fanVector.size(); j++) { Interfacecollectdata data = (Interfacecollectdata) fanVector.get(j); if (data != null) { EnvConfig config = envHashtable.get(data.getEntity()); if (config != null && config.getEnabled() == 1) { alarmIndicatorsnode.setAlarm_level(config.getAlarmlevel()); alarmIndicatorsnode.setAlarm_times(config.getAlarmtimes() + ""); alarmIndicatorsnode.setLimenvalue0(config.getAlarmvalue() + ""); checkutil.checkEvent( node, alarmIndicatorsnode, data.getThevalue(), data.getSubentity()); } } } } } } catch (Exception e) { e.printStackTrace(); } fanVector = null; // 把采集结果生成sql HDSEnvEnvResultTosql tosql = new HDSEnvEnvResultTosql(); tosql.CreateResultTosql(returnHash, node.getIpAddress()); return returnHash; }