private String delete() { String level_desc = request.getParameter("level_desc"); String rootMenu = request.getParameter("rootMenuSelect"); String secondMenu = request.getParameter("secondMenuSelect"); System.out.println(secondMenu); String thirdMenu = request.getParameter("thirdMenuSelect"); Function rootFunction = null; Function secondFunction = null; Function thirdFunction = null; FunctionDao functionDao = null; try { functionDao = new FunctionDao(); rootFunction = (Function) functionDao.findByID(rootMenu); secondFunction = (Function) functionDao.findByID(secondMenu); thirdFunction = (Function) functionDao.findByID(thirdMenu); } catch (Exception e) { SysLogger.error("MenuManager.delete()", e); e.printStackTrace(); } finally { functionDao.close(); } CreateRoleFunctionTable crft = new CreateRoleFunctionTable(); List<Function> deleteFunctionList = new ArrayList<Function>(); ; if ("1".equals(level_desc)) { deleteFunctionList = crft.getAllFuctionChildByRoot(rootFunction, allFunction); deleteFunctionList.add(rootFunction); } else if ("2".equals(level_desc)) { deleteFunctionList = crft.getAllFuctionChildByRoot(secondFunction, allFunction); deleteFunctionList.add(secondFunction); } else if ("3".equals(level_desc)) { deleteFunctionList.add(thirdFunction); } String[] id = new String[deleteFunctionList.size()]; for (int i = 0; i < deleteFunctionList.size(); i++) { id[i] = String.valueOf(deleteFunctionList.get(i).getId()); } boolean result = false; try { functionDao = new FunctionDao(); result = functionDao.deletelist(id); } catch (Exception e) { result = false; SysLogger.error("MenuManager.delete()", e); e.printStackTrace(); } finally { functionDao.close(); } if (result) { return "/system/menu/saveok.jsp"; } else { return "/system/menu/saveFail.jsp"; } }
/** 保存文件 */ public int writeModelXml(Hashtable has, Hashtable hat) { int done = 1; try { for (int i = 0; i < has.size(); i++) { String[] str1 = ((String) has.get(i)).split(","); System.out.println(str1.length); // 创建节点 node; String index = str1[2]; String direction = (String) hat.get(i); index = index.replaceAll("index", ""); addNodes(index, "image/up_green.gif", str1[0], str1[1], direction); } Format format = Format.getCompactFormat(); format.setEncoding("GB2312"); format.setIndent(" "); serializer = new XMLOutputter(format); fos = new FileOutputStream(fullPath); fos.write(headBytes.getBytes()); serializer.output(doc, fos); fos.close(); } catch (Exception e) { done = 0; e.printStackTrace(); SysLogger.error("Error in XmlOperator.close()", e); } return done; }
public String execute(String action) { FunctionDao functionDao = null; try { functionDao = new FunctionDao(); allFunction = functionDao.loadAll(); } catch (Exception e) { SysLogger.error("MenuManager.getAllMenuList()", e); e.printStackTrace(); } finally { functionDao.close(); } if ("list".equals(action)) { return getAllMenuList(); } if ("ready_add".equals(action)) { return add(); } if ("addUpdate".equals(action)) { return addUpdate(); } if ("delete".equals(action)) { return delete(); } if ("ready_edit".equals(action)) { return edit(); } if ("edit".equals(action)) { return editUpdate(); } setErrorCode(ErrorMessage.ACTION_NO_FOUND); return null; }
public boolean update(BaseVo baseVo) { Oraspaceconfig vo = (Oraspaceconfig) baseVo; boolean result = false; StringBuffer sql = new StringBuffer(); sql.append("update system_oraspaceconf set ipaddress='"); sql.append(vo.getIpaddress()); sql.append("',spacename='"); sql.append(vo.getSpacename()); sql.append("',linkuse='"); sql.append(vo.getLinkuse()); sql.append("',sms="); sql.append(vo.getSms()); sql.append(",bak='"); sql.append(vo.getBak()); sql.append("',reportflag="); sql.append(vo.getReportflag()); sql.append(",alarmvalue="); sql.append(vo.getAlarmvalue()); sql.append(" where id="); sql.append(vo.getId()); try { conn.executeUpdate(sql.toString()); result = true; } catch (Exception e) { result = false; SysLogger.error("OraspaceconfigDao:update()", e); } finally { conn.close(); } return result; }
/** 对IP_Net_To_Media进行探测 */ private void doIPNetProbe() { if (DiscoverEngine.getInstance().getStopStatus() == 1) return; List ipNetTable = SnmpUtil.getInstance().getIpNetToMediaTable(this.getIpAddress(), this.getCommunity()); if (ipNetTable == null || ipNetTable.size() == 0) // important { setDiscovered(true); return; } ipTotal = ipNetTable.size(); int threadTotal = 0; // 线程总数 SysLogger.info("PER_THREAD_IP===" + PER_THREAD_IP); if (ipTotal % PER_THREAD_IP == 0) // 每个线程对N个ip进行探测 threadTotal = ipTotal / PER_THREAD_IP; else threadTotal = ipTotal / PER_THREAD_IP + 1; IPNetProbeThread probeThread = null; for (int i = 0; i < threadTotal; i++) { if (i == threadTotal - 1) probeThread = new IPNetProbeThread(this, ipNetTable.subList(i * PER_THREAD_IP, ipTotal)); else probeThread = new IPNetProbeThread( this, ipNetTable.subList(i * PER_THREAD_IP, (i + 1) * PER_THREAD_IP)); DiscoverEngine.getInstance().addThread(probeThread); } }
public void collectData(Node node, MonitoredItem monitoredItem) { Host host = (Host) node; SnmpItem item = (SnmpItem) monitoredItem; String[] oids = new String[] {"1.3.6.1.2.1.25.3.3.1.2"}; String[][] valueArray = null; try { valueArray = snmp.getTableData(host.getIpAddress(), host.getCommunity(), oids); } catch (Exception e) { valueArray = null; SysLogger.error(host.getIpAddress() + "_WindowsCpu"); } if (valueArray == null || valueArray.length == 0) { item.setMultiResults(null); return; } List list = new ArrayList(3); for (int i = 0; i < valueArray.length; i++) { MonitorResult mr = new MonitorResult(); mr.setEntity(String.valueOf(i + 1)); try { mr.setPercentage(Integer.parseInt(valueArray[i][0])); } catch (NumberFormatException nfe) { mr.setPercentage(-1); } list.add(mr); } item.setMultiResults(list); }
// 虚拟机 public List VMgetByNodeIdAndTypeAndSubType( String nodeid, String type, String subtype, String category, String vid, String name) { String sql = ""; if (subtype != null && !"null".equalsIgnoreCase(subtype) && subtype.trim().length() > 0) { sql = "select * from nms_alarm_indicators_node where nodeid='" + nodeid + "' and type='" + type + "' and subtype='" + subtype + "' and category='" + category + "' and subentity='" + vid + "' and name ='" + name + "'"; } else sql = "select * from nms_alarm_indicators_node where nodeid='" + nodeid + "' and type='" + type + "'"; SysLogger.info(sql); List list = findByCriteria(sql); return list; }
public List listByPage(int curpage, String where, int perpage) { List list = new ArrayList(); try { rs = conn.executeQuery( "select count(*) from (select max(id) 'id',ipaddress,fileName,content,backup_time,file_size,bkp_type from nms_hua3vpncfg group by ipaddress) t"); if (rs.next()) jspPage = new JspPage(perpage, curpage, rs.getInt(1)); rs = conn.executeQuery( "select max(id) 'id',ipaddress,fileName,content,backup_time,file_size,bkp_type from nms_hua3vpncfg group by ipaddress;"); // SysLogger.info("select * from " + table + " " + where ); int loop = 0; while (rs.next()) { loop++; if (loop < jspPage.getMinNum()) continue; list.add(loadFromRS(rs)); if (loop == jspPage.getMaxNum()) break; } } catch (Exception e) { SysLogger.error("BaseDao.listByPage()", e); list = null; } finally { conn.close(); } return list; }
private void ready() { String level_desc = request.getParameter("level_desc"); String editId = null; if ("1".equals(level_desc)) { editId = request.getParameter("rootMenuSelect"); } else if ("2".equals(level_desc)) { editId = request.getParameter("secondMenuSelect"); } else if ("3".equals(level_desc)) { editId = request.getParameter("thirdMenuSelect"); } FunctionDao functionDao = null; Function function = null; try { functionDao = new FunctionDao(); function = (Function) functionDao.findByID(editId); } catch (Exception e) { SysLogger.error("MenuManager.add()", e); e.printStackTrace(); } finally { functionDao.close(); } request.setAttribute("level_desc", level_desc); request.setAttribute("function", function); request.setAttribute("allFunction", allFunction); }
/** 删除一个xml */ public void deleteXml() { try { File delFile = new File(fullPath); delFile.delete(); } catch (Exception e) { SysLogger.error("删除文件操作出错" + fullPath, e); } }
public Hashtable collect_Data( NodeGatherIndicators alarmIndicatorsNode) { // Òª¸ÄΪAlarmIndicatorsNode alarmIndicatorsNode Hashtable returnHash = new Hashtable(); Vector powerVector = new Vector(); Host node = (Host) PollingEngine.getInstance() .getNodeByID(Integer.parseInt(alarmIndicatorsNode.getNodeid())); if (node == null) return null; try { Calendar date = Calendar.getInstance(); Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(node.getIpAddress()); if (ipAllData == null) ipAllData = new Hashtable(); try { String temp = "0"; String[][] valueArray = null; String[] oids = new String[] {"1.3.6.1.4.1.7564.30.2", "1.3.6.1.4.1.7564.30.3"}; valueArray = SnmpUtils.getTableData( node.getIpAddress(), node.getCommunity(), oids, node.getSnmpversion(), 3, 1000); int flag = 0; if (valueArray != null) { for (int i = 0; i < valueArray.length; i++) { ArrayVPNSystem arrayVPNSystem = new ArrayVPNSystem(); String connectionsPerSec = valueArray[i][0]; String requestsPerSec = valueArray[i][1]; arrayVPNSystem.setRequestsPerSec(Integer.parseInt(requestsPerSec)); arrayVPNSystem.setConnectionsPerSec(Integer.parseInt(connectionsPerSec)); arrayVPNSystem.setIpaddress(node.getIpAddress()); arrayVPNSystem.setCollecttime(date); arrayVPNSystem.setType("NET"); arrayVPNSystem.setSubtype("ArrayNetworks"); SysLogger.info( // "cpuUtilization:"+cpuUtilization " connectionsPerSec:" + connectionsPerSec + " requestsPerSec :" + requestsPerSec); powerVector.addElement(arrayVPNSystem); } } } catch (Exception e) { } } catch (Exception e) { } Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(node.getIpAddress()); if (ipAllData == null) ipAllData = new Hashtable(); ipAllData.put("VPNSystem", powerVector); ShareData.getSharedata().put(node.getIpAddress(), ipAllData); returnHash.put("VPNSystem", powerVector); return returnHash; }
/** ɾ³ýÒ»Ìõ¼Ç¼ */ public boolean deleteByIp(String ip) { boolean result = false; try { conn.executeUpdate("delete from ipmac where relateipaddr='" + ip + "'"); result = true; } catch (Exception ex) { SysLogger.error("Error in ArpTempDao.deleteByIp(String ip)", ex); } finally { conn.close(); } return result; }
public boolean deleteByIp(String ip) { boolean result = false; try { conn.executeUpdate("delete from nms_diskperf_data_temp where ip='" + ip + "'"); result = true; } catch (Exception ex) { SysLogger.error("Error in DiskPerfTempDao.deleteByIp(String ip) ", ex); } finally { conn.close(); } return result; }
public BaseVo findByID(String id) { BaseVo vo = null; try { rs = conn.executeQuery("select * from nms_wasconfig where id=" + id); if (rs.next()) vo = loadFromRS(rs); } catch (Exception e) { SysLogger.error("WasConfigDao.findByID()", e); vo = null; } finally { conn.close(); } return vo; }
public boolean deleteFileByIps(String[] ips) { boolean result = false; try { for (int i = 0; i < ips.length; i++) conn.addBatch("delete from nms_vpncfg where ipaddress='" + ips[i] + "'"); conn.executeBatch(); result = true; } catch (Exception ex) { SysLogger.error("BaseDao.delete()", ex); result = false; } return result; }
/** 准备更新一个新的xml */ public void init4updateXml() { try { fis = new FileInputStream(fullPath); fis.skip(headBytes.getBytes().length); builder = new SAXBuilder(); doc = builder.build(fis); root = doc.getRootElement(); nodes = root.getChild("nodes"); } catch (Exception e) { e.printStackTrace(); SysLogger.error("Error in XmlOperator.init4updateXml(),file=" + fullPath); } }
public boolean delete(String id) { boolean result = false; try { conn.addBatch("delete from nms_nodediskconfig where id=" + id); conn.executeBatch(); result = true; } catch (Exception ex) { SysLogger.error("NodediskconfigDao.delete()", ex); result = false; } finally { conn.close(); } return result; }
/** 按端口找到一个接口 */ public IfEntity getIfEntityByPort(String port) { if (port == null) return null; if (ifEntityList == null || ifEntityList.size() == 0) return null; IfEntity ifEntity = null; for (int i = 0; i < ifEntityList.size(); i++) { IfEntity obj = (IfEntity) ifEntityList.get(i); if (obj.getPort().equals(port)) { ifEntity = obj; break; } } if (ifEntity == null) SysLogger.info(ipAddress + "中没有端口为" + port + "的接口"); return ifEntity; }
/** 按接口索引找到接口 */ public IfEntity getIfEntityByIndex(String ifIndex) { if (ifEntityList == null || ifEntityList.size() == 0) return null; IfEntity ifEntity = null; for (int i = 0; i < ifEntityList.size(); i++) { IfEntity obj = (IfEntity) ifEntityList.get(i); if (obj.getIndex().equals(ifIndex)) { ifEntity = obj; break; } } if (ifEntity == null) SysLogger.info(ipAddress + "中没有索引为" + ifIndex + "的接口"); return ifEntity; }
/** 按描述找到一个接口 */ public IfEntity getIfEntityByDesc(String desc) { if (desc == null) return null; if (ifEntityList == null || ifEntityList.size() == 0) return null; IfEntity ifEntity = null; for (int i = 0; i < ifEntityList.size(); i++) { IfEntity obj = (IfEntity) ifEntityList.get(i); if (obj.getDescr().equals(desc)) { ifEntity = obj; break; } } if (ifEntity == null) SysLogger.info(ipAddress + "中没有端口描述为" + desc + "的接口"); return ifEntity; }
/** 保存文件 */ public void writeXml() { try { Format format = Format.getCompactFormat(); format.setEncoding("GB2312"); format.setIndent(" "); serializer = new XMLOutputter(format); fos = new FileOutputStream(fullPath); fos.write(headBytes.getBytes()); serializer.output(doc, fos); fos.close(); } catch (Exception e) { e.printStackTrace(); SysLogger.error("Error in XmlOperator.close()", e); } }
public void run() { try { HostNodeDao nodeDao = new HostNodeDao(); // 得到被监视的防火墙设备 List nodeList = nodeDao.loadNetwork(8); for (int i = 0; i < nodeList.size(); i++) { HostNode node = (HostNode) nodeList.get(i); } Vector vector = null; int numTasks = nodeList.size(); int numThreads = 200; try { List numList = new ArrayList(); TaskXml taskxml = new TaskXml(); numList = taskxml.ListXml(); for (int i = 0; i < numList.size(); i++) { Task task = new Task(); BeanUtils.copyProperties(task, numList.get(i)); if (task.getTaskname().equals("netthreadnum")) { numThreads = task.getPolltime().intValue(); } } } catch (Exception e) { e.printStackTrace(); } // 生成线程池 ThreadPool threadPool = null; if (nodeList != null && nodeList.size() > 0) { threadPool = new ThreadPool(nodeList.size()); // 运行任务 for (int i = 0; i < nodeList.size(); i++) { threadPool.runTask(createTask((HostNode) nodeList.get(i))); } // 关闭线程池并等待所有任务完成 threadPool.join(); threadPool.close(); } threadPool = null; } catch (Exception e) { e.printStackTrace(); } finally { SysLogger.info("********Firewall Thread Count : " + Thread.activeCount()); } }
public AlarmIndicatorsNode findByIdAndNode(String id, String nodeid) { AlarmIndicatorsNode vo = null; try { rs = conn.executeQuery( "select * from nms_alarm_indicators_node where id=" + id + " and nodeid = '" + nodeid + "'"); if (rs.next()) vo = (AlarmIndicatorsNode) loadFromRS(rs); } catch (Exception ex) { ex.printStackTrace(); SysLogger.error("BaseDao.findByIdAndNode(String id)", ex); } return vo; }
@Override public BaseVo loadFromRS(ResultSet rs) { FtpTransConfig vo = new FtpTransConfig(); try { vo.setId(rs.getInt("id")); vo.setIp(rs.getString("ip")); vo.setUsername(rs.getString("username")); vo.setPassword(rs.getString("password")); vo.setFlag(rs.getInt("flag")); } catch (Exception e) { SysLogger.error("Error in TFtpServerDao.loadFromRS()", e); vo = null; e.printStackTrace(); } return vo; }
public BaseVo loadFromRS(ResultSet rs) { ArpNodeTemp vo = new ArpNodeTemp(); try { vo.setId(rs.getInt("id")); vo.setRelateipaddr(rs.getString("relateipaddr")); vo.setIfindex(rs.getString("ifindex")); vo.setIfband(rs.getString("ifband")); vo.setIfsms(rs.getString("ifsms")); vo.setIpaddress(rs.getString("ipaddress")); vo.setCollecttime(rs.getString("collecttime")); vo.setMac(rs.getString("mac")); vo.setBak(rs.getString("bak")); } catch (Exception e) { SysLogger.error("ArpTempDao.loadFromRS()", e); } return vo; }
@Override public BaseVo loadFromRS(ResultSet rs) { CmdCfgFile vo = new CmdCfgFile(); try { vo.setId(rs.getInt("id")); vo.setTimingId(rs.getInt("timingId")); vo.setIpaddress(rs.getString("ipaddress")); vo.setFileName(rs.getString("fileName")); vo.setContent(rs.getString("content")); vo.setFileSize(rs.getInt("file_size")); vo.setBackupTime(rs.getTimestamp("backup_time")); vo.setBkpType(rs.getString("bkp_type")); vo.setBaseline(rs.getInt("baseline")); } catch (Exception e) { SysLogger.error("VPNFileConfigDao.loadFromRS()", e); vo = null; } return vo; }
/** 删除一条记录 */ public boolean deleteByNodeIdSindex(String nodeid, String sid, String subentity) { boolean result = false; try { conn.executeUpdate( "delete from nms_diskperf_data_temp where nodeid='" + nodeid + "' and sindex='" + sid + "' and subentity='" + subentity + "'"); result = true; } catch (Exception ex) { SysLogger.error("Error in DiskPerfTempDao.deleteByNodeId(String nodeid)", ex); } finally { conn.close(); } return result; }
public BaseVo loadFromRS(ResultSet rs) { GgsciConfig vo = new GgsciConfig(); // WebConfig vo=new WebConfig(); try { vo.setId(rs.getInt("id")); vo.setFlag(rs.getInt("flag")); vo.setMon_flag(rs.getInt("mon_flag")); vo.setAlias(rs.getString("alias")); vo.setSendmobiles(rs.getString("sendmobiles")); vo.setNetid(rs.getString("netid")); vo.setSendemail(rs.getString("sendemail")); vo.setSendphone(rs.getString("sendphone")); vo.setIpAddress(rs.getString("ipAddress")); vo.setSupperid(rs.getInt("supperid")); } catch (SQLException e) { SysLogger.error("GgsciConfigDao.loadFromRS()", e); } return vo; }
public BaseVo loadFromRS(ResultSet rs) { NodeTemp vo = new NodeTemp(); try { vo.setNodeid(rs.getString("nodeid")); vo.setIp(rs.getString("ip")); vo.setType(rs.getString("type")); vo.setSubtype(rs.getString("subtype")); vo.setEntity(rs.getString("entity")); vo.setSubentity(rs.getString("subentity")); vo.setThevalue(rs.getString("thevalue")); vo.setChname(rs.getString("chname")); vo.setRestype(rs.getString("restype")); vo.setSindex(rs.getString("sindex")); vo.setCollecttime(rs.getString("collecttime")); vo.setUnit(rs.getString("unit")); vo.setBak(rs.getString("bak")); } catch (Exception e) { SysLogger.error("DiskPerfTempDao.loadFromRS()", e); } return vo; }
public void run() { if (DiscoverEngine.getInstance().getStopStatus() == 1) return; snmp = SnmpUtil.getInstance(); SysLogger.info("开始分析设备" + node.getIpAddress() + "的地址转发表"); Set shieldList = DiscoverResource.getInstance().getShieldSet(); List netshieldList = DiscoverResource.getInstance().getNetshieldList(); List netincludeList = DiscoverResource.getInstance().getNetincludeList(); IfEntity ifEntity = null; IfEntity endifEntity = null; // 生成线程池 ThreadPool threadPool = new ThreadPool(addressList.size()); for (int i = 0; i < addressList.size(); i++) { // ################################### // 若不需要服务器,则不进行交换机的ARP表采集 // if(1==1)continue; // ################################### try { // node.updateCount(2); IpAddress ipAddr = (IpAddress) addressList.get(i); threadPool.runTask(NetMediThread.createTask(ipAddr, node)); // SysLogger.info("在"+node.getIpAddress()+"的地址转发表发现IP "+ipAddr.getIpAddress()+",开始分析"); } catch (Exception ex) { ex.printStackTrace(); } } // end_for // 关闭线程池并等待所有任务完成 threadPool.join(); threadPool.close(); threadPool = null; DiscoverEngine.getInstance().addDiscoverdcount(); snmp = null; setCompleted(true); } // end_run