Example #1
0
  public Hashtable collect_Data(NodeGatherIndicators alarmIndicatorsNode) {
    Hashtable returnHash = new Hashtable();
    Vector processVector = new Vector();
    Host host =
        (Host)
            PollingEngine.getInstance()
                .getNodeByID(Integer.parseInt(alarmIndicatorsNode.getNodeid()));
    if (host == null) {
      return returnHash;
    }
    try {
      ProcessCollectEntity processdata = new ProcessCollectEntity();
      Calendar date = Calendar.getInstance();
      Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(host.getIpAddress());
      if (ipAllData == null) {
        ipAllData = new Hashtable();
      }
      try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        com.afunms.polling.base.Node snmpnode =
            PollingEngine.getInstance().getNodeByIP(host.getIpAddress());
        Date cc = date.getTime();
        String time = sdf.format(cc);
        snmpnode.setLastTime(time);
      } catch (Exception e) {
        e.printStackTrace();
      }
      try {

        String[] oids =
            new String[] {
              "1.3.6.1.2.1.25.4.2.1.1",
              "1.3.6.1.2.1.25.4.2.1.2",
              "1.3.6.1.2.1.25.4.2.1.5",
              "1.3.6.1.2.1.25.4.2.1.6",
              "1.3.6.1.2.1.25.4.2.1.7",
              "1.3.6.1.2.1.25.5.1.1.2",
              "1.3.6.1.2.1.25.5.1.1.1",
            };
        String[][] valueArray1 = null;
        try {
          valueArray1 =
              SnmpUtils.getTableData(
                  host.getIpAddress(),
                  host.getCommunity(),
                  oids,
                  host.getSnmpversion(),
                  host.getSecuritylevel(),
                  host.getSecurityName(),
                  host.getV3_ap(),
                  host.getAuthpassphrase(),
                  host.getV3_privacy(),
                  host.getPrivacyPassphrase(),
                  3,
                  1000 * 30);
        } catch (Exception e) {
          e.printStackTrace();
          valueArray1 = null;
        }
        int allMemorySize = 0;
        if (valueArray1 != null) {
          for (int i = 0; i < valueArray1.length; i++) {
            String svb0 = valueArray1[i][0];
            if (svb0 == null) {
              continue;
            }
            allMemorySize = Integer.parseInt(svb0);
          }
        }

        String[][] valueArray = null;
        try {
          valueArray = snmp.getTableData(host.getIpAddress(), host.getCommunity(), oids);
        } catch (Exception e) {
          e.printStackTrace();
          valueArray = null;
        }

        List procslist = new ArrayList();
        ProcsDao procsdao = new ProcsDao();
        try {
          procslist = procsdao.loadByIp(host.getIpAddress());
        } catch (Exception ex) {
          ex.printStackTrace();
        } finally {
          procsdao.close();
        }

        Hashtable procshash = new Hashtable();
        Vector procsV = new Vector();
        if (procslist != null && procslist.size() > 0) {
          for (int i = 0; i < procslist.size(); i++) {
            Procs procs = (Procs) procslist.get(i);
            procshash.put(procs.getProcname(), procs);
            procsV.add(procs.getProcname());
          }
        }
        if (valueArray != null) {
          for (int i = 0; i < valueArray.length; i++) {
            if (allMemorySize != 0) {
              String vbstring0 = valueArray[i][0];
              String vbstring1 = valueArray[i][1];
              String vbstring2 = valueArray[i][2];
              String vbstring3 = valueArray[i][3];
              String vbstring4 = valueArray[i][4];
              String vbstring5 = valueArray[i][5];
              String vbstring6 = valueArray[i][6];
              String processIndex = vbstring0.trim();

              float value = 0.0f;
              value = Integer.parseInt(vbstring5.trim()) * 100.0f / allMemorySize;

              String processName = vbstring1.trim();

              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("MemoryUtilization");
              processdata.setSubentity(processIndex);
              processdata.setRestype("dynamic");
              processdata.setUnit("%");
              processdata.setThevalue(Float.toString(value));
              processdata.setChname(processName);
              processVector.addElement(processdata);

              String processMemory = vbstring5.trim();
              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("Memory");
              processdata.setSubentity(processIndex);
              processdata.setRestype("static");
              processdata.setUnit("K");
              processdata.setThevalue(processMemory);
              processdata.setChname(processName);
              processVector.addElement(processdata);

              String processType = vbstring3.trim();
              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("Type");
              processdata.setSubentity(processIndex);
              processdata.setRestype("static");
              processdata.setUnit(" ");
              processdata.setThevalue(HOST_hrSWRun_hrSWRunType.get(processType).toString());
              processdata.setChname(processName);
              processVector.addElement(processdata);

              String processPath = vbstring2.trim();
              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("Path");
              processdata.setSubentity(processIndex);
              processdata.setRestype("static");
              processdata.setUnit(" ");
              processdata.setThevalue(processPath);
              processdata.setChname(processName);
              processVector.addElement(processdata);

              String processStatus = vbstring4.trim();
              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("Status");
              processdata.setSubentity(processIndex);
              processdata.setRestype("static");
              processdata.setUnit(" ");
              processdata.setThevalue(HOST_hrSWRun_hrSWRunStatus.get(processStatus).toString());
              processdata.setChname(processName);
              processVector.addElement(processdata);

              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("Name");
              processdata.setSubentity(processIndex);
              processdata.setRestype("static");
              processdata.setUnit(" ");
              processdata.setThevalue(processName);
              processVector.addElement(processdata);

              String processCpu = vbstring6.trim();
              processdata = new ProcessCollectEntity();
              processdata.setIpaddress(host.getIpAddress());
              processdata.setCollecttime(date);
              processdata.setCategory("Process");
              processdata.setEntity("CpuTime");
              processdata.setSubentity(processIndex);
              processdata.setRestype("static");
              processdata.setUnit("秒");
              processdata.setThevalue(Integer.toString((Integer.parseInt(processCpu) / 100)));
              processdata.setChname(processName);
              processVector.addElement(processdata);

              // 判断是否有需要监视的进程,若取得的列表里包含监视进程,则从Vector里去掉
              if (procsV != null && procsV.size() > 0) {
                if (procsV.contains(processName)) {
                  procsV.remove(processName);
                  // 判断已经发送的进程短信列表里是否有该进程,若有,则从已发送列表里去掉该短信信息
                  if (sendeddata.containsKey(host + ":" + processName)) {
                    sendeddata.remove(host + ":" + processName);
                  }
                  // 判断进程丢失列表里是否有该进程,若有,则从该列表里去掉该信息
                  Hashtable iplostprocdata = ShareData.getLostprocdata(host.getIpAddress());
                  if (iplostprocdata == null) {
                    iplostprocdata = new Hashtable();
                  }
                  if (iplostprocdata.containsKey(processName)) {
                    iplostprocdata.remove(processName);
                    ShareData.setLostprocdata(host.getIpAddress(), iplostprocdata);
                  }
                }
              }
            } else {
              throw new Exception("Process is 0");
            }
          }
        }

        // 判断ProcsV里还有没有需要监视的进程,若有,则说明当前没有启动该进程,则用命令重新启动该进程,同时写入事件
        Vector eventtmpV = new Vector();
        if (procsV != null && procsV.size() > 0) {
          for (int i = 0; i < procsV.size(); i++) {
            Procs procs = (Procs) procshash.get(procsV.get(i));

            Hashtable iplostprocdata = ShareData.getLostprocdata(host.getIpAddress());
            if (iplostprocdata == null) {
              iplostprocdata = new Hashtable();
            }
            iplostprocdata.put(procs.getProcname(), procs);
            ShareData.setLostprocdata(host.getIpAddress(), iplostprocdata);
            EventList eventlist = new EventList();
            eventlist.setEventtype("poll");
            eventlist.setEventlocation(host.getSysLocation());
            eventlist.setContent(procs.getProcname() + "进程丢失");
            eventlist.setLevel1(1);
            eventlist.setManagesign(0);
            eventlist.setBak("");
            eventlist.setRecordtime(Calendar.getInstance());
            eventlist.setReportman("系统轮询");
            eventlist.setEventlocation(host.getAlias() + "(" + host.getIpAddress() + ")");
            NodeToBusinessDao ntbdao = new NodeToBusinessDao();
            List ntblist = new ArrayList();
            try {
              ntblist = ntbdao.loadByNodeAndEtype(host.getId(), "equipment");
            } catch (Exception e) {
              e.printStackTrace();
            } finally {
              ntbdao.close();
            }
            String bids = ",";
            if (ntblist != null && ntblist.size() > 0) {

              for (int k = 0; k < ntblist.size(); k++) {
                NodeToBusiness ntb = (NodeToBusiness) ntblist.get(k);
                bids = bids + ntb.getBusinessid() + ",";
              }
            }
            eventlist.setBusinessid(bids);
            eventlist.setNodeid(host.getId());
            eventlist.setOid(0);
            eventlist.setSubtype("host");
            eventlist.setSubentity("proc");
            EventListDao eventlistdao = new EventListDao();
            eventlistdao.save(eventlist);
            eventtmpV.add(eventlist);
            // 发送手机短信并写事件和声音告警
          }
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (!(ShareData.getSharedata().containsKey(host.getIpAddress()))) {
      Hashtable ipAllData = new Hashtable();
      if (ipAllData == null) {
        ipAllData = new Hashtable();
      }
      if (processVector != null && processVector.size() > 0) {
        ipAllData.put("process", processVector);
      }
      ShareData.getSharedata().put(host.getIpAddress(), ipAllData);
    } else {
      if (processVector != null && processVector.size() > 0) {
        ((Hashtable) ShareData.getSharedata().get(host.getIpAddress()))
            .put("process", processVector);
      }
    }
    returnHash.put("process", processVector);
    processVector = null;
    List proEventList = new ArrayList();
    boolean alarm = false;
    try {
      if (processVector != null && processVector.size() > 0) {
        AlarmIndicatorsUtil alarmIndicatorsUtil = new AlarmIndicatorsUtil();
        List list =
            alarmIndicatorsUtil.getAlarmInicatorsThresholdForNode(
                host.getId() + "", "host", "windows");
        AlarmIndicatorsNode alarmIndicatorsNode2 = null;
        if (list == null) {
          for (int i = 0; i < list.size(); i++) {
            AlarmIndicatorsNode alarmIndicatorsNode2_per = (AlarmIndicatorsNode) list.get(i);
            if (alarmIndicatorsNode2_per != null
                && "process".equals(alarmIndicatorsNode2_per.getName())) {
              alarmIndicatorsNode2 = alarmIndicatorsNode2_per;
              break;
            }
          }
          CheckEventUtil checkutil = new CheckEventUtil();
          proEventList =
              checkutil.createProcessGroupEventList(
                  host.getIpAddress(), processVector, alarmIndicatorsNode2);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (proEventList != null && proEventList.size() > 0) {
      alarm = true;
    }
    if (alarm) {
      Host node = (Host) PollingEngine.getInstance().getNodeByID(host.getId());
      StringBuffer msg = new StringBuffer(200);
      msg.append("<font color='red'>--报警信息:--</font><br>");
      msg.append(node.getAlarmMessage().toString());
      if (proEventList != null && proEventList.size() > 0) {
        for (int i = 0; i < proEventList.size(); i++) {
          EventList eventList = (EventList) proEventList.get(i);
          msg.append(eventList.getContent() + "<br>");
          if (eventList.getLevel1() > node.getAlarmlevel()) {
            node.setAlarmlevel(eventList.getLevel1());
          }
        }
      }
      node.getAlarmMessage().clear();
      node.getAlarmMessage().add(msg.toString());
      node.setStatus(node.getAlarmlevel());
      node.setAlarm(true);
    }
    String runmodel = PollingEngine.getCollectwebflag(); // 采集与访问模式
    if (!"0".equals(runmodel)) {
      HostDatatempProcessRtTosql temptosql = new HostDatatempProcessRtTosql();
      temptosql.CreateResultTosql(returnHash, host);
    }

    return returnHash;
  }
Example #2
0
  public boolean update(BaseVo vo) {
    boolean flag = true;
    WasConfig vo1 = (WasConfig) vo;
    WasConfig pvo = (WasConfig) findByID(vo1.getId() + "");
    StringBuffer sql = new StringBuffer();
    sql.append("update nms_wasconfig set name='");
    sql.append(vo1.getName());
    sql.append("',ipaddress='");
    sql.append(vo1.getIpaddress());
    sql.append("',portnum='");
    sql.append(vo1.getPortnum());
    sql.append("',nodename='");
    sql.append(vo1.getNodename());
    sql.append("',servername='");
    sql.append(vo1.getServername());
    sql.append("',sendmobiles='");
    sql.append(vo1.getSendmobiles());
    sql.append("',mon_flag='");
    sql.append(vo1.getMon_flag());
    sql.append("',netid='");
    sql.append(vo1.getNetid());
    sql.append("',sendemail='");
    sql.append(vo1.getSendemail());
    sql.append("',supperid='");
    sql.append(vo1.getSupperid());
    sql.append("',version='");
    sql.append(vo1.getVersion());
    sql.append("' where id=" + vo1.getId());
    try {
      conn = new DBManager();
      saveOrUpdate(sql.toString());
      if (!vo1.getIpaddress().equals(pvo.getIpaddress())) {
        String ipstr = pvo.getIpaddress();
        String allipstr = SysUtil.doip(ipstr);

        CreateTableManager ctable = new CreateTableManager();

        // conn = new DBManager();
        ctable.deleteTable("wasping", allipstr, "wasping"); // Ping
        ctable.deleteTable("waspinghour", allipstr, "waspinghour"); // Ping
        ctable.deleteTable("waspingday", allipstr, "waspingday"); // Ping

        // 自服务器启动以来的CPU平均使用率
        ctable.deleteTable("wasrcpu", allipstr, "wasrcpu"); // Ping
        ctable.deleteTable("wasrcpuhour", allipstr, "wasrcpuhour"); // Ping
        ctable.deleteTable("wasrcpuday", allipstr, "wasrcpuday"); // Ping

        // 自上次查询以来的平均CPU使用率
        ctable.deleteTable("wasscpu", allipstr, "wasscpu"); // Ping
        ctable.deleteTable("wasscpuhour", allipstr, "wasscpuhour"); // Ping
        ctable.deleteTable("wasscpuday", allipstr, "wasscpuday"); // Ping

        // 缓存命中率
        ctable.deleteTable("wasrate", allipstr, "wasrate"); // Ping
        ctable.deleteTable("wasratehour", allipstr, "wasratehour"); // Ping
        ctable.deleteTable("wasrateday", allipstr, "wasrateday"); // Ping

        // JVM内存利用率
        ctable.deleteTable("wasjvm", allipstr, "wasjvm");
        ctable.deleteTable("wasjvmhour", allipstr, "wasjvmhour");
        ctable.deleteTable("wasjvmday", allipstr, "wasjvmday");

        // 性能表
        ctable.deleteTable("wassystem", allipstr, "wassystem");
        ctable.deleteTable("wassystemhour", allipstr, "wassystemhour");
        ctable.deleteTable("wassystemday", allipstr, "wassystemday");

        ctable.deleteTable("wasjdbc", allipstr, "wasjdbc");
        ctable.deleteTable("wasjdbchour", allipstr, "wasjdbchour");
        ctable.deleteTable("wasjdbcday", allipstr, "wasjdbcday");

        ctable.deleteTable("wassession", allipstr, "wassession");
        ctable.deleteTable("wassessionh", allipstr, "wassessionh"); // wassessionhour
        // 必须保留session字段
        ctable.deleteTable("wassessiond", allipstr, "wassessiond");

        ctable.deleteTable("wasjvminfo", allipstr, "wasjvminfo");
        ctable.deleteTable("wasjvminfoh", allipstr, "wasjvminfoh"); // wasjvminfohour
        // 必须保留jvminfo字段,详情见函数内部
        ctable.deleteTable("wasjvminfod", allipstr, "wasjvminfod"); // wasjvminfoday

        ctable.deleteTable("wascache", allipstr, "wascache");
        ctable.deleteTable("wascachehour", allipstr, "wascachehour");
        ctable.deleteTable("wascacheday", allipstr, "wascacheday");

        ctable.deleteTable("wasthread", allipstr, "wasthread");
        ctable.deleteTable("wasthreadhour", allipstr, "wasthreadhour");
        ctable.deleteTable("wasthreadday", allipstr, "wasthreadday");

        ctable.deleteTable("wastrans", allipstr, "wastrans");
        ctable.deleteTable("wastranshour", allipstr, "wastranshour");
        ctable.deleteTable("wastransday", allipstr, "wastransday");

        try {
          // 同时删除事件表里的相关数据
          EventListDao eventdao = new EventListDao();
          eventdao.delete(vo1.getId(), "wasserver");
        } catch (Exception e) {
          e.printStackTrace();
        }

        // 测试生成表
        String ip = vo1.getIpaddress();
        allipstr = SysUtil.doip(ip);
        ctable = new CreateTableManager();
        // 可用性
        ctable.createTable("wasping", allipstr, "wasping"); // Ping
        ctable.createTable("waspinghour", allipstr, "waspinghour"); // Ping
        ctable.createTable("waspingday", allipstr, "waspingday"); // Ping

        // 自服务器启动以来的CPU平均使用率
        ctable.createTable("wasrcpu", allipstr, "wasrcpu"); // Ping
        ctable.createTable("wasrcpuhour", allipstr, "wasrcpuhour"); // Ping
        ctable.createTable("wasrcpuday", allipstr, "wasrcpuday"); // Ping

        // 自上次查询以来的平均CPU使用率
        ctable.createTable("wasscpu", allipstr, "wasscpu"); // Ping
        ctable.createTable("wasscpuhour", allipstr, "wasscpuhour"); // Ping
        ctable.createTable("wasscpuday", allipstr, "wasscpuday"); // Ping

        // 缓存命中率
        ctable.createTable("wasrate", allipstr, "wasrate"); // Ping
        ctable.createTable("wasratehour", allipstr, "wasratehour"); // Ping
        ctable.createTable("wasrateday", allipstr, "wasrateday"); // Ping

        // JVM内存利用率
        ctable.createTable("wasjvm", allipstr, "wasjvm");
        ctable.createTable("wasjvmhour", allipstr, "wasjvmhour");
        ctable.createTable("wasjvmday", allipstr, "wasjvmday");

        // 建立性能表
        ctable.createWasTable(conn, "wassystem", allipstr);
        ctable.createWasTable(conn, "wassystemhour", allipstr);
        ctable.createWasTable(conn, "wassystemday", allipstr);

        ctable.createWasTable(conn, "wasjdbc", allipstr);
        ctable.createWasTable(conn, "wasjdbchour", allipstr);
        ctable.createWasTable(conn, "wasjdbcday", allipstr);

        ctable.createWasTable(conn, "wassession", allipstr);
        ctable.createWasTable(conn, "wassessionh", allipstr); // wassessionhour
        ctable.createWasTable(conn, "wassessiond", allipstr);

        ctable.createWasTable(conn, "wasjvminfo", allipstr);
        ctable.createWasTable(conn, "wasjvminfoh", allipstr); // wasjvminfohour
        ctable.createWasTable(conn, "wasjvminfod", allipstr); // wasjvminfoday

        ctable.createWasTable(conn, "wascache", allipstr);
        ctable.createWasTable(conn, "wascachehour", allipstr);
        ctable.createWasTable(conn, "wascacheday", allipstr);

        ctable.createWasTable(conn, "wasthread", allipstr);
        ctable.createWasTable(conn, "wasthreadhour", allipstr);
        ctable.createWasTable(conn, "wasthreadday", allipstr);

        ctable.createWasTable(conn, "wastrans", allipstr);
        ctable.createWasTable(conn, "wastranshour", allipstr);
        ctable.createWasTable(conn, "wastransday", allipstr);
      }

    } catch (Exception e) {
      flag = false;
      e.printStackTrace();
    } finally {
      conn.close();
    }
    return flag;
  }
Example #3
0
  public boolean delete(String id) {
    boolean result = false;
    try {
      WasConfig pvo = (WasConfig) findByID(id + "");
      String ipstr = pvo.getIpaddress();
      String allipstr = SysUtil.doip(ipstr);

      CreateTableManager ctable = new CreateTableManager();
      ctable.deleteTable("wasping", allipstr, "wasping"); // Ping
      ctable.deleteTable("waspinghour", allipstr, "waspinghour"); // Ping
      ctable.deleteTable("waspingday", allipstr, "waspingday"); // Ping

      // 自服务器启动以来的CPU平均使用率
      ctable.deleteTable("wasrcpu", allipstr, "wasrcpu"); // Ping
      ctable.deleteTable("wasrcpuhour", allipstr, "wasrcpuhour"); // Ping
      ctable.deleteTable("wasrcpuday", allipstr, "wasrcpuday"); // Ping

      // 自上次查询以来的平均CPU使用率
      ctable.deleteTable("wasscpu", allipstr, "wasscpu"); // Ping
      ctable.deleteTable("wasscpuhour", allipstr, "wasscpuhour"); // Ping
      ctable.deleteTable("wasscpuday", allipstr, "wasscpuday"); // Ping

      // 缓存命中率
      ctable.deleteTable("wasrate", allipstr, "wasrate"); // Ping
      ctable.deleteTable("wasratehour", allipstr, "wasratehour"); // Ping
      ctable.deleteTable("wasrateday", allipstr, "wasrateday"); // Ping

      // JVM内存利用率
      ctable.deleteTable("wasjvm", allipstr, "wasjvm");
      ctable.deleteTable("wasjvmhour", allipstr, "wasjvmhour");
      ctable.deleteTable("wasjvmday", allipstr, "wasjvmday");

      // 性能表
      ctable.deleteTable("wassystem", allipstr, "wassystem");
      ctable.deleteTable("wassystemhour", allipstr, "wassystemhour");
      ctable.deleteTable("wassystemday", allipstr, "wassystemday");

      ctable.deleteTable("wasjdbc", allipstr, "wasjdbc");
      ctable.deleteTable("wasjdbchour", allipstr, "wasjdbchour");
      ctable.deleteTable("wasjdbcday", allipstr, "wasjdbcday");

      ctable.deleteTable("wassession", allipstr, "wassession");
      ctable.deleteTable("wassessionh", allipstr, "wassessionh"); // wassessionhour
      // 必须保留session字段
      ctable.deleteTable("wassessiond", allipstr, "wassessiond"); // wassessionday

      ctable.deleteTable("wasjvminfo", allipstr, "wasjvminfo");
      ctable.deleteTable("wasjvminfoh", allipstr, "wasjvmhour"); // wasjvminfohour
      // 必须保留jvminfo字段
      ctable.deleteTable("wasjvminfod", allipstr, "wasjvmday"); // wasjvminfoday

      ctable.deleteTable("wascache", allipstr, "wascache");
      ctable.deleteTable("wascachehour", allipstr, "wascachehour");
      ctable.deleteTable("wascacheday", allipstr, "wascacheday");

      ctable.deleteTable("wasthread", allipstr, "wasthread");
      ctable.deleteTable("wasthreadhour", allipstr, "wasthreadhour");
      ctable.deleteTable("wasthreadday", allipstr, "wasthreadday");

      ctable.deleteTable("wastrans", allipstr, "wastrans");
      ctable.deleteTable("wastranshour", allipstr, "wastranshour");
      ctable.deleteTable("wastransday", allipstr, "wastransday");

      conn.addBatch("delete from nms_wasconfig where id=" + id);
      conn.executeBatch();
      result = true;
      try {
        // 同时删除事件表里的相关数据
        EventListDao eventdao = new EventListDao();
        eventdao.delete(Integer.parseInt(id), "wasserver");
      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      conn.close();
    }

    return result;
  }
  /**
   * 根据 psTypeVo 来组装 中间件
   *
   * @param psTypeVo
   * @return
   */
  public MonitorServiceDTO getMonitorServiceDTOByPSTypeVo(PSTypeVo psTypeVo) {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = simpleDateFormat.format(new Date());

    String starttime = date + " 00:00:00";
    String totime = date + " 23:59:59";

    int id = psTypeVo.getId();
    String alias = psTypeVo.getPort();
    String ipAddress = psTypeVo.getIpaddress();
    String category = "portService";

    Node psTypeVoNode = PollingEngine.getInstance().getSocketByID(id);

    int status = 0;
    try {
      status = psTypeVoNode.getStatus();
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Hashtable eventListSummary = new Hashtable();

    String generalAlarm = "0"; // 普通告警数  默认为 0
    String urgentAlarm = "0"; // 严重告警数  默认为 0
    String seriousAlarm = "0"; // 紧急告警数  默认为 0

    EventListDao eventListDao = new EventListDao();
    try {
      generalAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='1' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
      urgentAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='2' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
      seriousAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='3' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      eventListDao.close();
    }
    eventListSummary.put("generalAlarm", generalAlarm);
    eventListSummary.put("urgentAlarm", urgentAlarm);
    eventListSummary.put("seriousAlarm", seriousAlarm);

    String monflag = "否";
    if (psTypeVo.getMonflag() == 1) {
      monflag = "是";
    }

    MonitorServiceDTO monitorServiceDTO = new MonitorServiceDTO();
    monitorServiceDTO.setId(id);
    monitorServiceDTO.setStatus(String.valueOf(status));
    monitorServiceDTO.setAlias(alias);
    monitorServiceDTO.setIpAddress(ipAddress);
    monitorServiceDTO.setPingValue("");
    monitorServiceDTO.setCategory(category);
    monitorServiceDTO.setEventListSummary(eventListSummary);
    monitorServiceDTO.setMonflag(monflag);
    return monitorServiceDTO;
  }