Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
0d718044
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0d718044
编写于
11月 03, 2017
作者:
A
Aaron Xiao
提交者:
GitHub
11月 03, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Monitor: Match process by keywords instead of binary name, to support GPS and velodyne. (#1053)
上级
b8a3d6bb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
55 addition
and
40 deletion
+55
-40
modules/common/util/file.cc
modules/common/util/file.cc
+13
-0
modules/common/util/file.h
modules/common/util/file.h
+8
-0
modules/dreamview/conf/hmi.conf
modules/dreamview/conf/hmi.conf
+1
-9
modules/monitor/conf/module_monitor_conf.pb.txt
modules/monitor/conf/module_monitor_conf.pb.txt
+15
-7
modules/monitor/proto/module_monitor_conf.proto
modules/monitor/proto/module_monitor_conf.proto
+1
-1
modules/monitor/software/process_monitor.cc
modules/monitor/software/process_monitor.cc
+17
-23
未找到文件。
modules/common/util/file.cc
浏览文件 @
0d718044
...
...
@@ -19,11 +19,24 @@
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <fstream>
namespace
apollo
{
namespace
common
{
namespace
util
{
bool
GetContent
(
const
std
::
string
&
file_name
,
std
::
string
*
content
)
{
std
::
ifstream
fin
(
file_name
);
if
(
!
fin
)
{
return
false
;
}
std
::
stringstream
str_stream
;
str_stream
<<
fin
.
rdbuf
();
*
content
=
str_stream
.
str
();
return
true
;
}
bool
PathExists
(
const
std
::
string
&
path
)
{
struct
stat
info
;
return
stat
(
path
.
c_str
(),
&
info
)
==
0
;
...
...
modules/common/util/file.h
浏览文件 @
0d718044
...
...
@@ -170,6 +170,14 @@ bool GetProtoFromFile(const std::string &file_name, MessageType *message) {
return
true
;
}
/**
* @brief Get file content as string.
* @param file_name The name of the file to read content.
* @param content The file content.
* @return If the action is successful.
*/
bool
GetContent
(
const
std
::
string
&
file_name
,
std
::
string
*
content
);
/**
* @brief Check if the path exists.
* @return If the path exists.
...
...
modules/dreamview/conf/hmi.conf
浏览文件 @
0d718044
...
...
@@ -142,19 +142,11 @@ hardware {
key
:
"GPS"
value
: {
display_name
:
"GPS"
supported_commands
{
key
:
"health_check"
value
:
"scripts/hw_check.sh gps"
}
}
}
hardware
{
key
:
"
ESD_CAN-0
"
key
:
"
CAN
"
value
: {
display_name
:
"CAN"
supported_commands
{
key
:
"health_check"
value
:
"scripts/hw_check.sh can"
}
}
}
modules/monitor/conf/module_monitor_conf.pb.txt
浏览文件 @
0d718044
modules {
name: "canbus"
binary_path: "modules/canbus/canbus"
process_cmd_keywords: "modules/canbus/canbus"
}
modules {
name: "GPS"
process_cmd_keywords: "gnss_nodelet_manager"
}
modules {
name: "velodyne"
process_cmd_keywords: "velodyne_nodelet_manager"
}
modules {
name: "localization"
binary_path
: "modules/localization/localization"
process_cmd_keywords
: "modules/localization/localization"
}
modules {
name: "perception"
binary_path
: "modules/perception/perception"
process_cmd_keywords
: "modules/perception/perception"
}
modules {
name: "prediction"
binary_path
: "modules/prediction/prediction"
process_cmd_keywords
: "modules/prediction/prediction"
}
modules {
name: "routing"
binary_path
: "modules/routing/routing"
process_cmd_keywords
: "modules/routing/routing"
}
modules {
name: "planning"
binary_path
: "modules/planning/planning"
process_cmd_keywords
: "modules/planning/planning"
}
modules {
name: "control"
binary_path
: "modules/control/control"
process_cmd_keywords
: "modules/control/control"
}
modules/monitor/proto/module_monitor_conf.proto
浏览文件 @
0d718044
...
...
@@ -9,7 +9,7 @@ message ModuleMonitorConf {
optional
string
name
=
1
;
// For process monitor.
optional
string
binary_path
=
2
;
repeated
string
process_cmd_keywords
=
2
;
// TODO(xiaoxq): For message monitor, which hasn't been implemented.
optional
apollo.common.adapter.AdapterConfig.MessageType
msg_type
=
3
;
...
...
modules/monitor/software/process_monitor.cc
浏览文件 @
0d718044
...
...
@@ -24,7 +24,7 @@
DEFINE_string
(
process_monitor_name
,
"ProcessMonitor"
,
"Name of the process monitor."
);
DEFINE_double
(
process_monitor_interval
,
3
,
DEFINE_double
(
process_monitor_interval
,
1.5
,
"Process status checking interval (s)."
);
DEFINE_string
(
module_monitor_conf_path
,
...
...
@@ -33,23 +33,9 @@ DEFINE_string(module_monitor_conf_path,
namespace
apollo
{
namespace
monitor
{
namespace
{
using
apollo
::
common
::
util
::
GetProtoFromFile
;
std
::
string
TranslateSymbolicLink
(
const
std
::
string
&
origin
)
{
constexpr
int
BUF_SIZE
=
512
;
char
buf
[
BUF_SIZE
];
int
count
=
readlink
(
origin
.
c_str
(),
buf
,
BUF_SIZE
);
if
(
count
<
0
)
{
count
=
0
;
}
buf
[
count
]
=
'\0'
;
return
buf
;
}
}
// namespace
ProcessMonitor
::
ProcessMonitor
(
SystemStatus
*
system_status
)
:
RecurrentRunner
(
FLAGS_process_monitor_name
,
FLAGS_process_monitor_interval
)
...
...
@@ -59,7 +45,7 @@ ProcessMonitor::ProcessMonitor(SystemStatus *system_status)
// Init module status if it has set binary to check.
for
(
const
auto
&
module_conf
:
config_
.
modules
())
{
if
(
module_conf
.
has_binary_path
())
{
if
(
!
module_conf
.
process_cmd_keywords
().
empty
())
{
status_
->
insert
({
module_conf
.
name
(),
{}});
}
}
...
...
@@ -68,22 +54,30 @@ ProcessMonitor::ProcessMonitor(SystemStatus *system_status)
void
ProcessMonitor
::
RunOnce
(
const
double
current_time
)
{
// Set all processes as not-running by default.
for
(
const
auto
&
module_conf
:
config_
.
modules
())
{
if
(
module_conf
.
has_binary_path
())
{
if
(
!
module_conf
.
process_cmd_keywords
().
empty
())
{
(
*
status_
)[
module_conf
.
name
()].
set_process_running
(
false
);
}
}
const
auto
procs
=
common
::
util
::
ListSubDirectories
(
"/proc"
);
for
(
const
auto
&
proc
:
procs
)
{
const
auto
binary_link
=
common
::
util
::
StrCat
(
"/proc/"
,
proc
,
"/exe"
);
const
auto
binary_path
=
TranslateSymbolicLink
(
binary_link
);
if
(
binary_path
.
empty
())
{
// Get process command string.
std
::
string
cmd_string
;
const
auto
cmd_file
=
common
::
util
::
StrCat
(
"/proc/"
,
proc
,
"/cmdline"
);
if
(
!
common
::
util
::
GetContent
(
cmd_file
,
&
cmd_string
))
{
continue
;
}
for
(
const
auto
&
module_conf
:
config_
.
modules
())
{
// Find the bounded module.
if
(
module_conf
.
has_binary_path
()
&&
common
::
util
::
EndWith
(
binary_path
,
module_conf
.
binary_path
()))
{
const
auto
&
keywords
=
module_conf
.
process_cmd_keywords
();
// Check if the command string contains all keywords of this module.
const
bool
keywords_matched
=
!
keywords
.
empty
()
&&
std
::
find_if
(
keywords
.
begin
(),
keywords
.
end
(),
[
cmd_string
](
const
std
::
string
&
keyword
)
->
bool
{
return
cmd_string
.
find
(
keyword
)
==
std
::
string
::
npos
;
})
==
keywords
.
end
();
if
(
keywords_matched
)
{
(
*
status_
)[
module_conf
.
name
()].
set_process_running
(
true
);
ADEBUG
<<
"Found "
<<
module_conf
.
name
()
<<
" module "
"is running on process "
<<
proc
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录