use of org.apache.syncope.common.lib.info.SystemInfo in project syncope by apache.
the class LoadWidget method build.
private Line build(final SystemInfo systeminfo) {
List<String> labels = new ArrayList<>();
List<Double> cpuValues = new ArrayList<>();
List<Long> memValues = new ArrayList<>();
for (SystemInfo.LoadInstant instant : systeminfo.getLoad()) {
labels.add(DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(systeminfo.getStartTime() + instant.getUptime()));
cpuValues.add(instant.getSystemLoadAverage() * 1000);
memValues.add(instant.getTotalMemory());
}
Line line = new Line();
line.getOptions().setPointDot(false);
line.getOptions().setDatasetFill(false);
line.getOptions().setResponsive(true);
line.getOptions().setMaintainAspectRatio(true);
line.getOptions().setShowScale(false);
line.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>");
line.getData().setLabels(labels);
List<LineDataSet> datasets = new ArrayList<>();
LineDataSet cpuDataSet = new LineDataSet(cpuValues);
cpuDataSet.setLabel("CPU");
cpuDataSet.setPointColor("purple");
cpuDataSet.setStrokeColor("purple");
datasets.add(cpuDataSet);
LineDataSet memDataSet = new LineDataSet(memValues);
memDataSet.setLabel("MEM");
memDataSet.setPointColor("grey");
memDataSet.setStrokeColor("grey");
datasets.add(memDataSet);
line.getData().setDatasets(datasets);
return line;
}
use of org.apache.syncope.common.lib.info.SystemInfo in project syncope by apache.
the class SyncopeLogic method initSystemInfo.
private void initSystemInfo() {
if (SYSTEM_INFO == null) {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
SYSTEM_INFO = new SystemInfo();
try {
SYSTEM_INFO.setHostname(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
LOG.error("Could not get host name", e);
}
SYSTEM_INFO.setOs(operatingSystemMXBean.getName() + " " + operatingSystemMXBean.getVersion() + " " + operatingSystemMXBean.getArch());
SYSTEM_INFO.setAvailableProcessors(operatingSystemMXBean.getAvailableProcessors());
SYSTEM_INFO.setJvm(runtimeMXBean.getVmName() + " " + System.getProperty("java.version") + " " + runtimeMXBean.getVmVendor());
SYSTEM_INFO.setStartTime(runtimeMXBean.getStartTime());
}
}
Aggregations