From f9ca5d8ad986bc6add1c3f1a5544c710529ed524 Mon Sep 17 00:00:00 2001 From: Cyber-SiKu Date: Fri, 27 Oct 2023 10:27:12 +0800 Subject: [PATCH] [fix]curvefs/monitor: target_json.py Signed-off-by: Cyber-SiKu --- curvefs/monitor/target_json.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/curvefs/monitor/target_json.py b/curvefs/monitor/target_json.py index ebb726229d..1447219f84 100644 --- a/curvefs/monitor/target_json.py +++ b/curvefs/monitor/target_json.py @@ -102,11 +102,14 @@ def loadPlugin(): # load *.json file in plugin dir # merge to one json data = [] - for filename in os.listdir(PLUGIN_PATH): - if filename.endswith('.json'): - with open(os.path.join(PLUGIN_PATH, filename)) as f: - plugin_data = json.load(f) - data.append(unitValue(plugin_data["labels"], plugin_data["targets"]) + if os.path.isdir(PLUGIN_PATH): + for filename in os.listdir(PLUGIN_PATH): + if filename.endswith('.json'): + with open(os.path.join(PLUGIN_PATH, filename)) as f: + plugin_data = json.load(f) + if len(plugin_data) == 0: + continue + data.append(unitValue(plugin_data["labels"], plugin_data["targets"])) return data def refresh():