Search in sources :

Example 1 with DeviceMemoryStats

use of org.onosproject.net.behaviour.DeviceMemoryStats in project onos by opennetworkinglab.

the class PicaOvsdbSystemStatsQuery method getDeviceSystemStats.

/**
 * Get system stats (cpu/mmeory usage) of device.
 *
 * @return deviceSystemStats, system stats (cpu/memory usage) of device if available
 */
@Override
public Optional<DeviceSystemStats> getDeviceSystemStats() {
    Optional<DeviceCpuStats> cpuStats = getCpuUsage();
    Optional<DeviceMemoryStats> memoryStats = getMemoryUsage();
    if (cpuStats.isPresent() && memoryStats.isPresent()) {
        DeviceSystemStats systemStats = new DeviceSystemStats(memoryStats.get(), cpuStats.get());
        return Optional.of(systemStats);
    } else {
        return Optional.empty();
    }
}
Also used : DeviceMemoryStats(org.onosproject.net.behaviour.DeviceMemoryStats) DeviceCpuStats(org.onosproject.net.behaviour.DeviceCpuStats) DeviceSystemStats(org.onosproject.net.behaviour.DeviceSystemStats)

Example 2 with DeviceMemoryStats

use of org.onosproject.net.behaviour.DeviceMemoryStats in project onos by opennetworkinglab.

the class PicaOvsdbClient method getDeviceMemoryUsage.

/**
 * Get memory usage of pica device.
 *
 * @return memoryStats, memory usage statistics if present
 */
public Optional<DeviceMemoryStats> getDeviceMemoryUsage() {
    Optional<Object> deviceMemoryDataObject = ovsdbClientService.getFirstRow(SWINVENTORY_DBNAME, OvsdbTable.CPUMEMORYDATA);
    if (!deviceMemoryDataObject.isPresent()) {
        log.debug("Could not find {} column in {} table", DEVICE_MEMORY, CPU_MEMORY_DATA);
        return Optional.empty();
    }
    CpuMemoryData deviceMemoryData = (CpuMemoryData) deviceMemoryDataObject.get();
    long totalMem = deviceMemoryData.getTotalMemoryStats();
    long usedMem = deviceMemoryData.getUsedMemoryStats();
    long freeMem = deviceMemoryData.getFreeMemoryStats();
    DeviceMemoryStats deviceMemoryStats = new DeviceMemoryStats();
    deviceMemoryStats.setFree(freeMem);
    deviceMemoryStats.setUsed(usedMem);
    deviceMemoryStats.setTotal(totalMem);
    return Optional.of(deviceMemoryStats);
}
Also used : DeviceMemoryStats(org.onosproject.net.behaviour.DeviceMemoryStats) CpuMemoryData(org.onosproject.ovsdb.rfc.table.CpuMemoryData)

Example 3 with DeviceMemoryStats

use of org.onosproject.net.behaviour.DeviceMemoryStats in project onos by opennetworkinglab.

the class ServerDevicesDiscovery method getDeviceSystemStats.

/**
 * Implements DeviceSystemStatisticsQuery behaviour.
 */
@Override
public Optional<DeviceSystemStats> getDeviceSystemStats() {
    // Retrieve the device ID from the handler
    DeviceId deviceId = getDeviceId();
    checkNotNull(deviceId, MSG_DEVICE_ID_NULL);
    // ....to retrieve monitoring statistics
    MonitoringStatistics monStats = getGlobalMonitoringStatistics(deviceId);
    Optional<DeviceCpuStats> cpuStats = getOverallCpuUsage(monStats);
    Optional<DeviceMemoryStats> memoryStats = getOverallMemoryUsage(monStats);
    if (cpuStats.isPresent() && memoryStats.isPresent()) {
        return Optional.of(new DeviceSystemStats(memoryStats.get(), cpuStats.get()));
    } else {
        return Optional.empty();
    }
}
Also used : DeviceMemoryStats(org.onosproject.net.behaviour.DeviceMemoryStats) DeviceCpuStats(org.onosproject.net.behaviour.DeviceCpuStats) DeviceId(org.onosproject.net.DeviceId) DefaultMonitoringStatistics(org.onosproject.drivers.server.impl.stats.DefaultMonitoringStatistics) MonitoringStatistics(org.onosproject.drivers.server.stats.MonitoringStatistics) DeviceSystemStats(org.onosproject.net.behaviour.DeviceSystemStats)

Aggregations

DeviceMemoryStats (org.onosproject.net.behaviour.DeviceMemoryStats)3 DeviceCpuStats (org.onosproject.net.behaviour.DeviceCpuStats)2 DeviceSystemStats (org.onosproject.net.behaviour.DeviceSystemStats)2 DefaultMonitoringStatistics (org.onosproject.drivers.server.impl.stats.DefaultMonitoringStatistics)1 MonitoringStatistics (org.onosproject.drivers.server.stats.MonitoringStatistics)1 DeviceId (org.onosproject.net.DeviceId)1 CpuMemoryData (org.onosproject.ovsdb.rfc.table.CpuMemoryData)1