Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
6beb52bc
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6beb52bc
编写于
8月 24, 2018
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'PraveenPenguin/fix_profiler1'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
af7239bf
2432383e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
16 deletion
+30
-16
avocado/core/sysinfo.py
avocado/core/sysinfo.py
+30
-16
未找到文件。
avocado/core/sysinfo.py
浏览文件 @
6beb52bc
...
...
@@ -112,7 +112,7 @@ class Command(Collectible):
:param cmd: String with the command.
:param logf: Basename of the file where output is logged (optional).
:param compress_log
f
: Whether to compress the output of the command.
:param compress_log: Whether to compress the output of the command.
"""
def
__init__
(
self
,
cmd
,
logf
=
None
,
compress_log
=
False
):
...
...
@@ -184,9 +184,13 @@ class Daemon(Command):
:param cmd: String with the daemon command.
:param logf: Basename of the file where output is logged (optional).
:param compress_log
f
: Whether to compress the output of the command.
:param compress_log: Whether to compress the output of the command.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Daemon
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
daemon_process
=
None
def
run
(
self
,
logdir
):
"""
Execute the daemon as a subprocess and log its output in logdir.
...
...
@@ -202,21 +206,29 @@ class Daemon(Command):
logf_path
=
os
.
path
.
join
(
logdir
,
self
.
logf
)
stdin
=
open
(
os
.
devnull
,
"r"
)
stdout
=
open
(
logf_path
,
"w"
)
self
.
pipe
=
subprocess
.
Popen
(
shlex
.
split
(
self
.
cmd
),
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
subprocess
.
STDOUT
,
shell
=
False
,
env
=
env
)
try
:
self
.
daemon_process
=
subprocess
.
Popen
(
shlex
.
split
(
self
.
cmd
),
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
subprocess
.
STDOUT
,
shell
=
False
,
env
=
env
)
except
OSError
:
log
.
debug
(
"Not logging %s (command could not be run)"
%
self
.
cmd
)
def
stop
(
self
):
"""
Stop daemon execution.
"""
retcode
=
self
.
pipe
.
poll
()
if
retcode
is
None
:
process
.
kill_process_tree
(
self
.
pipe
.
pid
)
retcode
=
self
.
pipe
.
wait
()
else
:
log
.
error
(
"Daemon process '%s' (pid %d) terminated abnormally (code %d)"
,
self
.
cmd
,
self
.
pipe
.
pid
,
retcode
)
return
retcode
if
self
.
daemon_process
is
not
None
:
retcode
=
self
.
daemon_process
.
poll
()
if
retcode
is
None
:
process
.
kill_process_tree
(
self
.
daemon_process
.
pid
)
retcode
=
self
.
daemon_process
.
wait
()
else
:
log
.
error
(
"Daemon process '%s' (pid %d) "
"terminated abnormally (code %d)"
,
self
.
cmd
,
self
.
daemon_process
.
pid
,
retcode
)
return
retcode
class
JournalctlWatcher
(
Collectible
):
...
...
@@ -331,7 +343,8 @@ class LogWatcher(Collectible):
with
gzip
.
GzipFile
(
dstpath
,
"wb"
)
as
out_messages
:
in_messages
.
seek
(
bytes_to_skip
)
while
True
:
# Read data in manageable chunks rather than all at once.
# Read data in manageable chunks rather than
# all at once.
in_data
=
in_messages
.
read
(
200000
)
if
not
in_data
:
break
...
...
@@ -423,7 +436,8 @@ class SysInfo(object):
if
self
.
profiler
is
False
:
if
not
self
.
profilers
:
log
.
info
(
'Profiler disabled: no profiler commands configured'
)
log
.
info
(
'Profiler disabled: no profiler'
' commands configured'
)
else
:
log
.
info
(
'Profiler disabled'
)
else
:
...
...
@@ -523,8 +537,8 @@ class SysInfo(object):
Add a system file watcher collectible.
:param filename: Path to the file to be logged.
:param hook: In which hook this watcher should be logged
(start job, end
job).
:param hook: In which hook this watcher should be logged
(start job, end
job).
"""
collectibles
=
self
.
_get_collectibles
(
hook
)
collectibles
.
add
(
LogWatcher
(
filename
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录