@Test public void testQueryServerGroupByName() { ServerGroupDO serverGroupDO=serverGroupDao.queryServerGroupByName("group_zsearch-solr-engine"); System.err.println(zabbixHistoryServiceImpl.queryHistory(serverGroupDO)); }
@Override public List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO) { List result = new ArrayList<>(); List<ServerDO> listServerDO = serverDao.acqServersByGroupId(serverGroupDO.getId()); if (listServerDO == null || listServerDO.size() == 0) { return result; } for (ServerDO serverDO : listServerDO) { if (!zabbixService.hostExists(serverDO)) continue; if(zabbixService.hostGetStatus(serverDO) == ZabbixServiceImpl.hostStatusDisable) continue; Map<String, Object> server = new HashMap<>(); server.put("serverId", serverDO.getId()); server.put("serverName", serverDO.getServerName()); server.put("evnType", serverDO.getEnvType()); server.put("serialNumber", serverDO.getSerialNumber()); Map<String, Object> history = new HashMap<>(); Float cpuUser = Float.valueOf(acqResultValue(queryCpuUser(serverDO, 1))); BigDecimal bigDecimalCpuUser = new BigDecimal(cpuUser); cpuUser = bigDecimalCpuUser.setScale(3, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuUser", cpuUser); Float cpuLoad = Float.valueOf(acqResultValue(queryPerCpuAvg1(serverDO, 1))); BigDecimal bigDecimalCpuLoad = new BigDecimal(cpuLoad); cpuLoad = bigDecimalCpuLoad.setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuLoad", cpuLoad); Long longMemoryAvailable = Long.valueOf(acqResultValue(queryMemoryAvailable(serverDO, 1))); Float memoryAvailable = (float) longMemoryAvailable / 1073741824; BigDecimal bigDecimalMemoryAvailable = new BigDecimal(memoryAvailable); memoryAvailable = bigDecimalMemoryAvailable.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryAvailable", memoryAvailable); Long longMemoryTotal = Long.valueOf(acqResultValue(queryMemoryTotal(serverDO, 1))); Float memoryTotal = (float) longMemoryTotal / 1073741824; BigDecimal bigDecimalMemoryTotal = new BigDecimal(memoryTotal); memoryTotal = bigDecimalMemoryTotal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryTotal", memoryTotal); server.put("history", history); result.add(server); } return result; }
ZabbixHistoryServiceImpl implements ZabbixHistoryService { @Override public List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO) { List result = new ArrayList<>(); List<ServerDO> listServerDO = serverDao.acqServersByGroupId(serverGroupDO.getId()); if (listServerDO == null || listServerDO.size() == 0) { return result; } for (ServerDO serverDO : listServerDO) { if (!zabbixService.hostExists(serverDO)) continue; if(zabbixService.hostGetStatus(serverDO) == ZabbixServiceImpl.hostStatusDisable) continue; Map<String, Object> server = new HashMap<>(); server.put("serverId", serverDO.getId()); server.put("serverName", serverDO.getServerName()); server.put("evnType", serverDO.getEnvType()); server.put("serialNumber", serverDO.getSerialNumber()); Map<String, Object> history = new HashMap<>(); Float cpuUser = Float.valueOf(acqResultValue(queryCpuUser(serverDO, 1))); BigDecimal bigDecimalCpuUser = new BigDecimal(cpuUser); cpuUser = bigDecimalCpuUser.setScale(3, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuUser", cpuUser); Float cpuLoad = Float.valueOf(acqResultValue(queryPerCpuAvg1(serverDO, 1))); BigDecimal bigDecimalCpuLoad = new BigDecimal(cpuLoad); cpuLoad = bigDecimalCpuLoad.setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuLoad", cpuLoad); Long longMemoryAvailable = Long.valueOf(acqResultValue(queryMemoryAvailable(serverDO, 1))); Float memoryAvailable = (float) longMemoryAvailable / 1073741824; BigDecimal bigDecimalMemoryAvailable = new BigDecimal(memoryAvailable); memoryAvailable = bigDecimalMemoryAvailable.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryAvailable", memoryAvailable); Long longMemoryTotal = Long.valueOf(acqResultValue(queryMemoryTotal(serverDO, 1))); Float memoryTotal = (float) longMemoryTotal / 1073741824; BigDecimal bigDecimalMemoryTotal = new BigDecimal(memoryTotal); memoryTotal = bigDecimalMemoryTotal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryTotal", memoryTotal); server.put("history", history); result.add(server); } return result; } }
ZabbixHistoryServiceImpl implements ZabbixHistoryService { @Override public List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO) { List result = new ArrayList<>(); List<ServerDO> listServerDO = serverDao.acqServersByGroupId(serverGroupDO.getId()); if (listServerDO == null || listServerDO.size() == 0) { return result; } for (ServerDO serverDO : listServerDO) { if (!zabbixService.hostExists(serverDO)) continue; if(zabbixService.hostGetStatus(serverDO) == ZabbixServiceImpl.hostStatusDisable) continue; Map<String, Object> server = new HashMap<>(); server.put("serverId", serverDO.getId()); server.put("serverName", serverDO.getServerName()); server.put("evnType", serverDO.getEnvType()); server.put("serialNumber", serverDO.getSerialNumber()); Map<String, Object> history = new HashMap<>(); Float cpuUser = Float.valueOf(acqResultValue(queryCpuUser(serverDO, 1))); BigDecimal bigDecimalCpuUser = new BigDecimal(cpuUser); cpuUser = bigDecimalCpuUser.setScale(3, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuUser", cpuUser); Float cpuLoad = Float.valueOf(acqResultValue(queryPerCpuAvg1(serverDO, 1))); BigDecimal bigDecimalCpuLoad = new BigDecimal(cpuLoad); cpuLoad = bigDecimalCpuLoad.setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuLoad", cpuLoad); Long longMemoryAvailable = Long.valueOf(acqResultValue(queryMemoryAvailable(serverDO, 1))); Float memoryAvailable = (float) longMemoryAvailable / 1073741824; BigDecimal bigDecimalMemoryAvailable = new BigDecimal(memoryAvailable); memoryAvailable = bigDecimalMemoryAvailable.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryAvailable", memoryAvailable); Long longMemoryTotal = Long.valueOf(acqResultValue(queryMemoryTotal(serverDO, 1))); Float memoryTotal = (float) longMemoryTotal / 1073741824; BigDecimal bigDecimalMemoryTotal = new BigDecimal(memoryTotal); memoryTotal = bigDecimalMemoryTotal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryTotal", memoryTotal); server.put("history", history); result.add(server); } return result; }  }
ZabbixHistoryServiceImpl implements ZabbixHistoryService { @Override public List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO) { List result = new ArrayList<>(); List<ServerDO> listServerDO = serverDao.acqServersByGroupId(serverGroupDO.getId()); if (listServerDO == null || listServerDO.size() == 0) { return result; } for (ServerDO serverDO : listServerDO) { if (!zabbixService.hostExists(serverDO)) continue; if(zabbixService.hostGetStatus(serverDO) == ZabbixServiceImpl.hostStatusDisable) continue; Map<String, Object> server = new HashMap<>(); server.put("serverId", serverDO.getId()); server.put("serverName", serverDO.getServerName()); server.put("evnType", serverDO.getEnvType()); server.put("serialNumber", serverDO.getSerialNumber()); Map<String, Object> history = new HashMap<>(); Float cpuUser = Float.valueOf(acqResultValue(queryCpuUser(serverDO, 1))); BigDecimal bigDecimalCpuUser = new BigDecimal(cpuUser); cpuUser = bigDecimalCpuUser.setScale(3, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuUser", cpuUser); Float cpuLoad = Float.valueOf(acqResultValue(queryPerCpuAvg1(serverDO, 1))); BigDecimal bigDecimalCpuLoad = new BigDecimal(cpuLoad); cpuLoad = bigDecimalCpuLoad.setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuLoad", cpuLoad); Long longMemoryAvailable = Long.valueOf(acqResultValue(queryMemoryAvailable(serverDO, 1))); Float memoryAvailable = (float) longMemoryAvailable / 1073741824; BigDecimal bigDecimalMemoryAvailable = new BigDecimal(memoryAvailable); memoryAvailable = bigDecimalMemoryAvailable.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryAvailable", memoryAvailable); Long longMemoryTotal = Long.valueOf(acqResultValue(queryMemoryTotal(serverDO, 1))); Float memoryTotal = (float) longMemoryTotal / 1073741824; BigDecimal bigDecimalMemoryTotal = new BigDecimal(memoryTotal); memoryTotal = bigDecimalMemoryTotal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryTotal", memoryTotal); server.put("history", history); result.add(server); } return result; }  @Override String acqResultValue(JSONObject response); @Override JSONObject queryCpuUser(ServerDO serverDO, int limit); @Override JSONObject queryCpuIowait(ServerDO serverDO, int limit); @Override JSONObject queryPerCpuAvg1(ServerDO serverDO, int limit); @Override JSONObject queryPerCpuAvg5(ServerDO serverDO, int limit); @Override JSONObject queryPerCpuAvg15(ServerDO serverDO, int limit); @Override JSONObject queryMemoryTotal(ServerDO serverDO, int limit); @Override JSONObject queryMemoryAvailable(ServerDO serverDO, int limit); @Override JSONObject queryFreeDiskSpaceOnSys(ServerDO serverDO, int limit); @Override JSONObject queryFreeDiskSpaceOnData(ServerDO serverDO, int limit); JSONObject queryTotalDiskSpaceOnData(ServerDO serverDO, int limit); JSONObject queryUsedDiskSpaceOnData(ServerDO serverDO, int limit); @Override JSONObject queryDiskReadBps(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskWriteBps(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskReadIops(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskWriteIops(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskReadMs(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskWriteMs(ServerDO serverDO, String volume, int limit); @Override List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO); @Override HashMap<Long, HashMap<Integer, String>> queryZabbixMoniter(ServerGroupDO serverGroupDO); }
ZabbixHistoryServiceImpl implements ZabbixHistoryService { @Override public List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO) { List result = new ArrayList<>(); List<ServerDO> listServerDO = serverDao.acqServersByGroupId(serverGroupDO.getId()); if (listServerDO == null || listServerDO.size() == 0) { return result; } for (ServerDO serverDO : listServerDO) { if (!zabbixService.hostExists(serverDO)) continue; if(zabbixService.hostGetStatus(serverDO) == ZabbixServiceImpl.hostStatusDisable) continue; Map<String, Object> server = new HashMap<>(); server.put("serverId", serverDO.getId()); server.put("serverName", serverDO.getServerName()); server.put("evnType", serverDO.getEnvType()); server.put("serialNumber", serverDO.getSerialNumber()); Map<String, Object> history = new HashMap<>(); Float cpuUser = Float.valueOf(acqResultValue(queryCpuUser(serverDO, 1))); BigDecimal bigDecimalCpuUser = new BigDecimal(cpuUser); cpuUser = bigDecimalCpuUser.setScale(3, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuUser", cpuUser); Float cpuLoad = Float.valueOf(acqResultValue(queryPerCpuAvg1(serverDO, 1))); BigDecimal bigDecimalCpuLoad = new BigDecimal(cpuLoad); cpuLoad = bigDecimalCpuLoad.setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("cpuLoad", cpuLoad); Long longMemoryAvailable = Long.valueOf(acqResultValue(queryMemoryAvailable(serverDO, 1))); Float memoryAvailable = (float) longMemoryAvailable / 1073741824; BigDecimal bigDecimalMemoryAvailable = new BigDecimal(memoryAvailable); memoryAvailable = bigDecimalMemoryAvailable.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryAvailable", memoryAvailable); Long longMemoryTotal = Long.valueOf(acqResultValue(queryMemoryTotal(serverDO, 1))); Float memoryTotal = (float) longMemoryTotal / 1073741824; BigDecimal bigDecimalMemoryTotal = new BigDecimal(memoryTotal); memoryTotal = bigDecimalMemoryTotal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); history.put("memoryTotal", memoryTotal); server.put("history", history); result.add(server); } return result; }  @Override String acqResultValue(JSONObject response); @Override JSONObject queryCpuUser(ServerDO serverDO, int limit); @Override JSONObject queryCpuIowait(ServerDO serverDO, int limit); @Override JSONObject queryPerCpuAvg1(ServerDO serverDO, int limit); @Override JSONObject queryPerCpuAvg5(ServerDO serverDO, int limit); @Override JSONObject queryPerCpuAvg15(ServerDO serverDO, int limit); @Override JSONObject queryMemoryTotal(ServerDO serverDO, int limit); @Override JSONObject queryMemoryAvailable(ServerDO serverDO, int limit); @Override JSONObject queryFreeDiskSpaceOnSys(ServerDO serverDO, int limit); @Override JSONObject queryFreeDiskSpaceOnData(ServerDO serverDO, int limit); JSONObject queryTotalDiskSpaceOnData(ServerDO serverDO, int limit); JSONObject queryUsedDiskSpaceOnData(ServerDO serverDO, int limit); @Override JSONObject queryDiskReadBps(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskWriteBps(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskReadIops(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskWriteIops(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskReadMs(ServerDO serverDO, String volume, int limit); @Override JSONObject queryDiskWriteMs(ServerDO serverDO, String volume, int limit); @Override List<Map<String, Object>> queryHistory(ServerGroupDO serverGroupDO); @Override HashMap<Long, HashMap<Integer, String>> queryZabbixMoniter(ServerGroupDO serverGroupDO); final int zabbix_result_array; final int zabbix_result_object; static final int historyTypeNumericFloat; static final int historyTypeCharacter; static final int historyTypeLog; static final int historyTypeNumericUnsigned; static final int historyTypeText; }