Skip to content

Commit

Permalink
fix(system_monitor): fix variableScope (#8448)
Browse files Browse the repository at this point in the history
fix:variableScope

Signed-off-by: kobayu858 <[email protected]>
  • Loading branch information
kobayu858 authored Aug 15, 2024
1 parent 36f30d4 commit 3470824
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 9 additions & 8 deletions system/system_monitor/src/cpu_monitor/cpu_monitor_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<std::string> v = cpu_load.get_optional<std::string>("cpu")) {
cpu_name = v.get();
get_cpu_name = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -179,6 +177,7 @@ void ProcessMonitor::getTasksSummary(
return;
}

std::string line;
std::getline(is_out, line);
std::cmatch match;
const std::regex filter(
Expand Down

0 comments on commit 3470824

Please sign in to comment.