diff --git a/system/system_monitor/src/cpu_monitor/cpu_monitor_base.cpp b/system/system_monitor/src/cpu_monitor/cpu_monitor_base.cpp index b5e0e51c0ceaf..13d7151bb14c7 100644 --- a/system/system_monitor/src/cpu_monitor/cpu_monitor_base.cpp +++ b/system/system_monitor/src/cpu_monitor/cpu_monitor_base.cpp @@ -175,14 +175,6 @@ void CPUMonitorBase::checkUsage(diagnostic_updater::DiagnosticStatusWrapper & st return; } - std::string cpu_name; - float usr{0.0}; - float nice{0.0}; - float sys{0.0}; - float iowait{0.0}; - float idle{0.0}; - float usage{0.0}; - float total{0.0}; int level = DiagStatus::OK; int whole_level = DiagStatus::OK; @@ -203,6 +195,15 @@ void CPUMonitorBase::checkUsage(diagnostic_updater::DiagnosticStatusWrapper & st CpuStatus cpu_status; + std::string cpu_name; + float usr{0.0}; + float nice{0.0}; + float sys{0.0}; + float iowait{0.0}; + float idle{0.0}; + float usage{0.0}; + float total{0.0}; + if (boost::optional v = cpu_load.get_optional("cpu")) { cpu_name = v.get(); get_cpu_name = true; diff --git a/system/system_monitor/src/process_monitor/process_monitor.cpp b/system/system_monitor/src/process_monitor/process_monitor.cpp index 2ab3e053225eb..73059d2d162fa 100644 --- a/system/system_monitor/src/process_monitor/process_monitor.cpp +++ b/system/system_monitor/src/process_monitor/process_monitor.cpp @@ -127,8 +127,6 @@ void ProcessMonitor::getTasksSummary( } bp::pipe p{p_fd[0], p_fd[1]}; - std::string line; - // Echo output for grep { int out_fd[2]; @@ -179,6 +177,7 @@ void ProcessMonitor::getTasksSummary( return; } + std::string line; std::getline(is_out, line); std::cmatch match; const std::regex filter(