@Test public void testGetNodeUptimeInfoFunction() { assertEquals(HashMap.class, provider.getNodeUpTimeInfo().getClass()); assert(provider.getNodeUpTimeInfo() != null); }
public Map<Object, Object> getNodeUpTimeInfo() { Uptime upTime = null; Who[] who = null; Map<Object, Object> nodeUpTimeInfo = new HashMap<Object, Object>(); double[] loadAverage = { 0, 0, 0 }; try { upTime = sigar.getUptime(); nodeUpTimeInfo.put("upTime", upTime.getUptime()); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { who = sigar.getWhoList(); String loggedUsers; List<String> userList = new ArrayList<String>(); for (Who w : who) { userList.add(w.getUser()); } loggedUsers = getDelimitedValues(userList, ","); nodeUpTimeInfo.put("loggedUsers", loggedUsers); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { loadAverage = sigar.getLoadAverage(); nodeUpTimeInfo.put("loadAverage1", loadAverage[0]); nodeUpTimeInfo.put("loadAverage2", loadAverage[1]); nodeUpTimeInfo.put("loadAverage3", loadAverage[2]); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } nodeUpTimeInfo.put("cpuUsage", getCpuUsage()); return nodeUpTimeInfo; }
SigarNodeInfoProvider { public Map<Object, Object> getNodeUpTimeInfo() { Uptime upTime = null; Who[] who = null; Map<Object, Object> nodeUpTimeInfo = new HashMap<Object, Object>(); double[] loadAverage = { 0, 0, 0 }; try { upTime = sigar.getUptime(); nodeUpTimeInfo.put("upTime", upTime.getUptime()); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { who = sigar.getWhoList(); String loggedUsers; List<String> userList = new ArrayList<String>(); for (Who w : who) { userList.add(w.getUser()); } loggedUsers = getDelimitedValues(userList, ","); nodeUpTimeInfo.put("loggedUsers", loggedUsers); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { loadAverage = sigar.getLoadAverage(); nodeUpTimeInfo.put("loadAverage1", loadAverage[0]); nodeUpTimeInfo.put("loadAverage2", loadAverage[1]); nodeUpTimeInfo.put("loadAverage3", loadAverage[2]); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } nodeUpTimeInfo.put("cpuUsage", getCpuUsage()); return nodeUpTimeInfo; } }
SigarNodeInfoProvider { public Map<Object, Object> getNodeUpTimeInfo() { Uptime upTime = null; Who[] who = null; Map<Object, Object> nodeUpTimeInfo = new HashMap<Object, Object>(); double[] loadAverage = { 0, 0, 0 }; try { upTime = sigar.getUptime(); nodeUpTimeInfo.put("upTime", upTime.getUptime()); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { who = sigar.getWhoList(); String loggedUsers; List<String> userList = new ArrayList<String>(); for (Who w : who) { userList.add(w.getUser()); } loggedUsers = getDelimitedValues(userList, ","); nodeUpTimeInfo.put("loggedUsers", loggedUsers); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { loadAverage = sigar.getLoadAverage(); nodeUpTimeInfo.put("loadAverage1", loadAverage[0]); nodeUpTimeInfo.put("loadAverage2", loadAverage[1]); nodeUpTimeInfo.put("loadAverage3", loadAverage[2]); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } nodeUpTimeInfo.put("cpuUsage", getCpuUsage()); return nodeUpTimeInfo; } SigarNodeInfoProvider(); }
SigarNodeInfoProvider { public Map<Object, Object> getNodeUpTimeInfo() { Uptime upTime = null; Who[] who = null; Map<Object, Object> nodeUpTimeInfo = new HashMap<Object, Object>(); double[] loadAverage = { 0, 0, 0 }; try { upTime = sigar.getUptime(); nodeUpTimeInfo.put("upTime", upTime.getUptime()); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { who = sigar.getWhoList(); String loggedUsers; List<String> userList = new ArrayList<String>(); for (Who w : who) { userList.add(w.getUser()); } loggedUsers = getDelimitedValues(userList, ","); nodeUpTimeInfo.put("loggedUsers", loggedUsers); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { loadAverage = sigar.getLoadAverage(); nodeUpTimeInfo.put("loadAverage1", loadAverage[0]); nodeUpTimeInfo.put("loadAverage2", loadAverage[1]); nodeUpTimeInfo.put("loadAverage3", loadAverage[2]); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } nodeUpTimeInfo.put("cpuUsage", getCpuUsage()); return nodeUpTimeInfo; } SigarNodeInfoProvider(); Map<Object, Object> getNodeMemoryInfo(); List<Map<Object, Object>> getNodeCpuInfos(); Map<Object, Object> getNodeSwapInfo(); List<Map<Object, Object>> getNodeNetworkInfos(); Map<Object, Object> getNodeOSInfo(); Map<Object, Object> getNodeUpTimeInfo(); List<Map<Object, Object>> getNodeDiskInfos(); List<Map<Object, Object>> getSortedListByItem(final String item); Map<String, Object> getNodeInfo(int topProcessCount); }
SigarNodeInfoProvider { public Map<Object, Object> getNodeUpTimeInfo() { Uptime upTime = null; Who[] who = null; Map<Object, Object> nodeUpTimeInfo = new HashMap<Object, Object>(); double[] loadAverage = { 0, 0, 0 }; try { upTime = sigar.getUptime(); nodeUpTimeInfo.put("upTime", upTime.getUptime()); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { who = sigar.getWhoList(); String loggedUsers; List<String> userList = new ArrayList<String>(); for (Who w : who) { userList.add(w.getUser()); } loggedUsers = getDelimitedValues(userList, ","); nodeUpTimeInfo.put("loggedUsers", loggedUsers); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } try { loadAverage = sigar.getLoadAverage(); nodeUpTimeInfo.put("loadAverage1", loadAverage[0]); nodeUpTimeInfo.put("loadAverage2", loadAverage[1]); nodeUpTimeInfo.put("loadAverage3", loadAverage[2]); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } nodeUpTimeInfo.put("cpuUsage", getCpuUsage()); return nodeUpTimeInfo; } SigarNodeInfoProvider(); Map<Object, Object> getNodeMemoryInfo(); List<Map<Object, Object>> getNodeCpuInfos(); Map<Object, Object> getNodeSwapInfo(); List<Map<Object, Object>> getNodeNetworkInfos(); Map<Object, Object> getNodeOSInfo(); Map<Object, Object> getNodeUpTimeInfo(); List<Map<Object, Object>> getNodeDiskInfos(); List<Map<Object, Object>> getSortedListByItem(final String item); Map<String, Object> getNodeInfo(int topProcessCount); static final char SLEEP; static final char RUN; static final char STOP; static final char ZOMBIE; static final char IDLE; static final int HUNDRED; static final int NUMBER_1024; }