예제 #1
0
 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";
   }
 }
예제 #2
0
 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;
 }
예제 #3
0
 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);
 }
  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 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;
  }
 /** 保存文件 */
 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 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;
  }
 /** 删除一个xml */
 public void deleteXml() {
   try {
     File delFile = new File(fullPath);
     delFile.delete();
   } catch (Exception e) {
     SysLogger.error("删除文件操作出错" + fullPath, e);
   }
 }
예제 #9
0
 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;
 }
예제 #10
0
 /** ɾ³ýÒ»Ìõ¼Ç¼ */
 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;
 }
예제 #11
0
 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 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);
   }
 }
예제 #16
0
 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;
 }
예제 #17
0
 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;
  }
 @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;
 }
예제 #20
0
 /** 删除一条记录 */
 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;
  }
예제 #22
0
 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;
 }
예제 #23
0
  /* (non-Javadoc)
   * @see com.dhcc.webnms.host.snmp.AbstractSnmp#collectData()
   */
  public Hashtable collect_Data(NodeGatherIndicators alarmIndicatorsNode) {
    Hashtable returnHash = new Hashtable();
    Vector diskVector = new Vector();
    List cpuList = new ArrayList();
    Host node =
        (Host)
            PollingEngine.getInstance()
                .getNodeByID(Integer.parseInt(alarmIndicatorsNode.getNodeid()));

    try {
      Diskcollectdata diskdata = null;
      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) {

      }
      // -------------------------------------------------------------------------------------------disk start
      try {
        String[] oids =
            new String[] {
              "1.3.6.1.2.1.25.2.3.1.1",
              "1.3.6.1.2.1.25.2.3.1.2",
              "1.3.6.1.2.1.25.2.3.1.3",
              "1.3.6.1.2.1.25.2.3.1.4",
              "1.3.6.1.2.1.25.2.3.1.5",
              "1.3.6.1.2.1.25.2.3.1.6",
              "1.3.6.1.2.1.25.2.3.1.7"
            };

        String[][] valueArray = null;
        try {
          valueArray =
              SnmpUtils.getTableData(
                  node.getIpAddress(),
                  node.getCommunity(),
                  oids,
                  node.getSnmpversion(),
                  3,
                  1000 * 30);
        } catch (Exception e) {
          valueArray = null;
          SysLogger.error(node.getIpAddress() + "_WindowsDiskSnmp");
        }
        for (int i = 0; i < valueArray.length; i++) {
          diskdata = new Diskcollectdata();
          diskdata.setIpaddress(node.getIpAddress());
          diskdata.setCollecttime(date);
          diskdata.setCategory("Disk");
          diskdata.setEntity("Utilization");
          diskdata.setRestype("static");
          diskdata.setUnit("%");
          String descriptions = valueArray[i][2];
          String byteunit = valueArray[i][3];
          String desc = "";
          if (descriptions == null) descriptions = "";
          if (descriptions.indexOf("Memory") >= 0) {
          } else {
            if (descriptions.trim().length() > 2) {
              desc = descriptions.substring(0, 3);
            }
          }
          if (descriptions.indexOf("\\") >= 0) {
            desc = desc.replace("\\", "/");
          }
          diskdata.setSubentity(desc);
          float value = 0.0f;
          String svb4 = valueArray[i][4];
          String svb5 = valueArray[i][5];
          int allsize = Integer.parseInt(svb4.trim());
          int used = Integer.parseInt(svb5.trim());
          if (allsize != 0) {
            value = used * 100.0f / allsize;
          } else {
            value = 0.0f;
          }
          diskdata.setThevalue(Float.toString(value));

          if (diskdata.getSubentity().equals("Physical Memory")) {
          } else if (diskdata.getSubentity().equals("Virtual Memory")) {
          } else {
            if (diskdata.getSubentity().trim().length() > 0) {
              // SysLogger.info(diskdata.getSubentity()+"===="+diskdata.getThevalue());
              diskVector.addElement(diskdata);
            }
          }

          diskdata = new Diskcollectdata();
          diskdata.setIpaddress(node.getIpAddress());
          diskdata.setCollecttime(date);
          diskdata.setCategory("Disk");
          diskdata.setEntity("AllSize");
          diskdata.setRestype("static");
          diskdata.setSubentity(desc);
          float size = 0.0f;
          size = allsize * Long.parseLong(byteunit) * 1.0f / 1024 / 1024;
          String unit = "";
          if (size >= 1024.0f) {
            size = size / 1024;
            diskdata.setUnit("G");
            unit = "G";
          } else {
            diskdata.setUnit("M");
            unit = "M";
          }
          diskdata.setThevalue(Float.toString(size));
          if (diskdata.getSubentity().equals("Virtual Memory")) {}

          if (!diskdata.getSubentity().equals("Physical Memory")
              && !diskdata.getSubentity().equals("Virtual Memory")
              && diskdata.getSubentity().trim().length() > 0) {
            diskVector.addElement(diskdata);
          }
          diskdata = new Diskcollectdata();
          diskdata.setIpaddress(node.getIpAddress());
          diskdata.setCollecttime(date);
          diskdata.setCategory("Disk");
          diskdata.setEntity("UsedSize");
          diskdata.setRestype("static");
          diskdata.setSubentity(desc);
          size = used * Long.parseLong(byteunit) * 1.0f / 1024 / 1024;
          if ("G".equals(unit)) {
            size = size / 1024;
            diskdata.setUnit("G");
          } else {
            diskdata.setUnit("M");
          }
          diskdata.setThevalue(Float.toString(size));
          if (!diskdata.getSubentity().equals("Physical Memory")
              && !diskdata.getSubentity().equals("Virtual Memory")
              && diskdata.getSubentity().trim().length() > 0) {
            diskVector.addElement(diskdata);
          }
          try {
            String diskinc = "0.0";
            float pastutil = 0.0f;
            Vector disk_v = (Vector) ipAllData.get("disk");
            if (disk_v != null && disk_v.size() > 0) {
              for (int si = 0; si < disk_v.size(); si++) {
                Diskcollectdata disk_data = (Diskcollectdata) disk_v.elementAt(si);
                if ((desc).equals(disk_data.getSubentity())
                    && "Utilization".equals(disk_data.getEntity())) {
                  pastutil = Float.parseFloat(disk_data.getThevalue());
                }
              }
            } else {
              pastutil = value;
            }
            if (pastutil == 0) {
              pastutil = value;
            }
            if (value - pastutil > 0) {
              diskinc = (value - pastutil) + "";
            }
            // System.out.println("diskinc------------------"+diskinc);
            diskdata = new Diskcollectdata();
            diskdata.setIpaddress(node.getIpAddress());
            diskdata.setCollecttime(date);
            diskdata.setCategory("Disk");
            diskdata.setEntity("UtilizationInc"); // 利用增长率百分比
            diskdata.setSubentity(desc);
            diskdata.setRestype("dynamic");
            diskdata.setUnit("%");
            diskdata.setThevalue(diskinc);
            if (diskdata.getSubentity().equals("Physical Memory")
                || diskdata.getSubentity().equals("Virtual Memory")) {

            } else {
              if (diskdata.getSubentity().trim().length() > 0) {

                diskVector.addElement(diskdata);
              }
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      } catch (Exception e) {
        // e.printStackTrace();
      }
      // --------------------------------------------------------------------------------------disk
      // end
    } catch (Exception e) {
      // returnHash=null;
      // e.printStackTrace();
      // return null;
    }

    //		Hashtable ipAllData = new Hashtable();
    //		try{
    //			ipAllData = (Hashtable)ShareData.getSharedata().get(node.getIpAddress());
    //		}catch(Exception e){
    //
    //		}
    //		if(ipAllData == null)ipAllData = new Hashtable();
    //		ipAllData.put("disk",diskVector);
    //	    ShareData.getSharedata().put(node.getIpAddress(), ipAllData);
    //	    returnHash.put("disk", diskVector);

    if (!(ShareData.getSharedata().containsKey(node.getIpAddress()))) {
      Hashtable ipAllData = new Hashtable();
      if (ipAllData == null) ipAllData = new Hashtable();
      if (diskVector != null && diskVector.size() > 0) ipAllData.put("disk", diskVector);

      ShareData.getSharedata().put(node.getIpAddress(), ipAllData);
    } else {
      if (diskVector != null && diskVector.size() > 0)
        ((Hashtable) ShareData.getSharedata().get(node.getIpAddress())).put("disk", diskVector);
    }
    returnHash.put("disk", diskVector);

    // 进行磁盘告警检测
    // SysLogger.info("### 开始运行检测磁盘是否告警### ... ###");
    try {
      AlarmIndicatorsUtil alarmIndicatorsUtil = new AlarmIndicatorsUtil();
      List list =
          alarmIndicatorsUtil.getAlarmInicatorsThresholdForNode(
              String.valueOf(node.getId()), AlarmConstant.TYPE_HOST, "windows");
      for (int i = 0; i < list.size(); i++) {
        AlarmIndicatorsNode alarmIndicatorsnode = (AlarmIndicatorsNode) list.get(i);
        // SysLogger.info("alarmIndicatorsnode name ======"+alarmIndicatorsnode.getName());
        if (alarmIndicatorsnode.getName().equalsIgnoreCase("diskperc")) {
          CheckEventUtil checkutil = new CheckEventUtil();
          checkutil.checkDisk(node, diskVector, alarmIndicatorsnode);
          break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    // 进行磁盘告警检测
    // SysLogger.info("### 开始运行检测磁盘是否告警### ... ###");
    try {
      AlarmIndicatorsUtil alarmIndicatorsUtil = new AlarmIndicatorsUtil();
      List list =
          alarmIndicatorsUtil.getAlarmInicatorsThresholdForNode(
              String.valueOf(node.getId()), AlarmConstant.TYPE_HOST, "windows");
      for (int i = 0; i < list.size(); i++) {
        AlarmIndicatorsNode alarmIndicatorsnode = (AlarmIndicatorsNode) list.get(i);
        // SysLogger.info("alarmIndicatorsnode name ======"+alarmIndicatorsnode.getName());
        if (alarmIndicatorsnode.getName().equalsIgnoreCase("diskinc")) {
          CheckEventUtil checkutil = new CheckEventUtil();
          checkutil.checkDisk(node, diskVector, alarmIndicatorsnode);
          break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    // 把采集结果生成sql
    HostdiskResultosql tosql = new HostdiskResultosql();
    tosql.CreateResultTosql(returnHash, node.getIpAddress());

    HostDatatempDiskRttosql temptosql = new HostDatatempDiskRttosql();
    temptosql.CreateResultTosql(returnHash, node);

    return returnHash;
  }
예제 #24
0
 private String addUpdate() {
   String level_desc = request.getParameter("level_desc");
   String ch_desc = request.getParameter("ch_desc");
   String fatherNode = request.getParameter("fatherNode");
   String url = request.getParameter("url");
   String img_url = request.getParameter("img_url");
   String isCurrentWindow = request.getParameter("isCurrentWindow");
   String width = request.getParameter("width");
   String height = request.getParameter("height");
   String clientX = request.getParameter("clientX");
   String clientY = request.getParameter("clientY");
   int fatherId = 0;
   List<Function> functionList = null;
   Function functionFather = null;
   CreateRoleFunctionTable crft = new CreateRoleFunctionTable();
   if (!level_desc.equals("1") && fatherNode != null) {
     for (int i = 0; i < allFunction.size(); i++) {
       if (allFunction.get(i).getId() == Integer.valueOf(fatherNode)) {
         fatherId = allFunction.get(i).getId();
         functionFather = allFunction.get(i);
       }
     }
     functionList = crft.getFunctionChild(functionFather, allFunction);
   } else if (level_desc.equals("1") && fatherNode == null) {
     fatherId = 0;
     functionList = crft.getAllMenuRoot(allFunction);
   }
   String nextFunc_desc = getNextFunc_desc(functionList);
   if (nextFunc_desc == null) {
     if ("1".equals(level_desc)) {
       nextFunc_desc = "0A";
     } else if ("2".equals(level_desc)) {
       nextFunc_desc = functionFather.getFunc_desc() + "0A";
     } else if ("3".equals(level_desc)) {
       nextFunc_desc = functionFather.getFunc_desc() + "01";
     }
   }
   Function addFunction = new Function();
   addFunction.setId(0);
   addFunction.setFunc_desc(nextFunc_desc);
   addFunction.setLevel_desc(Integer.valueOf(level_desc));
   addFunction.setCh_desc(ch_desc);
   addFunction.setFather_node(fatherId);
   addFunction.setUrl(url);
   addFunction.setImg_url(img_url);
   addFunction.setIsCurrentWindow(Integer.valueOf(isCurrentWindow));
   addFunction.setWidth(width);
   addFunction.setHeight(height);
   addFunction.setClientX(clientX);
   addFunction.setClientY(clientY);
   boolean result = false;
   FunctionDao functionDao = null;
   try {
     functionDao = new FunctionDao();
     result = functionDao.save(addFunction);
   } catch (Exception e) {
     result = false;
     SysLogger.error("MenuManager.addUpdate()", e);
     e.printStackTrace();
   } finally {
     functionDao.close();
   }
   if (result) {
     return "/system/menu/saveok.jsp";
   } else {
     return "/system/menu/saveFail.jsp";
   }
 }
예제 #25
0
  private String editUpdate() {
    FunctionDao addFunctionDao = null;
    FunctionDao functionDao = null;
    boolean result = false;
    try {
      String id = request.getParameter("id");
      String level_desc = request.getParameter("level_desc");
      String ch_desc = request.getParameter("ch_desc");
      String fatherNode = request.getParameter("fatherNode");
      String url = request.getParameter("url");
      String img_url = request.getParameter("img_url");
      String isCurrentWindow = request.getParameter("isCurrentWindow");
      String width = request.getParameter("width");
      String height = request.getParameter("height");
      String clientX = request.getParameter("clientX");
      String clientY = request.getParameter("clientY");
      functionDao = new FunctionDao();
      Function function = (Function) functionDao.findByID(id);
      CreateRoleFunctionTable crft = new CreateRoleFunctionTable();
      List<Function> allFunctionChildList = crft.getAllFuctionChildByRoot(function, allFunction);
      if (Integer.valueOf(level_desc) != function.getLevel_desc()) {
        String[] idArray = new String[allFunctionChildList.size() + 1];
        idArray[allFunctionChildList.size()] = id;
        functionDao.delete(idArray);
      }
      if (level_desc.equals("1")) {
        fatherNode = "0";
      }
      Function functionFather = null;
      allFunction = functionDao.loadAll();
      List<Function> functionList = new ArrayList<Function>();
      for (int i = 0; i < allFunction.size(); i++) {
        if (allFunction.get(i).getId() == Integer.valueOf(fatherNode)) {
          functionFather = allFunction.get(i);
        }
        if (allFunction.get(i).getFather_node() == Integer.valueOf(fatherNode)) {
          functionList.add(allFunction.get(i));
        }
      }
      String nextFunc_desc = getNextFunc_desc(functionList);
      if (nextFunc_desc == null) {
        if ("1".equals(level_desc)) {
          nextFunc_desc = "0A";
        } else if ("2".equals(level_desc)) {
          nextFunc_desc = functionFather.getFunc_desc() + "0A";
        } else if ("3".equals(level_desc)) {
          nextFunc_desc = functionFather.getFunc_desc() + "01";
        }
      }
      Function editFunction = new Function();
      editFunction.setId(Integer.valueOf(id));
      editFunction.setFunc_desc(nextFunc_desc);
      editFunction.setLevel_desc(Integer.valueOf(level_desc));
      editFunction.setCh_desc(ch_desc);
      editFunction.setFather_node(Integer.valueOf(fatherNode));
      editFunction.setUrl(url);
      editFunction.setImg_url(img_url);
      editFunction.setIsCurrentWindow(Integer.valueOf(isCurrentWindow));
      editFunction.setWidth(width);
      editFunction.setHeight(height);
      editFunction.setClientX(clientX);
      editFunction.setClientY(clientY);

      addFunctionDao = new FunctionDao();
      addFunctionDao.update(editFunction);
      result = true;
    } catch (Exception e) {
      result = false;
      SysLogger.error("MenuManager.delete()", e);
      e.printStackTrace();
    } finally {
      functionDao.close();
      addFunctionDao.close();
    }
    if (result) {
      return "/system/menu/saveok.jsp";
    } else {
      return "/system/menu/saveFail.jsp";
    }
  }
  /** @author nielin modify at 2010-01-08 */
  public int writeXml(int flag) {
    int done = 0;
    // 需要做分布式判断
    String runmodel = PollingEngine.getCollectwebflag();
    try {
      I_HostLastCollectData hostlastmanager = new HostLastCollectDataManager();
      Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(ipaddress);

      Vector vector = new Vector();
      String[] netInterfaceItem = {
        "index",
        "ifDescr",
        "ifSpeed",
        "ifAdminStatus",
        "ifOperStatus",
        "OutBandwidthUtilHdx",
        "InBandwidthUtilHdx"
      };
      try {
        if ("0".equals(runmodel)) {
          // 采集与访问是集成模式
          vector = hostlastmanager.getInterface_share(ipaddress, netInterfaceItem, "index", "", "");
        } else {
          // 采集与访问是分离模式
          vector = hostlastmanager.getInterface(ipaddress, netInterfaceItem, "index", "", "");
        }
      } catch (Exception e) {
        e.printStackTrace();
        return done;
      }
      try {
        _fis =
            new FileInputStream(
                ResourceCenter.getInstance().getSysPath()
                    + "panel/model/"
                    + oid
                    + "_"
                    + imageType
                    + ".jsp");
      } catch (Exception e) {
        e.printStackTrace();
        _fis.close();
        return done;
      }
      _fis.skip(headBytes.getBytes().length);
      _builder = new SAXBuilder();
      _doc = _builder.build(_fis);
      _root = _doc.getRootElement();
      _nodes = _root.getChild("nodes");

      List list = _nodes.getChildren();

      PortconfigDao dao = new PortconfigDao();

      try {

        for (int i = 0; i < list.size(); i++) {
          Element eleNode = (Element) list.get(i);
          if (eleNode.getChildText("index") == null) break;
          int index = Integer.valueOf(eleNode.getChildText("index")).intValue();
          String x = eleNode.getChildText("x");
          String y = eleNode.getChildText("y");
          String img = eleNode.getChildText("img");
          String direction = eleNode.getChildText("direction");
          String ifname = "";
          String OutBandwidthUtilHdx = "0";
          String InBandwidthUtilHdx = "0";
          String portuse = "";
          if (vector != null && vector.size() > 0) {
            for (int m = 0; m < vector.size(); m++) {
              String[] strs = (String[]) vector.get(m);
              String _ifname = strs[1];
              String _index = strs[0];
              String opstatus = strs[4];
              OutBandwidthUtilHdx = strs[5];
              InBandwidthUtilHdx = strs[6];

              Portconfig portconfig = null;
              try {
                portconfig = dao.getPanelByipandindex(ipaddress, index + "");
              } catch (Exception e) {

              }
              if (portconfig != null
                  && portconfig.getLinkuse() != null
                  && portconfig.getLinkuse().trim().length() > 0) {
                portuse = portconfig.getLinkuse();
              }

              // SysLogger.info(ipaddress+"====ifOperStatus====="+strs[4]);
              if (Integer.parseInt(_index) == index) {
                ifname = _ifname;
                if ("down".equalsIgnoreCase(opstatus)) {
                  // DOWN
                  if ("1".equalsIgnoreCase(direction)) {
                    // 向上的端口
                    img = "image/up_down_gray.gif";
                  } else {
                    // 向下的端口
                    img = "image/down_down_gray.gif";
                  }
                } else {
                  // UP
                  if ("1".equalsIgnoreCase(direction)) {
                    // 向上的端口
                    img = "image/up_up_green.gif";
                  } else {
                    // 向下的端口
                    img = "image/down_up_green.gif";
                  }
                }
                break;
              }
            }
          }
          addNode(
              index + "",
              InBandwidthUtilHdx,
              OutBandwidthUtilHdx,
              img,
              ipaddress,
              ifname,
              portuse,
              x,
              y);
        }

      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        dao.close();
      }

      Format format = Format.getCompactFormat();
      format.setEncoding("GB2312");
      format.setIndent("	");
      serializer = new XMLOutputter(format);
      // SysLogger.info("path==="+fullPath);
      fos = new FileOutputStream(fullPath);
      fos.write(headBytes.getBytes());
      serializer.output(doc, fos);
      fos.close();
      done = 1;
    } catch (Exception e) {
      done = 0;
      e.printStackTrace();
      SysLogger.error("Error in XmlOperator.close()", e);
    }
    return done;
  }