Compare commits
10 Commits
af7e512fd6
...
23a63e5f90
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23a63e5f90 | ||
|
|
3f27eeffd4 | ||
|
|
bc61ffa875 | ||
|
|
b9aaf76c07 | ||
|
|
12c820734a | ||
|
|
d4d07bc624 | ||
|
|
010bcee507 | ||
|
|
d044c7f068 | ||
|
|
d66a47f5bb | ||
|
|
9e6698c244 |
28
CVE-2024-24897.patch
Normal file
28
CVE-2024-24897.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From c59e9b4dd509a456fb1fedb50cc7ff9ef7ad55f9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: zhoupengcheng <zhoupengcheng11@huawei.com>
|
||||||
|
Date: Mon, 11 Mar 2024 19:05:07 +0800
|
||||||
|
Subject: [PATCH] preventing possible Shell command injection
|
||||||
|
|
||||||
|
---
|
||||||
|
atune_collector/plugin/monitor/process/sched.py | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/monitor/process/sched.py b/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
index 0fadeba..82e6d9f 100644
|
||||||
|
--- a/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
+++ b/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
@@ -68,8 +68,9 @@ class ProcSched(Monitor):
|
||||||
|
raise err
|
||||||
|
|
||||||
|
for app in self.__applications:
|
||||||
|
- pid = subprocess.getoutput(
|
||||||
|
- "ps -A | grep {} | awk '{{print $1}}'".format(app)).split()
|
||||||
|
+ pid = subprocess.getoutput("ps -A")
|
||||||
|
+ app_processes = [line for line in pid.split('\n') if app in line]
|
||||||
|
+ pid = [line.split()[0] for line in app_processes]
|
||||||
|
app_pid_flag = True if pid else False
|
||||||
|
proc_flag.append(app_pid_flag)
|
||||||
|
if pid:
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
56
atune-collector-add-backup-for-apps.patch
Normal file
56
atune-collector-add-backup-for-apps.patch
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
From bfe9d212c518944678bbf526d61a8e778f378b41 Mon Sep 17 00:00:00 2001
|
||||||
|
From: gaoruoshu <gaoruoshu@huawei.com>
|
||||||
|
Date: Wed, 16 Aug 2023 12:36:46 +0800
|
||||||
|
Subject: [PATCH] [atune-collector]add backup for apps
|
||||||
|
|
||||||
|
---
|
||||||
|
atune_collector/plugin/configurator/mysql/mysql.py | 3 +++
|
||||||
|
atune_collector/plugin/configurator/nginx/nginx.py | 3 +++
|
||||||
|
atune_collector/plugin/configurator/redis/redis.py | 3 +++
|
||||||
|
3 files changed, 9 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/configurator/mysql/mysql.py b/atune_collector/plugin/configurator/mysql/mysql.py
|
||||||
|
index e472a1c..9badd21 100644
|
||||||
|
--- a/atune_collector/plugin/configurator/mysql/mysql.py
|
||||||
|
+++ b/atune_collector/plugin/configurator/mysql/mysql.py
|
||||||
|
@@ -81,6 +81,9 @@ class Mysql(Configurator):
|
||||||
|
def _get(self, key, _):
|
||||||
|
pass
|
||||||
|
|
||||||
|
+ def _backup(self, config, _):
|
||||||
|
+ return str(config)
|
||||||
|
+
|
||||||
|
@staticmethod
|
||||||
|
def check(config1, config2):
|
||||||
|
return True
|
||||||
|
diff --git a/atune_collector/plugin/configurator/nginx/nginx.py b/atune_collector/plugin/configurator/nginx/nginx.py
|
||||||
|
index 9d38dd0..7f7eaad 100644
|
||||||
|
--- a/atune_collector/plugin/configurator/nginx/nginx.py
|
||||||
|
+++ b/atune_collector/plugin/configurator/nginx/nginx.py
|
||||||
|
@@ -198,6 +198,9 @@ class Nginx(Configurator):
|
||||||
|
def _get(self, key, _):
|
||||||
|
pass
|
||||||
|
|
||||||
|
+ def _backup(self, config, _):
|
||||||
|
+ return str(config)
|
||||||
|
+
|
||||||
|
@staticmethod
|
||||||
|
def check(config1, config2):
|
||||||
|
return True
|
||||||
|
diff --git a/atune_collector/plugin/configurator/redis/redis.py b/atune_collector/plugin/configurator/redis/redis.py
|
||||||
|
index aa14bcd..44da99e 100644
|
||||||
|
--- a/atune_collector/plugin/configurator/redis/redis.py
|
||||||
|
+++ b/atune_collector/plugin/configurator/redis/redis.py
|
||||||
|
@@ -68,6 +68,9 @@ class Redis(Configurator):
|
||||||
|
def _get(self, key, _):
|
||||||
|
pass
|
||||||
|
|
||||||
|
+ def _backup(self, config, _):
|
||||||
|
+ return str(config)
|
||||||
|
+
|
||||||
|
@staticmethod
|
||||||
|
def check(config1, config2):
|
||||||
|
return True
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Name: atune-collector
|
Name: atune-collector
|
||||||
Version: 1.1.0
|
Version: 1.1.0
|
||||||
Release: 3
|
Release: 8
|
||||||
Summary: A-Tune-Collector is used to collect various system resources.
|
Summary: A-Tune-Collector is used to collect various system resources.
|
||||||
License: Mulan PSL v2
|
License: Mulan PSL v2
|
||||||
URL: https://gitee.com/openeuler/A-Tune-Collector
|
URL: https://gitee.com/openeuler/A-Tune-Collector
|
||||||
@ -19,9 +19,16 @@ Patch8: feature-set-redis-value.patch
|
|||||||
Patch9: feature-set-nginx.patch
|
Patch9: feature-set-nginx.patch
|
||||||
Patch10: bugfix-create-file-only-if-setting-params.patch
|
Patch10: bugfix-create-file-only-if-setting-params.patch
|
||||||
Patch11: change-import-behavior.patch
|
Patch11: change-import-behavior.patch
|
||||||
|
Patch12: atune-collector-add-backup-for-apps.patch
|
||||||
|
Patch13: feature-add-network-CPI.patch
|
||||||
|
Patch14: feature-add-multi-for-rps-xps.patch
|
||||||
|
Patch15: feature-add-rfs-to-network.patch
|
||||||
|
Patch16: fix-bug-procsched-report-list-index-out-of-range.patch
|
||||||
|
Patch17: fix-bug-procsched-data-collection-issue.patch
|
||||||
|
Patch18: CVE-2024-24897.patch
|
||||||
|
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
Requires: python3-dict2xml
|
Requires: python3-dict2xml python3-werkzeug
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The A-Tune-Collector is used to collect various system resources and can also be used as the collector of the A-Tune project.
|
The A-Tune-Collector is used to collect various system resources and can also be used as the collector of the A-Tune project.
|
||||||
@ -43,6 +50,21 @@ The A-Tune-Collector is used to collect various system resources and can also be
|
|||||||
%attr(0600,root,root) %{_sysconfdir}/atune_collector/*
|
%attr(0600,root,root) %{_sysconfdir}/atune_collector/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Mar 12 2024 zhoupengcheng <zhoupengcheng11@huawei.com> - 1.1.0-8
|
||||||
|
- fix CVE-2024-24897
|
||||||
|
|
||||||
|
* Fri Dec 15 2023 weiyaping <weiyaping@xfusion.com> - 1.1.0-7
|
||||||
|
- fix bug: ProcSched.report: list index out of range
|
||||||
|
|
||||||
|
* Wed Nov 29 2023 gaoruoshu <gaoruoshu@huawei.com> - 1.1.0-6
|
||||||
|
- feature: add rfs and rps/xps=multi to [network]
|
||||||
|
|
||||||
|
* Tue Aug 22 2023 gaoruoshu <gaoruoshu@huawei.com> - 1.1.0-5
|
||||||
|
- feature: add [network] to CPI
|
||||||
|
|
||||||
|
* Wed Aug 16 2023 gaoruoshu <gaoruoshu@huawei.com> - 1.1.0-4
|
||||||
|
- atune-collector: add backup for apps
|
||||||
|
|
||||||
* Tue Aug 01 2023 gaoruoshu <gaoruoshu@huawei.com> - 1.1.0-3
|
* Tue Aug 01 2023 gaoruoshu <gaoruoshu@huawei.com> - 1.1.0-3
|
||||||
- feature: enable application config
|
- feature: enable application config
|
||||||
|
|
||||||
|
|||||||
100
feature-add-multi-for-rps-xps.patch
Normal file
100
feature-add-multi-for-rps-xps.patch
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
From c2df28764f159163233cdab4fb34f62efe888c4e Mon Sep 17 00:00:00 2001
|
||||||
|
From: gaoruoshu <gaoruoshu@huawei.com>
|
||||||
|
Date: Mon, 27 Nov 2023 12:56:09 +0000
|
||||||
|
Subject: [PATCH 1/2] feature: add 'multi' for rps/xps
|
||||||
|
|
||||||
|
Signed-off-by: gaoruoshu <gaoruoshu@huawei.com>
|
||||||
|
---
|
||||||
|
.../plugin/configurator/network/network.py | 55 ++++++++++++++++++-
|
||||||
|
1 file changed, 52 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/configurator/network/network.py b/atune_collector/plugin/configurator/network/network.py
|
||||||
|
index 977f29c..afc31f2 100644
|
||||||
|
--- a/atune_collector/plugin/configurator/network/network.py
|
||||||
|
+++ b/atune_collector/plugin/configurator/network/network.py
|
||||||
|
@@ -35,8 +35,8 @@ class Network(Configurator):
|
||||||
|
|
||||||
|
def __init__(self, user=None):
|
||||||
|
Configurator.__init__(self, user)
|
||||||
|
- self._cmd_map = {'xps': ['all', 'off', 'half', 'separate'],
|
||||||
|
- 'rps': ['all', 'off', 'half', 'separate']}
|
||||||
|
+ self._cmd_map = {'xps': ['all', 'off', 'half', 'separate', 'multi'],
|
||||||
|
+ 'rps': ['all', 'off', 'half', 'separate', 'multi']}
|
||||||
|
self._nic = self._get_nic()
|
||||||
|
self._queue_dir = '/sys/class/net/{}/queues'.format(self._nic)
|
||||||
|
|
||||||
|
@@ -52,6 +52,12 @@ class Network(Configurator):
|
||||||
|
'Failed to get dir under {}'.format(self._queue_dir))
|
||||||
|
dir_list = re.findall(pattern, dir_strs)
|
||||||
|
core_num = os.cpu_count()
|
||||||
|
+
|
||||||
|
+ multi_qs = len(dir_list)
|
||||||
|
+ stride = 1 if core_num // multi_qs == 0 else core_num // multi_qs
|
||||||
|
+ stragglers = 0 if core_num <= multi_qs else core_num % multi_qs
|
||||||
|
+ cur_cpu = 0
|
||||||
|
+ dir_list = sorted(dir_list, key=lambda x: int(x.split('-')[1]))
|
||||||
|
for index, dir_name in enumerate(dir_list):
|
||||||
|
file_path = '{}/{}/{}_cpus'.format(self._queue_dir, dir_name, key)
|
||||||
|
shell_cmd(['cat', file_path],
|
||||||
|
@@ -75,14 +81,57 @@ class Network(Configurator):
|
||||||
|
offset = index % half_num
|
||||||
|
val_format = 1 << (offset + half_num + core_num % 2)
|
||||||
|
set_value = f"{val_format:x}"
|
||||||
|
- else: # value == 'separate'
|
||||||
|
+ elif value == 'separate':
|
||||||
|
num = 1 << (index % core_num)
|
||||||
|
set_value = f"{num:x}"
|
||||||
|
+ else: # value = multi:
|
||||||
|
+ str_value = ''
|
||||||
|
+ gsize = stride if index >= stragglers else stride + 1
|
||||||
|
+ for _ in range(gsize):
|
||||||
|
+ str_value = str(cur_cpu) + ' ' + str_value
|
||||||
|
+ cur_cpu += 1
|
||||||
|
+ set_value = self._u32list(str_value)
|
||||||
|
|
||||||
|
shell_cmd(['sh', '-c', 'echo {} > {}'.format(set_value, file_path)],
|
||||||
|
'Failed to set {} to {}'.format(key, file_path))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
+ @staticmethod
|
||||||
|
+ def _u32list(cpulist):
|
||||||
|
+ max_cpu = 0
|
||||||
|
+ ii = 0
|
||||||
|
+
|
||||||
|
+ for _cpu in cpulist.split():
|
||||||
|
+ if max_cpu < int(_cpu):
|
||||||
|
+ max_cpu = int(_cpu)
|
||||||
|
+
|
||||||
|
+ #init a bitmap
|
||||||
|
+ map = [0] * (max_cpu + 1)
|
||||||
|
+
|
||||||
|
+ # set bit map according to cpulist
|
||||||
|
+ for _cpu in cpulist.split():
|
||||||
|
+ map[int(_cpu)] = 1
|
||||||
|
+
|
||||||
|
+ #format a u32list
|
||||||
|
+ seg = 0
|
||||||
|
+ mask = ''
|
||||||
|
+ for ii in range(max_cpu + 1):
|
||||||
|
+ if ii % 4 == 0 and ii != 0:
|
||||||
|
+ seg = format(seg, 'x')
|
||||||
|
+ mask = seg + mask
|
||||||
|
+ seg = 0
|
||||||
|
+ if ii % 32 == 0 and ii != 0:
|
||||||
|
+ mask = ',' + mask
|
||||||
|
+ cur = map[ii]
|
||||||
|
+ if cur == 1:
|
||||||
|
+ val = 1 << (ii % 4)
|
||||||
|
+ seg += val
|
||||||
|
+
|
||||||
|
+ if seg != 0:
|
||||||
|
+ seg = format(seg, 'x')
|
||||||
|
+ mask = seg + mask
|
||||||
|
+ return mask
|
||||||
|
+
|
||||||
|
def _set(self, key, value):
|
||||||
|
if not key.lower() in self._cmd_map or not value.lower() in self._cmd_map[key.lower()]:
|
||||||
|
raise SetConfigError("Invalid value {}={}".format(key, value))
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
182
feature-add-network-CPI.patch
Normal file
182
feature-add-network-CPI.patch
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
From 148c57c3695080667e138425b1295e89197a241b Mon Sep 17 00:00:00 2001
|
||||||
|
From: gaoruoshu <gaoruoshu@huawei.com>
|
||||||
|
Date: Tue, 22 Aug 2023 15:07:50 +0800
|
||||||
|
Subject: [PATCH] feature: add [network] CPI
|
||||||
|
|
||||||
|
---
|
||||||
|
.../plugin/configurator/__init__.py | 2 +
|
||||||
|
.../plugin/configurator/network/__init__.py | 21 ++++
|
||||||
|
.../plugin/configurator/network/network.py | 113 ++++++++++++++++++
|
||||||
|
3 files changed, 136 insertions(+)
|
||||||
|
create mode 100644 atune_collector/plugin/configurator/network/__init__.py
|
||||||
|
create mode 100644 atune_collector/plugin/configurator/network/network.py
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/configurator/__init__.py b/atune_collector/plugin/configurator/__init__.py
|
||||||
|
index fd7ea63..46cff84 100755
|
||||||
|
--- a/atune_collector/plugin/configurator/__init__.py
|
||||||
|
+++ b/atune_collector/plugin/configurator/__init__.py
|
||||||
|
@@ -22,6 +22,7 @@ from .bios import *
|
||||||
|
from .bootloader import *
|
||||||
|
from .file_config import *
|
||||||
|
from .kernel_config import *
|
||||||
|
+from .network import *
|
||||||
|
from .script import *
|
||||||
|
from .sysctl import *
|
||||||
|
from .sysfs import *
|
||||||
|
@@ -37,6 +38,7 @@ __all__ = ["exceptions",
|
||||||
|
"bootloader",
|
||||||
|
"file_config",
|
||||||
|
"kernel_config",
|
||||||
|
+ "network",
|
||||||
|
"script",
|
||||||
|
"sysctl",
|
||||||
|
"sysfs",
|
||||||
|
diff --git a/atune_collector/plugin/configurator/network/__init__.py b/atune_collector/plugin/configurator/network/__init__.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..088e459
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/atune_collector/plugin/configurator/network/__init__.py
|
||||||
|
@@ -0,0 +1,21 @@
|
||||||
|
+#!/usr/bin/python3
|
||||||
|
+# -*- coding: utf-8 -*-
|
||||||
|
+# Copyright (c) 2019 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: 2023-08-22
|
||||||
|
+
|
||||||
|
+"""
|
||||||
|
+Init file.
|
||||||
|
+"""
|
||||||
|
+
|
||||||
|
+__all__ = ["network"]
|
||||||
|
+
|
||||||
|
+from . import network
|
||||||
|
+
|
||||||
|
diff --git a/atune_collector/plugin/configurator/network/network.py b/atune_collector/plugin/configurator/network/network.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..977f29c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/atune_collector/plugin/configurator/network/network.py
|
||||||
|
@@ -0,0 +1,113 @@
|
||||||
|
+#!/usr/bin/python3
|
||||||
|
+# -*- coding: utf-8 -*-
|
||||||
|
+# Copyright (c) 2019 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: 2023-08-22
|
||||||
|
+
|
||||||
|
+"""
|
||||||
|
+The sub class of the Configurator, used to extend script for network for CPI.
|
||||||
|
+"""
|
||||||
|
+
|
||||||
|
+import re
|
||||||
|
+import logging
|
||||||
|
+import os
|
||||||
|
+import math
|
||||||
|
+import configparser
|
||||||
|
+import subprocess
|
||||||
|
+
|
||||||
|
+from ..exceptions import SetConfigError
|
||||||
|
+from ..common import Configurator
|
||||||
|
+
|
||||||
|
+LOGGER = logging.getLogger(__name__)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+class Network(Configurator):
|
||||||
|
+ _module = "NETWORK"
|
||||||
|
+ _submod = "NETWORK"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ def __init__(self, user=None):
|
||||||
|
+ Configurator.__init__(self, user)
|
||||||
|
+ self._cmd_map = {'xps': ['all', 'off', 'half', 'separate'],
|
||||||
|
+ 'rps': ['all', 'off', 'half', 'separate']}
|
||||||
|
+ self._nic = self._get_nic()
|
||||||
|
+ self._queue_dir = '/sys/class/net/{}/queues'.format(self._nic)
|
||||||
|
+
|
||||||
|
+ def _get_nic(self):
|
||||||
|
+ if not os.path.isfile('/etc/atuned/atuned.cnf'):
|
||||||
|
+ raise SetConfigError('Cannot get network name')
|
||||||
|
+ config = configparser.ConfigParser()
|
||||||
|
+ config.read('/etc/atuned/atuned.cnf')
|
||||||
|
+ return config.get('system', 'network')
|
||||||
|
+
|
||||||
|
+ def _set_cpus(self, key, value, pattern):
|
||||||
|
+ dir_strs = shell_cmd(['ls', self._queue_dir],
|
||||||
|
+ 'Failed to get dir under {}'.format(self._queue_dir))
|
||||||
|
+ dir_list = re.findall(pattern, dir_strs)
|
||||||
|
+ core_num = os.cpu_count()
|
||||||
|
+ for index, dir_name in enumerate(dir_list):
|
||||||
|
+ file_path = '{}/{}/{}_cpus'.format(self._queue_dir, dir_name, key)
|
||||||
|
+ shell_cmd(['cat', file_path],
|
||||||
|
+ 'Failed to set {}={}: does not support for {}'.format(key, value, key))
|
||||||
|
+
|
||||||
|
+ if value == 'off':
|
||||||
|
+ set_value = '0'
|
||||||
|
+ elif value == 'all':
|
||||||
|
+ set_value = 'f' * (core_num // 4)
|
||||||
|
+ if core_num % 4 != 0:
|
||||||
|
+ bin_num = int('0b' + '1' * (core_num % 4), 2)
|
||||||
|
+ set_value = f"{bin_num:x}" + set_value
|
||||||
|
+ elif value == 'half':
|
||||||
|
+ half_num = core_num // 2
|
||||||
|
+ if core_num == 1:
|
||||||
|
+ val_format = 1
|
||||||
|
+ elif key == 'rps':
|
||||||
|
+ offset = index % (half_num + core_num % 2)
|
||||||
|
+ val_format = 1 << offset
|
||||||
|
+ else:
|
||||||
|
+ offset = index % half_num
|
||||||
|
+ val_format = 1 << (offset + half_num + core_num % 2)
|
||||||
|
+ set_value = f"{val_format:x}"
|
||||||
|
+ else: # value == 'separate'
|
||||||
|
+ num = 1 << (index % core_num)
|
||||||
|
+ set_value = f"{num:x}"
|
||||||
|
+
|
||||||
|
+ shell_cmd(['sh', '-c', 'echo {} > {}'.format(set_value, file_path)],
|
||||||
|
+ 'Failed to set {} to {}'.format(key, file_path))
|
||||||
|
+ return 0
|
||||||
|
+
|
||||||
|
+ def _set(self, key, value):
|
||||||
|
+ if not key.lower() in self._cmd_map or not value.lower() in self._cmd_map[key.lower()]:
|
||||||
|
+ raise SetConfigError("Invalid value {}={}".format(key, value))
|
||||||
|
+
|
||||||
|
+ if key == 'xps':
|
||||||
|
+ self._set_cpus(key.lower(), value.lower(), r'tx-\d+')
|
||||||
|
+ elif key == 'rps':
|
||||||
|
+ self._set_cpus(key.lower(), value.lower(), r'rx-\d+')
|
||||||
|
+
|
||||||
|
+ return 0
|
||||||
|
+
|
||||||
|
+ def _get(self, key, _):
|
||||||
|
+ pass
|
||||||
|
+
|
||||||
|
+ def _backup(self, config, _):
|
||||||
|
+ return str(config)
|
||||||
|
+
|
||||||
|
+ @staticmethod
|
||||||
|
+ def check(config1, config2):
|
||||||
|
+ return True
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def shell_cmd(cmd, error_message):
|
||||||
|
+ output = subprocess.run(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
+ if output.returncode != 0:
|
||||||
|
+ raise SetConfigError(error_message)
|
||||||
|
+ return output.stdout.decode()
|
||||||
|
+
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
132
feature-add-rfs-to-network.patch
Normal file
132
feature-add-rfs-to-network.patch
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
From abc01d60cc574b27b943f2d619f0b3cca8f6e1c6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: gaoruoshu <gaoruoshu@huawei.com>
|
||||||
|
Date: Tue, 28 Nov 2023 03:35:26 +0000
|
||||||
|
Subject: [PATCH 2/2] feature: add rfs to network
|
||||||
|
|
||||||
|
Signed-off-by: gaoruoshu <gaoruoshu@huawei.com>
|
||||||
|
---
|
||||||
|
.../plugin/configurator/network/network.py | 56 +++++++++++++++----
|
||||||
|
1 file changed, 44 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/configurator/network/network.py b/atune_collector/plugin/configurator/network/network.py
|
||||||
|
index afc31f2..01e5640 100644
|
||||||
|
--- a/atune_collector/plugin/configurator/network/network.py
|
||||||
|
+++ b/atune_collector/plugin/configurator/network/network.py
|
||||||
|
@@ -36,7 +36,8 @@ class Network(Configurator):
|
||||||
|
def __init__(self, user=None):
|
||||||
|
Configurator.__init__(self, user)
|
||||||
|
self._cmd_map = {'xps': ['all', 'off', 'half', 'separate', 'multi'],
|
||||||
|
- 'rps': ['all', 'off', 'half', 'separate', 'multi']}
|
||||||
|
+ 'rps': ['all', 'off', 'half', 'separate', 'multi'],
|
||||||
|
+ 'rfs': ['on', 'off']}
|
||||||
|
self._nic = self._get_nic()
|
||||||
|
self._queue_dir = '/sys/class/net/{}/queues'.format(self._nic)
|
||||||
|
|
||||||
|
@@ -47,17 +48,21 @@ class Network(Configurator):
|
||||||
|
config.read('/etc/atuned/atuned.cnf')
|
||||||
|
return config.get('system', 'network')
|
||||||
|
|
||||||
|
- def _set_cpus(self, key, value, pattern):
|
||||||
|
+ def _get_init(self, pattern):
|
||||||
|
dir_strs = shell_cmd(['ls', self._queue_dir],
|
||||||
|
'Failed to get dir under {}'.format(self._queue_dir))
|
||||||
|
dir_list = re.findall(pattern, dir_strs)
|
||||||
|
+ dir_list = sorted(dir_list, key=lambda x: int(x.split('-')[1]))
|
||||||
|
core_num = os.cpu_count()
|
||||||
|
+ return dir_list, core_num
|
||||||
|
+
|
||||||
|
+ def _set_cpus(self, key, value, pattern):
|
||||||
|
+ dir_list, core_num = self._get_init(pattern)
|
||||||
|
|
||||||
|
multi_qs = len(dir_list)
|
||||||
|
stride = 1 if core_num // multi_qs == 0 else core_num // multi_qs
|
||||||
|
stragglers = 0 if core_num <= multi_qs else core_num % multi_qs
|
||||||
|
cur_cpu = 0
|
||||||
|
- dir_list = sorted(dir_list, key=lambda x: int(x.split('-')[1]))
|
||||||
|
for index, dir_name in enumerate(dir_list):
|
||||||
|
file_path = '{}/{}/{}_cpus'.format(self._queue_dir, dir_name, key)
|
||||||
|
shell_cmd(['cat', file_path],
|
||||||
|
@@ -84,13 +89,15 @@ class Network(Configurator):
|
||||||
|
elif value == 'separate':
|
||||||
|
num = 1 << (index % core_num)
|
||||||
|
set_value = f"{num:x}"
|
||||||
|
- else: # value = multi:
|
||||||
|
- str_value = ''
|
||||||
|
+ elif value == 'multi': # value = multi:
|
||||||
|
+ list_cpu = []
|
||||||
|
gsize = stride if index >= stragglers else stride + 1
|
||||||
|
for _ in range(gsize):
|
||||||
|
- str_value = str(cur_cpu) + ' ' + str_value
|
||||||
|
+ list_cpu.append(cur_cpu)
|
||||||
|
cur_cpu += 1
|
||||||
|
- set_value = self._u32list(str_value)
|
||||||
|
+ set_value = self._u32list(list_cpu)
|
||||||
|
+ else:
|
||||||
|
+ raise SetConfigError("cannot set {} to {}".format(key, value))
|
||||||
|
|
||||||
|
shell_cmd(['sh', '-c', 'echo {} > {}'.format(set_value, file_path)],
|
||||||
|
'Failed to set {} to {}'.format(key, file_path))
|
||||||
|
@@ -101,16 +108,15 @@ class Network(Configurator):
|
||||||
|
max_cpu = 0
|
||||||
|
ii = 0
|
||||||
|
|
||||||
|
- for _cpu in cpulist.split():
|
||||||
|
- if max_cpu < int(_cpu):
|
||||||
|
- max_cpu = int(_cpu)
|
||||||
|
+ for _cpu in cpulist:
|
||||||
|
+ max_cpu = max(max_cpu, _cpu)
|
||||||
|
|
||||||
|
#init a bitmap
|
||||||
|
map = [0] * (max_cpu + 1)
|
||||||
|
|
||||||
|
# set bit map according to cpulist
|
||||||
|
- for _cpu in cpulist.split():
|
||||||
|
- map[int(_cpu)] = 1
|
||||||
|
+ for _cpu in cpulist:
|
||||||
|
+ map[_cpu] = 1
|
||||||
|
|
||||||
|
#format a u32list
|
||||||
|
seg = 0
|
||||||
|
@@ -131,6 +137,30 @@ class Network(Configurator):
|
||||||
|
seg = format(seg, 'x')
|
||||||
|
mask = seg + mask
|
||||||
|
return mask
|
||||||
|
+
|
||||||
|
+ def _set_rfs(self, value, pattern):
|
||||||
|
+ dir_list, _ = self._get_init(pattern)
|
||||||
|
+ for dir_name in dir_list:
|
||||||
|
+ file_path = '{}/{}/rps_flow_cnt'.format(self._queue_dir, dir_name)
|
||||||
|
+ shell_cmd(['cat', file_path],
|
||||||
|
+ 'Failed to set rfs={}: does not support for rfs'.format(value))
|
||||||
|
+ if value == 'off':
|
||||||
|
+ set_value = 0
|
||||||
|
+ elif value == 'on':
|
||||||
|
+ set_value = 4096
|
||||||
|
+ else:
|
||||||
|
+ raise SetConfigError("cannot set rfs to {}".format(value))
|
||||||
|
+ shell_cmd(['sh', '-c', 'echo {} > {}'.format(set_value, file_path)],
|
||||||
|
+ 'Failed to set rfs to {}'.format(file_path))
|
||||||
|
+
|
||||||
|
+ if value == 'off':
|
||||||
|
+ entries = 0
|
||||||
|
+ elif value == 'on':
|
||||||
|
+ entries = 4096 * len(dir_list)
|
||||||
|
+ entries_path = '/proc/sys/net/core/rps_sock_flow_entries'
|
||||||
|
+ shell_cmd(['sh', '-c', 'echo {} > {}'.format(entries, entries_path)],
|
||||||
|
+ 'Failed to set rfs to {}'.format(entries_path))
|
||||||
|
+ return 0
|
||||||
|
|
||||||
|
def _set(self, key, value):
|
||||||
|
if not key.lower() in self._cmd_map or not value.lower() in self._cmd_map[key.lower()]:
|
||||||
|
@@ -140,6 +170,8 @@ class Network(Configurator):
|
||||||
|
self._set_cpus(key.lower(), value.lower(), r'tx-\d+')
|
||||||
|
elif key == 'rps':
|
||||||
|
self._set_cpus(key.lower(), value.lower(), r'rx-\d+')
|
||||||
|
+ elif key == 'rfs':
|
||||||
|
+ self._set_rfs(value.lower(), r'rx-\d+')
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
56
fix-bug-procsched-data-collection-issue.patch
Normal file
56
fix-bug-procsched-data-collection-issue.patch
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
From 43c7e8eb00268570abbaeacbb2689079dddec63d Mon Sep 17 00:00:00 2001
|
||||||
|
From: weiyaping <weiyaping@xfusion.com>
|
||||||
|
Date: Fri, 15 Dec 2023 03:50:06 -0500
|
||||||
|
Subject: [PATCH] fix-bug-procsched-data-collection-issue
|
||||||
|
|
||||||
|
---
|
||||||
|
atune_collector/plugin/monitor/process/sched.py | 27 ++++++++++++++++---------
|
||||||
|
1 file changed, 17 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/monitor/process/sched.py b/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
index f184957..0fadeba 100644
|
||||||
|
--- a/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
+++ b/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
@@ -107,7 +107,7 @@ class ProcSched(Monitor):
|
||||||
|
continue
|
||||||
|
|
||||||
|
pattern = re.compile(
|
||||||
|
- r"(\w+)\ {1,}\:\ {1,}(\d+.\d+)",
|
||||||
|
+ r"(\w+)\ {1,}\:\ {1,}(\d+\.?\d*)",
|
||||||
|
re.I | re.UNICODE | re.MULTILINE)
|
||||||
|
search_obj = pattern.findall(info)
|
||||||
|
search_list = []
|
||||||
|
@@ -118,13 +118,20 @@ class ProcSched(Monitor):
|
||||||
|
search_list.append(obj[0])
|
||||||
|
search_list.append(obj[1])
|
||||||
|
if len(search_obj) == 0:
|
||||||
|
- err = LookupError("Fail to find data")
|
||||||
|
- LOGGER.error("%s.%s: %s", self.__class__.__name__,
|
||||||
|
- inspect.stack()[0][3], str(err))
|
||||||
|
- raise err
|
||||||
|
+ return " " + " ".join(['0'] * len(keys))
|
||||||
|
+ proc_data = []
|
||||||
|
+ proc_keys = 0
|
||||||
|
+ proc_step = len(set(keys))
|
||||||
|
|
||||||
|
- while start <= len(self.__applications) * len(keys):
|
||||||
|
- for key in keys:
|
||||||
|
- ret = ret + " " + search_list[search_list.index(key, start)+1]
|
||||||
|
- start = search_list.index(key, start) + 1
|
||||||
|
- return ret
|
||||||
|
\ No newline at end of file
|
||||||
|
+ for key in keys:
|
||||||
|
+ if len(proc_data) >= self.__proc_flag.count(True) * proc_step:
|
||||||
|
+ break
|
||||||
|
+ proc_data.append(search_list[search_list.index(key, start) + 1])
|
||||||
|
+ start = search_list.index(key, start) + 1
|
||||||
|
+ for pid_flag in self.__proc_flag:
|
||||||
|
+ if not pid_flag:
|
||||||
|
+ ret = ret + " " + " ".join(['0'] * proc_step)
|
||||||
|
+ else:
|
||||||
|
+ ret = ret + " " + " ".join(proc_data[proc_keys:(proc_keys + proc_step)])
|
||||||
|
+ proc_keys += proc_step
|
||||||
|
+ return ret
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
45
fix-bug-procsched-report-list-index-out-of-range.patch
Normal file
45
fix-bug-procsched-report-list-index-out-of-range.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From 009428bbf8f38bf9754999ec77403c4b181cf8ed Mon Sep 17 00:00:00 2001
|
||||||
|
From: weiyaping <weiyaping@xfusion.com>
|
||||||
|
Date: Fri, 15 Dec 2023 03:37:02 -0500
|
||||||
|
Subject: [PATCH] fix bug:ProcSched.report: list index out of range
|
||||||
|
|
||||||
|
---
|
||||||
|
atune_collector/plugin/monitor/process/sched.py | 10 ++++++++--
|
||||||
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/atune_collector/plugin/monitor/process/sched.py b/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
index 5289d84..f184957 100644
|
||||||
|
--- a/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
+++ b/atune_collector/plugin/monitor/process/sched.py
|
||||||
|
@@ -36,10 +36,12 @@ class ProcSched(Monitor):
|
||||||
|
self.__interval = 1
|
||||||
|
self.__applications = []
|
||||||
|
self.__pids = []
|
||||||
|
+ self.__proc_flag = []
|
||||||
|
|
||||||
|
def _get(self, para=None):
|
||||||
|
output = ""
|
||||||
|
pids = []
|
||||||
|
+ proc_flag = []
|
||||||
|
if para is not None:
|
||||||
|
opts, _ = getopt.getopt(para.split(), None, ['interval=', 'app='])
|
||||||
|
for opt, val in opts:
|
||||||
|
@@ -67,9 +69,13 @@ class ProcSched(Monitor):
|
||||||
|
|
||||||
|
for app in self.__applications:
|
||||||
|
pid = subprocess.getoutput(
|
||||||
|
- "ps -A | grep {} | awk '{{print $1}}'".format(app)).split()[0]
|
||||||
|
- pids.append(pid)
|
||||||
|
+ "ps -A | grep {} | awk '{{print $1}}'".format(app)).split()
|
||||||
|
+ app_pid_flag = True if pid else False
|
||||||
|
+ proc_flag.append(app_pid_flag)
|
||||||
|
+ if pid:
|
||||||
|
+ pids.append(pid[0])
|
||||||
|
self.__pids = pids
|
||||||
|
+ self.__proc_flag = proc_flag
|
||||||
|
|
||||||
|
for pid in self.__pids:
|
||||||
|
out = subprocess.check_output(
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user