use of org.onosproject.net.behaviour.DeviceCpuStats 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();
}
}
use of org.onosproject.net.behaviour.DeviceCpuStats 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();
}
}
use of org.onosproject.net.behaviour.DeviceCpuStats 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