private void ajaxUpdate_availability() {
    double avgpingcon = 0;
    DBVo vo = new DBVo();
    DBDao dao = new DBDao();
    String id = getParaValue("id");
    request.setAttribute("id", id);
    try {
      vo = (DBVo) dao.findByID(id);
    } catch (Exception e) {

    } finally {
      dao.close();
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String time1 = sdf.format(new Date());
    String newip = SysUtil.doip(vo.getIpAddress());

    String starttime1 = time1 + " 00:00:00";
    String totime1 = time1 + " 23:59:59";

    Hashtable ConnectUtilizationhash = new Hashtable();
    I_HostCollectData hostmanager = new HostCollectDataManager();
    try {
      ConnectUtilizationhash =
          hostmanager.getCategory(
              vo.getId() + "", "INFORMIXPing", "ConnectUtilization", starttime1, totime1);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    String pingconavg = "";
    if (ConnectUtilizationhash.get("avgpingcon") != null)
      pingconavg = (String) ConnectUtilizationhash.get("avgpingcon");
    if (pingconavg != null) {
      pingconavg = pingconavg.replace("%", "");
    }
    avgpingcon = new Double(pingconavg + "").doubleValue();
    int percent1 = Double.valueOf(avgpingcon).intValue();
    int percent2 = 100 - percent1;
    Map<String, Integer> map = new HashMap<String, Integer>();
    map.put("percent1", percent1);
    map.put("percent2", percent2);
    // System.out.println("percent1:"+percent1);
    // System.out.println("percent2:"+percent2);
    JSONObject json = JSONObject.fromObject(map);
    out.print(json);
    out.flush();
  }
Esempio n. 2
0
  private void ajaxUpdate_availability() {
    String buffercache = null;
    DBVo vo = new DBVo();
    DBDao dao = new DBDao();
    String id = getParaValue("id");
    try {
      vo = (DBVo) dao.findByID(id);
    } catch (Exception e) {

    } finally {
      dao.close();
    }
    String sid = getParaValue("sid");
    String pingconavg = "0";
    double avgpingcon = 0;
    Hashtable ConnectUtilizationhash = new Hashtable();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String time1 = sdf.format(new Date());

    String starttime1 = time1 + " 00:00:00";
    String totime1 = time1 + " 23:59:59";
    I_HostCollectData hostmanager = new HostCollectDataManager();
    try {
      ConnectUtilizationhash =
          hostmanager.getCategory(id, "ORAPing", "ConnectUtilization", starttime1, totime1);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    if (ConnectUtilizationhash.get("avgpingcon") != null)
      pingconavg = (String) ConnectUtilizationhash.get("avgpingcon");
    if (pingconavg != null) {
      pingconavg = pingconavg.replace("%", "");
    }
    avgpingcon = new Double(pingconavg + "").doubleValue();
    int percent1 = Double.valueOf(avgpingcon).intValue();
    int percent2 = 100 - percent1;
    Map<String, Integer> map = new HashMap<String, Integer>();
    map.put("percent1", percent1);
    map.put("percent2", percent2);
    Hashtable memPerfValue = new Hashtable();
    dao = new DBDao();
    String hex = IpTranslation.formIpToHex(vo.getIpAddress());
    String serverip = hex + ":" + sid;
    try {
      memPerfValue = dao.getOracle_nmsoramemperfvalue(serverip);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      dao.close();
    }
    int intbuffercache = 0;
    if (memPerfValue.containsKey("buffercache")) {
      buffercache = (String) memPerfValue.get("buffercache");
      intbuffercache = Integer.parseInt(buffercache);
    }
    if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) {
      buffercache = (String) memPerfValue.get("buffercache");
    }
    int intdictionarycache = 0;
    if (memPerfValue.containsKey("dictionarycache")
        && memPerfValue.get("dictionarycache") != null) {
      intdictionarycache = (int) (Float.parseFloat(buffercache));
    }
    String librarycache = "0";
    int intlibrarycache = 0;
    if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) {
      librarycache = (String) memPerfValue.get("librarycache");
      intlibrarycache = (int) (Float.parseFloat(librarycache));
    }
    String pctmemorysorts = "0";
    int intpctmemorysorts = 0;
    if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) {
      pctmemorysorts = (String) memPerfValue.get("pctmemorysorts");
      intpctmemorysorts = (int) (Float.parseFloat(pctmemorysorts));
    }
    String pctbufgets = "0";
    int intpctbufgets = 0;
    if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) {
      pctbufgets = (String) memPerfValue.get("pctbufgets");
      intpctbufgets = (int) (Float.parseFloat(pctbufgets));
    }
    map.put("pctbufgets", intpctbufgets);
    map.put("pctmemorysorts", intpctmemorysorts);
    map.put("librarycache", intlibrarycache);
    map.put("dictionarycache", intdictionarycache);
    map.put("buffercache", intbuffercache);
    map.put("cpuper", intbuffercache);
    JSONObject json = JSONObject.fromObject(map);
    out.print(json);
    out.flush();
  }