@@ -118,7 +118,7 @@ uint32_t ComponentMonitor::to_uint32(const std::string & str)
118
118
/* *
119
119
* @brief Get CPU usage of the component.
120
120
*
121
- * @details The output of `pidstat -u -p PID` is like below:
121
+ * @details The output of `pidstat -u -h 1 1 - p PID` is like below:
122
122
*
123
123
* Linux 6.5.0-35-generic (leopc) 21-05-2024 _x86_64_ (16 CPU)
124
124
* 14:54:52 UID PID %usr %system %guest %wait %CPU CPU Command
@@ -128,7 +128,7 @@ uint32_t ComponentMonitor::to_uint32(const std::string & str)
128
128
*/
129
129
void ComponentMonitor::get_cpu_usage ()
130
130
{
131
- std::string cmd{" pidstat -u -p " };
131
+ std::string cmd{" pidstat -u -h 1 1 - p " };
132
132
cmd += std::to_string (pid_);
133
133
134
134
auto std_out = run_command (cmd);
@@ -141,7 +141,7 @@ void ComponentMonitor::get_cpu_usage()
141
141
/* *
142
142
* @brief Get memory usage of the component.
143
143
*
144
- * @details The output of `pidstat -r -p PID` is like below:
144
+ * @details The output of `pidstat -r -h 1 1 - p PID` is like below:
145
145
*
146
146
* Linux 6.5.0-35-generic (leopc) 21-05-2024 _x86_64_ (16 CPU)
147
147
* 14:54:52 UID PID minflt/s majflt/s VSZ RSS %MEM Command
@@ -151,7 +151,7 @@ void ComponentMonitor::get_cpu_usage()
151
151
*/
152
152
void ComponentMonitor::get_mem_usage ()
153
153
{
154
- std::string cmd{" pidstat -r -p " };
154
+ std::string cmd{" pidstat -r -h 1 1 - p " };
155
155
cmd += std::to_string (pid_);
156
156
157
157
auto std_out = run_command (cmd);
0 commit comments