Search in sources :

Example 1 with SystemInfo

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;
}
Also used : Line(com.pingunaut.wicket.chartjs.chart.impl.Line) SystemInfo(org.apache.syncope.common.lib.info.SystemInfo) LineDataSet(com.pingunaut.wicket.chartjs.data.sets.LineDataSet) ArrayList(java.util.ArrayList)

Example 2 with SystemInfo

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());
    }
}
Also used : SystemInfo(org.apache.syncope.common.lib.info.SystemInfo) UnknownHostException(java.net.UnknownHostException) RuntimeMXBean(java.lang.management.RuntimeMXBean) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean)

Aggregations

SystemInfo (org.apache.syncope.common.lib.info.SystemInfo)2 Line (com.pingunaut.wicket.chartjs.chart.impl.Line)1 LineDataSet (com.pingunaut.wicket.chartjs.data.sets.LineDataSet)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1