From a3c4113d839ad12325f1245605aca35b5c0ec68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=92=90?= Date: Tue, 27 Feb 2024 16:52:52 +0800 Subject: [PATCH] Add get net offload information function to get_net_info.py --- category/get_net_info.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/category/get_net_info.py b/category/get_net_info.py index b882696..9a50202 100644 --- a/category/get_net_info.py +++ b/category/get_net_info.py @@ -85,6 +85,29 @@ class NetInfo: split = '=' if i == len(res_list)-1 else '-' res += FileOperation.wrap_output_format(cmd_name, cmd_result, split) return Command.cmd_write_file(res, self.__default_file_name) + + def __get_eth_off_info(self): + ''' + get net offload information + ''' + cmd_name = "ethtool" + res = '' + res_list = [] + + for i, device in enumerate(self.__netdevice): + type = self.__netdevice[device] + if type == 'ethernet' and self.__link_status[device] == 'yes': + cmd_result = Command.cmd_run("ethtool -k " + device) + res_list.append(cmd_result) + cmd_result = Command.cmd_run("ethtool -c " + device) + res_list.append(cmd_result) + + #wrap result + for i,cmd_result in enumerate(res_list): + split = '=' if i == len(res_list)-1 else '-' + res += FileOperation.wrap_output_format(cmd_name, cmd_result, split) + + return Command.cmd_write_file(res, self.__default_file_name) def get_info(self): ''' @@ -92,4 +115,6 @@ class NetInfo: ''' if not self.__get_devices(): return False - self.__get_devices_info() \ No newline at end of file + self.__get_devices_info() + self.__get_eth_off_info() + \ No newline at end of file -- Gitee