public Long getMemShared() { return vdsStatistics.getMemShared(); }
public Integer getMemSharedPercent() { Long shared = vdsStatistics.getMemShared(); Integer physical = vdsDynamic.getPhysicalMemMb(); if (shared == null || physical == null || physical == 0) { return 0; } return (int) ((shared * 100) / physical); }
static VDS setUpStatisticalEntityExpectations(VDS entity, VdsStatistics statistics) { when(entity.getPhysicalMemMb()).thenReturn(5120); when(entity.getStatisticsData()).thenReturn(statistics); when(statistics.getUsageMemPercent()).thenReturn(20); when(statistics.getSwapFree()).thenReturn(25L); when(statistics.getSwapTotal()).thenReturn(30L); when(statistics.getMemAvailable()).thenReturn(35L); when(statistics.getMemShared()).thenReturn(38L); when(statistics.getKsmCpuPercent()).thenReturn(40); when(statistics.getCpuUser()).thenReturn(45.0); when(statistics.getCpuSys()).thenReturn(50.0); when(statistics.getCpuIdle()).thenReturn(55.0); when(statistics.getCpuLoad()).thenReturn(0.60); return entity; }
public List<Statistic> getStatistics(VDS entity) { VdsStatistics s = entity.getStatisticsData(); // if user queries host statistics before host installation completed, null values are possible (therefore added checks). long memTotal = entity.getPhysicalMemMb()==null ? 0 : entity.getPhysicalMemMb() * Mb; long memUsed = (s==null || s.getUsageMemPercent()==null) ? 0 : memTotal * s.getUsageMemPercent() / 100; List<Statistic> statistics = asList(setDatum(clone(MEM_TOTAL), memTotal), setDatum(clone(MEM_USED), memUsed), setDatum(clone(MEM_FREE), memTotal-memUsed), setDatum(clone(MEM_SHARED), (s==null || s.getMemShared()==null) ? 0 : s.getMemShared()*Mb), setDatum(clone(MEM_BUFFERS), 0), setDatum(clone(MEM_CACHED), 0), setDatum(clone(SWAP_TOTAL), (s==null || s.getSwapTotal()==null) ? 0 : s.getSwapTotal()*Mb), setDatum(clone(SWAP_FREE), (s==null || s.getSwapFree()==null) ? 0 : s.getSwapFree()*Mb), setDatum(clone(SWAP_USED), getSwapUsed(s)*Mb), setDatum(clone(SWAP_CACHED), 0), setDatum(clone(CPU_KSM), (s==null || s.getKsmCpuPercent()==null) ? 0 : s.getKsmCpuPercent()), setDatum(clone(CPU_USER), (s==null || s.getCpuUser()==null) ? 0 : s.getCpuUser()), setDatum(clone(CPU_SYS), (s==null || s.getCpuSys()==null) ? 0 : s.getCpuSys()), setDatum(clone(CPU_IDLE), (s==null || s.getCpuIdle()==null) ? 0 : s.getCpuIdle()), setDatum(clone(CPU_LOAD), (s==null || s.getCpuLoad()==null) ? 0 : s.getCpuLoad()/100), setDatum(clone(BOOT_TIME), (s==null || s.getBootTime()==null) ? 0 : s.getBootTime())); if (s != null && s.getHugePages() != null) { s.getHugePages().stream() .filter(page -> page.getAmount() != null) .map(this::createHugePagesFree) .forEach(statistics::add); } return statistics; }
.addValue("mem_available", stats.getMemAvailable()) .addValue("mem_free" , stats.getMemFree()) .addValue("mem_shared", stats.getMemShared()) .addValue("swap_free", stats.getSwapFree()) .addValue("swap_total", stats.getSwapTotal())
.addValue("mem_available", stats.getMemAvailable()) .addValue("mem_free" , stats.getMemFree()) .addValue("mem_shared", stats.getMemShared()) .addValue("swap_free", stats.getSwapFree()) .addValue("swap_total", stats.getSwapTotal())