Apollo 11.0
自动驾驶开放平台
apollo::process_statistic::ProcessStatisticComponent类 参考

#include <process_statistic_component.h>

类 apollo::process_statistic::ProcessStatisticComponent 继承关系图:
apollo::process_statistic::ProcessStatisticComponent 的协作图:

Public 成员函数

bool Init () override
 
bool Proc () override
 The Proc logic of the component, which called by the CyberRT frame.
 
- Public 成员函数 继承自 apollo::cyber::TimerComponent
 TimerComponent ()
 
 ~TimerComponent () override
 
bool Initialize (const TimerComponentConfig &config) override
 init the component by protobuf object.
 
void Clear () override
 
bool Process ()
 
uint32_t GetInterval () const
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const ComponentConfig &config)
 
virtual void Shutdown ()
 
template<typename T >
bool GetProtoConfig (T *config) const
 

额外继承的成员函数

- Public 类型 继承自 apollo::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Node > node_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 process_statistic_component.h 第 48 行定义.

成员函数说明

◆ Init()

bool apollo::process_statistic::ProcessStatisticComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 process_statistic_component.cc 第 26 行定义.

26 {
27 // hook: Apollo License Verification: v_apollo_park
28 ProcessStatisticConf conf;
29 if (!ComponentBase::GetProtoConfig(&conf)) {
30 AERROR << "Unable to load process statistic conf file: " << ComponentBase::ConfigFilePath();
31 return false;
32 }
33 AINFO << "read conf success.";
34 LoadConf(conf);
35 // create metric writer
36 metric_writer_ = node_->CreateWriter<ProcessMetrics>(FLAGS_process_statistic_topic);
37 return true;
38}
std::shared_ptr< Node > node_
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42

◆ Proc()

bool apollo::process_statistic::ProcessStatisticComponent::Proc ( )
overridevirtual

The Proc logic of the component, which called by the CyberRT frame.

返回
returns true if successful, otherwise returns false

实现了 apollo::cyber::TimerComponent.

在文件 process_statistic_component.cc 第 52 行定义.

52 {
53 auto metrics = std::make_shared<ProcessMetrics>();
54 apollo::common::util::FillHeader(node_->Name(), metrics.get());
55
56 for (const auto& cmd_file : cyber::common::Glob("/proc/[0-9]*/cmdline")) {
57 // Get process command string.
58 std::string cmd_string;
59 if (cyber::common::GetContent(cmd_file, &cmd_string) && !cmd_string.empty()) {
60 // In /proc/<PID>/cmdline, the parts are separated with \0, which will be
61 // converted back to whitespaces here.
62 std::replace(cmd_string.begin(), cmd_string.end(), '\0', ' ');
63
64 if (ParseFromCache(cmd_string, metrics)) {
65 continue;
66 }
67 ParseCmd(cmd_string, metrics, cache_.at(cmd_string));
68 }
69 }
70 // write metrics
71 metric_writer_->Write(metrics);
72
73 // clean cache
74 if (++cycles % cache_clean_cycles == 0) {
75 cycles = 0;
76 CleanCache();
77 }
78 return true;
79}
std::vector< std::string > Glob(const std::string &pattern)
Expand path pattern to matched paths.
Definition file.cc:212
bool GetContent(const std::string &file_name, std::string *content)
Get file content as string.
Definition file.cc:167

该类的文档由以下文件生成: