Search in sources :

Example 1 with CpuMemoryData

use of org.onosproject.ovsdb.rfc.table.CpuMemoryData 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 2 with CpuMemoryData

use of org.onosproject.ovsdb.rfc.table.CpuMemoryData in project onos by opennetworkinglab.

the class PicaOvsdbClient method getDeviceCpuUsage.

/**
 * Get cpu usage of pica device.
 *
 * @return cpuStats, cpu usage statistics if present
 */
public Optional<DeviceCpuStats> getDeviceCpuUsage() {
    Optional<Object> deviceCpuDataObject = ovsdbClientService.getFirstRow(SWINVENTORY_DBNAME, OvsdbTable.CPUMEMORYDATA);
    if (!deviceCpuDataObject.isPresent()) {
        log.debug("Could not find {} column in {} table", DEVICE_CPU, CPU_MEMORY_DATA);
        return Optional.empty();
    }
    CpuMemoryData deviceCpuData = (CpuMemoryData) deviceCpuDataObject.get();
    log.debug("GOT CpuMemoryData as {} ", deviceCpuData);
    float freeCpuStat = deviceCpuData.getFreeCpuStats();
    DeviceCpuStats deviceCpuStats = new DeviceCpuStats();
    deviceCpuStats.setUsed(100.0f - freeCpuStat);
    return Optional.of(deviceCpuStats);
}
Also used : DeviceCpuStats(org.onosproject.net.behaviour.DeviceCpuStats) CpuMemoryData(org.onosproject.ovsdb.rfc.table.CpuMemoryData)

Aggregations

CpuMemoryData (org.onosproject.ovsdb.rfc.table.CpuMemoryData)2 DeviceCpuStats (org.onosproject.net.behaviour.DeviceCpuStats)1 DeviceMemoryStats (org.onosproject.net.behaviour.DeviceMemoryStats)1