From 1cc37ec84e68c6b86f9c8c466b9c93ee2341727e Mon Sep 17 00:00:00 2001 From: 尹姜谊 Date: Wed, 17 Apr 2024 15:26:34 +0800 Subject: Fix: 修复监控问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detection/knowledgebase_monitor.py | 4 ++-- detection/tool/KnowledgeBaseTool.py | 4 +++- .../tool/__pycache__/KnowledgeBaseTool.cpython-39.pyc | Bin 3521 -> 3537 bytes 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/detection/knowledgebase_monitor.py b/detection/knowledgebase_monitor.py index 5dd2e83..0a0dbb9 100644 --- a/detection/knowledgebase_monitor.py +++ b/detection/knowledgebase_monitor.py @@ -176,12 +176,12 @@ if __name__ == '__main__': end_time = datetime.datetime.now().strftime("%Y-%m-%d %H:00:00") start_time = (datetime.datetime.now() - datetime.timedelta(hours=recent_interval)).strftime("%Y-%m-%d %H:00:00") - monitor_result_dict.update(monitor.calculate_vpn_monitor_recent_mode(vpn_service=None)) + monitor_result_dict.update(monitor.calculate_vpn_monitor_recent_mode(vpn_service=None, recent_interval_h=recent_interval)) vpn_service_name_list = [] for plugin_name in config_dict: if 'vpn' in plugin_name and 'vpn_service_name' in config_dict[plugin_name]: vpn_service_name = config_dict[plugin_name]['vpn_service_name'] - monitor_result_dict.update(monitor.calculate_vpn_monitor_recent_mode(vpn_service=vpn_service_name)) + monitor_result_dict.update(monitor.calculate_vpn_monitor_recent_mode(vpn_service=vpn_service_name, recent_interval_h=recent_interval)) # save to prom file monitor_file = monitor.monitor_config['monitor_file_path'] diff --git a/detection/tool/KnowledgeBaseTool.py b/detection/tool/KnowledgeBaseTool.py index bdf6328..a8079d4 100644 --- a/detection/tool/KnowledgeBaseTool.py +++ b/detection/tool/KnowledgeBaseTool.py @@ -102,12 +102,14 @@ class KnowledgeApi: def get_knowledgebase_count(self, knowledge_id, page_size=None, page_no=None, q=None): url = 'http://' + self.api_address + '/v1/knowledgeBase/' + str(knowledge_id) + q = quote(q, 'utf-8') param = { - "q": quote(q, 'utf-8'), "pageNo": page_no, "pageSize": page_size } + url += ('?q=' + q) + header = { "Cn-Authorization": self.api_token } diff --git a/detection/tool/__pycache__/KnowledgeBaseTool.cpython-39.pyc b/detection/tool/__pycache__/KnowledgeBaseTool.cpython-39.pyc index 82af915..87a4e19 100644 Binary files a/detection/tool/__pycache__/KnowledgeBaseTool.cpython-39.pyc and b/detection/tool/__pycache__/KnowledgeBaseTool.cpython-39.pyc differ -- cgit v1.2.3