Skip to content

Commit 7819a31

Browse files
committed
[feat]curvefs/monitor: support plugin
Signed-off-by: Cyber-SiKu <Cyber-SiKu@outlook.com>
1 parent 5f76eaf commit 7819a31

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

curvefs/monitor/target_json.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
CURVEFS_TOOL = "curvefs_tool"
1313
JSON_PATH = "/tmp/topology.json"
14+
PLUGIN_PATH = "plugin"
1415
HOSTNAME_PORT_REGEX = r"[^\"\ ]\S*:\d+"
1516
IP_PORT_REGEX = r"[0-9]+(?:\.[0-9]+){3}:\d+"
1617

@@ -97,6 +98,16 @@ def unitValue(lables, targets):
9798
unit["targets"] = targets
9899
return unit
99100

101+
def loadPlugin():
102+
# load *.json file in plugin dir
103+
# merge to one json
104+
data = []
105+
for filename in os.listdir(PLUGIN_PATH):
106+
if filename.endswith('.json'):
107+
with open(os.path.join(PLUGIN_PATH, filename)) as f:
108+
plugin_data = json.load(f)
109+
data.append(unitValue(plugin_data["labels"], plugin_data["targets"])
110+
return data
100111

101112
def refresh():
102113
targets = []
@@ -113,6 +124,8 @@ def refresh():
113124
# load client
114125
client = loadClient()
115126
targets.append(client)
127+
plugin = loadPlugin()
128+
targets += plugin
116129

117130
with open(targetPath+'.new', 'w', 0o777) as fd:
118131
json.dump(targets, fd, indent=4)

0 commit comments

Comments
 (0)