Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
A-Tune
提交
c9c281fa
A
A-Tune
项目概览
openeuler
/
A-Tune
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
A-Tune
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c9c281fa
编写于
7月 07, 2020
作者:
H
hanxinke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
atune: add file_config CPI and code enhancement
上级
ed0d1902
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
143 addition
and
18 deletion
+143
-18
analysis/plugin/configurator/__init__.py
analysis/plugin/configurator/__init__.py
+1
-0
analysis/plugin/configurator/affinity/irq.py
analysis/plugin/configurator/affinity/irq.py
+1
-0
analysis/plugin/configurator/bios/bios.py
analysis/plugin/configurator/bios/bios.py
+1
-1
analysis/plugin/configurator/common.py
analysis/plugin/configurator/common.py
+12
-0
analysis/plugin/configurator/file_config/__init__.py
analysis/plugin/configurator/file_config/__init__.py
+20
-0
analysis/plugin/configurator/file_config/fconfig.py
analysis/plugin/configurator/file_config/fconfig.py
+91
-0
analysis/plugin/configurator/kernel_config/kconfig.py
analysis/plugin/configurator/kernel_config/kconfig.py
+2
-5
analysis/plugin/configurator/script/script.py
analysis/plugin/configurator/script/script.py
+1
-0
analysis/plugin/configurator/sysctl/sysctl.py
analysis/plugin/configurator/sysctl/sysctl.py
+1
-0
analysis/plugin/configurator/sysfs/sysfs.py
analysis/plugin/configurator/sysfs/sysfs.py
+1
-0
analysis/plugin/configurator/systemctl/systemctl.py
analysis/plugin/configurator/systemctl/systemctl.py
+1
-0
analysis/plugin/monitor/storage/iostat.py
analysis/plugin/monitor/storage/iostat.py
+9
-10
analysis/plugin/monitor/system/interrupts.py
analysis/plugin/monitor/system/interrupts.py
+1
-1
analysis/resources/profile.py
analysis/resources/profile.py
+1
-1
未找到文件。
analysis/plugin/configurator/__init__.py
浏览文件 @
c9c281fa
...
...
@@ -19,6 +19,7 @@ __all__ = [
"affinity"
,
"bios"
,
"bootloader"
,
"file_config"
,
"kernel_config"
,
"script"
,
"sysctl"
,
...
...
analysis/plugin/configurator/affinity/irq.py
浏览文件 @
c9c281fa
...
...
@@ -93,6 +93,7 @@ class IrqAffinity(Configurator):
@
staticmethod
def
check
(
config1
,
config2
):
"""replace comma"""
config1
=
config1
.
replace
(
","
,
""
)
config2
=
config2
.
replace
(
","
,
""
)
return
int
(
config1
,
base
=
16
)
==
int
(
config2
,
base
=
16
)
analysis/plugin/configurator/bios/bios.py
浏览文件 @
c9c281fa
...
...
@@ -34,7 +34,7 @@ class Bios(Configurator):
def
_set
(
self
,
key
,
value
):
raise
NeedConfigWarning
(
"
Please change the BIOS configuration {key} to {val}.
"
.
format
(
"
please change the BIOS configuration {key} to {val}
"
.
format
(
key
=
key
,
val
=
value
))
def
_get
(
self
,
key
,
_
):
...
...
analysis/plugin/configurator/common.py
浏览文件 @
c9c281fa
...
...
@@ -90,6 +90,12 @@ class Configurator:
cfg
=
self
.
_getcfg
(
config
)
try
:
ret
=
self
.
_set
(
cfg
[
0
],
cfg
[
1
])
except
Warning
as
warn
:
if
self
.
_user
==
"UT"
:
raise
warn
LOGGER
.
warning
(
"%s.%s: %s"
,
self
.
__class__
.
__name__
,
inspect
.
stack
()[
0
][
3
],
str
(
warn
))
return
warn
except
Exception
as
err
:
if
self
.
_user
==
"UT"
:
raise
err
...
...
@@ -188,6 +194,12 @@ class Configurator:
ret
=
self
.
_get
(
key
,
value
)
if
ret
is
not
None
:
ret
=
ret
.
replace
(
'
\n
'
,
' '
).
strip
()
except
Warning
as
warn
:
if
self
.
_user
==
"UT"
:
raise
warn
LOGGER
.
warning
(
"%s.%s: %s"
,
self
.
__class__
.
__name__
,
inspect
.
stack
()[
0
][
3
],
str
(
warn
))
return
warn
except
Exception
as
err
:
if
self
.
_user
==
"UT"
:
raise
err
...
...
analysis/plugin/configurator/file_config/__init__.py
0 → 100755
浏览文件 @
c9c281fa
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-06-18
"""
Init file.
"""
__all__
=
[
"fconfig"
]
from
.
import
*
analysis/plugin/configurator/file_config/fconfig.py
0 → 100755
浏览文件 @
c9c281fa
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-06-18
"""
The sub class of the Configurator, used to change the file config.
"""
import
inspect
import
logging
import
os
import
random
import
re
import
shutil
from
analysis.plugin.public
import
GetConfigError
,
NeedConfigWarning
from
..common
import
Configurator
LOGGER
=
logging
.
getLogger
(
__name__
)
class
FileConfig
(
Configurator
):
"""To change the file config"""
_module
=
"FILE_CONFIG"
_submod
=
"FILE_CONFIG"
_cfg_files
=
[
"/etc/profile"
]
_separator_char
=
"-"
def
__init__
(
self
,
user
=
None
):
Configurator
.
__init__
(
self
,
user
)
def
_set
(
self
,
key
,
value
):
try
:
if
self
.
get
(
key
,
value
)
==
value
:
return
0
except
LookupError
as
err
:
LOGGER
.
debug
(
"%s.%s: %s"
,
self
.
__class__
.
__name__
,
inspect
.
stack
()[
0
][
3
],
str
(
err
))
with
open
(
key
,
'a'
)
as
file
:
file
.
write
(
value
+
"
\n
"
)
if
key
in
self
.
_cfg_files
:
raise
NeedConfigWarning
(
"please exec source {file} to make the configuration take effect"
.
format
(
file
=
key
))
return
0
def
_get
(
self
,
key
,
value
):
if
not
os
.
path
.
exists
(
key
):
raise
GetConfigError
(
"Fail to find file {}"
.
format
(
key
))
config_key
=
value
.
split
(
"="
)[
0
]
if
value
.
find
(
"="
)
!=
-
1
else
value
pattern
=
re
.
compile
(
"^"
+
config_key
+
".*"
,
re
.
ASCII
|
re
.
DOTALL
)
search_obj
=
[]
with
open
(
key
,
'r'
)
as
file
:
for
line
in
file
:
result
=
pattern
.
search
(
line
)
if
result
is
not
None
:
search_obj
.
append
(
result
.
group
(
0
).
strip
())
if
len
(
search_obj
)
==
0
:
raise
LookupError
(
"Fail to find {} entry in {}"
.
format
(
config_key
,
key
))
return
search_obj
[
-
1
]
def
_backup
(
self
,
config
,
rollback_info
):
cfg
=
self
.
_getcfg
(
config
)
name
=
cfg
[
0
].
replace
(
"/"
,
self
.
_separator_char
)
bak_file
=
"{path}/{file}{sep}{ver}"
.
format
(
path
=
rollback_info
,
file
=
name
,
sep
=
self
.
_separator_char
,
ver
=
random
.
random
())
shutil
.
copy
(
cfg
[
0
],
bak_file
)
return
"CPI_ROLLBACK_INFO = {}"
.
format
(
bak_file
)
def
_resume
(
self
,
key
,
value
):
if
key
!=
"CPI_ROLLBACK_INFO"
:
raise
ValueError
(
"unsupported resume type: {}"
.
format
(
key
))
left_index
=
value
.
rfind
(
"/"
)
right_index
=
value
.
rfind
(
self
.
_separator_char
)
if
left_index
==
-
1
or
right_index
==
-
1
:
return
cfg_file
=
value
[
left_index
+
1
:
right_index
].
replace
(
self
.
_separator_char
,
"/"
)
LOGGER
.
info
(
"resume cfg file is %s"
,
cfg_file
)
shutil
.
copy
(
value
,
cfg_file
)
analysis/plugin/configurator/kernel_config/kconfig.py
浏览文件 @
c9c281fa
...
...
@@ -15,7 +15,6 @@
The sub class of the Configurator, used to change the kernel config.
"""
import
gzip
import
inspect
import
os
import
logging
import
subprocess
...
...
@@ -46,7 +45,7 @@ class KernelConfig(Configurator):
if
self
.
get
(
key
)
==
value
:
return
0
raise
NeedConfigWarning
(
"
Please change the kernel configuration {key} to {val}.
"
.
format
(
"
please change the kernel configuration {key} to {val}
"
.
format
(
key
=
key
,
val
=
value
))
def
_get
(
self
,
key
,
_
):
...
...
@@ -61,9 +60,7 @@ class KernelConfig(Configurator):
pattern
=
re
.
compile
(
"^"
+
key
+
"=(.+)"
,
re
.
ASCII
|
re
.
MULTILINE
)
search_obj
=
pattern
.
findall
(
cfgs
)
if
len
(
search_obj
)
!=
1
:
err
=
LookupError
(
"not find one "
+
key
)
LOGGER
.
error
(
"%s.%s: %s"
,
self
.
__class__
.
__name__
,
inspect
.
stack
()[
0
][
3
],
str
(
err
))
err
=
Warning
(
"not find one "
+
key
)
raise
err
return
search_obj
[
0
]
...
...
analysis/plugin/configurator/script/script.py
浏览文件 @
c9c281fa
...
...
@@ -100,6 +100,7 @@ class Script(Configurator):
@
staticmethod
def
check
(
_
,
__
):
"""check"""
return
True
def
_backup
(
self
,
config
,
rollback_info
):
...
...
analysis/plugin/configurator/sysctl/sysctl.py
浏览文件 @
c9c281fa
...
...
@@ -44,6 +44,7 @@ class Sysctl(Configurator):
@
staticmethod
def
check
(
config1
,
config2
):
"""substring"""
config1
=
re
.
sub
(
r
"\s{1,}"
,
" "
,
config1
)
config2
=
re
.
sub
(
r
"\s{1,}"
,
" "
,
config2
)
return
config1
==
config2
analysis/plugin/configurator/sysfs/sysfs.py
浏览文件 @
c9c281fa
...
...
@@ -48,4 +48,5 @@ class Sysfs(Configurator):
@
staticmethod
def
check
(
_
,
__
):
"""check"""
return
True
analysis/plugin/configurator/systemctl/systemctl.py
浏览文件 @
c9c281fa
...
...
@@ -53,6 +53,7 @@ class Systemctl(Configurator):
@
staticmethod
def
check
(
_
,
__
):
"""check"""
return
True
def
_backup
(
self
,
config
,
_
):
...
...
analysis/plugin/monitor/storage/iostat.py
浏览文件 @
c9c281fa
...
...
@@ -95,6 +95,7 @@ class IoStat(Monitor):
keys
=
[]
dev
=
"sd.*?"
ret
=
""
resplitobj
=
re
.
compile
(
r
'\s*\n'
)
device_data
=
{}
opts
,
_
=
getopt
.
getopt
(
para
.
split
(),
None
,
[
'device='
,
'fields='
])
...
...
@@ -106,17 +107,15 @@ class IoStat(Monitor):
keys
.
append
(
val
)
continue
rows_contents
=
resplitobj
.
split
(
info
)
dev
=
"Device|"
+
dev
pattern
=
re
.
compile
(
"^("
+
dev
+
r
")\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)"
r
"\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)"
r
"\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)"
r
"\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)\ {1,}(\S*)"
,
re
.
ASCII
|
re
.
MULTILINE
)
search_obj
=
pattern
.
findall
(
info
)
if
len
(
search_obj
)
<
2
:
search_obj
=
[]
pattern
=
re
.
compile
(
"^("
+
dev
+
r
").+"
,
re
.
ASCII
)
for
row
in
rows_contents
:
if
pattern
.
match
(
row
):
search_obj
.
append
([
data
for
data
in
row
.
split
()])
if
len
(
search_obj
)
<
3
:
err
=
LookupError
(
"Fail to find data for {}"
.
format
(
dev
))
LOGGER
.
error
(
"%s.%s: %s"
,
self
.
__class__
.
__name__
,
inspect
.
stack
()[
0
][
3
],
str
(
err
))
...
...
analysis/plugin/monitor/system/interrupts.py
浏览文件 @
c9c281fa
...
...
@@ -59,6 +59,6 @@ class SysInterrupts(Monitor):
nic
=
val
break
pattern
=
re
.
compile
(
r
"^(\d*):{}
$
"
.
format
(
nic
.
strip
()),
re
.
MULTILINE
)
pattern
=
re
.
compile
(
r
"^(\d*):{}"
.
format
(
nic
.
strip
()),
re
.
MULTILINE
)
interrupts
=
pattern
.
findall
(
info
)
return
" "
.
join
(
interrupts
).
strip
()
analysis/resources/profile.py
浏览文件 @
c9c281fa
...
...
@@ -79,7 +79,7 @@ class Profile(Resource):
result
[
"status"
]
=
"FAILED"
result
[
"value"
]
=
str
(
real_value
)
else
:
if
not
real_valu
e
:
if
real_value
is
Non
e
:
result
[
"status"
]
=
"FAILED"
result
[
"value"
]
=
"UNKNOWN"
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录