Skip to content

Commit

Permalink
fix(system_monitor): fix unreadVariable (autowarefoundation#8372)
Browse files Browse the repository at this point in the history
fix:unreadVariable

Signed-off-by: kobayu858 <[email protected]>
  • Loading branch information
kobayu858 authored Aug 9, 2024
1 parent fb2fc7d commit e0fa943
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions system/system_monitor/src/cpu_monitor/intel_cpu_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,14 @@ void CPUMonitor::checkThrottling(diagnostic_updater::DiagnosticStatusWrapper & s
return;
}

int level = DiagStatus::OK;
int whole_level = DiagStatus::OK;
int index = 0;

for (auto itr = info.pkg_thermal_status_.begin(); itr != info.pkg_thermal_status_.end();
++itr, ++index) {
int level = DiagStatus::OK;
if (*itr) {
level = DiagStatus::ERROR;
} else {
level = DiagStatus::OK;
}

stat.add(fmt::format("CPU {}: Pkg Thermal Status", index), thermal_dict_.at(level));
Expand Down
6 changes: 2 additions & 4 deletions system/system_monitor/src/gpu_monitor/nvml_gpu_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ void GPUMonitor::checkUsage(diagnostic_updater::DiagnosticStatusWrapper & stat)
// Remember start time to measure elapsed time
const auto t_start = SystemMonitorUtility::startMeasurement();

int level = DiagStatus::OK;
int whole_level = DiagStatus::OK;
int index = 0;
nvmlReturn_t ret{};
Expand All @@ -150,7 +149,7 @@ void GPUMonitor::checkUsage(diagnostic_updater::DiagnosticStatusWrapper & stat)
return;
}

level = DiagStatus::OK;
int level = DiagStatus::OK;
float usage = static_cast<float>(itr->utilization.gpu) / 100.0;
if (usage >= gpu_usage_error_) {
level = std::max(level, static_cast<int>(DiagStatus::ERROR));
Expand Down Expand Up @@ -264,7 +263,6 @@ void GPUMonitor::checkMemoryUsage(diagnostic_updater::DiagnosticStatusWrapper &
// Remember start time to measure elapsed time
const auto t_start = SystemMonitorUtility::startMeasurement();

int level = DiagStatus::OK;
int whole_level = DiagStatus::OK;
int index = 0;
nvmlReturn_t ret{};
Expand All @@ -286,7 +284,7 @@ void GPUMonitor::checkMemoryUsage(diagnostic_updater::DiagnosticStatusWrapper &
return;
}

level = DiagStatus::OK;
int level = DiagStatus::OK;
float usage = static_cast<float>(itr->utilization.memory) / 100.0;
if (usage >= memory_usage_error_) {
level = std::max(level, static_cast<int>(DiagStatus::ERROR));
Expand Down

0 comments on commit e0fa943

Please sign in to comment.