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);
}
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);
}
Aggregations