File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
CURVEFS_TOOL = "curvefs_tool"
13
13
JSON_PATH = "/tmp/topology.json"
14
+ PLUGIN_PATH = "plugin"
14
15
HOSTNAME_PORT_REGEX = r"[^\"\ ]\S*:\d+"
15
16
IP_PORT_REGEX = r"[0-9]+(?:\.[0-9]+){3}:\d+"
16
17
@@ -97,6 +98,16 @@ def unitValue(lables, targets):
97
98
unit ["targets" ] = targets
98
99
return unit
99
100
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
100
111
101
112
def refresh ():
102
113
targets = []
@@ -113,6 +124,8 @@ def refresh():
113
124
# load client
114
125
client = loadClient ()
115
126
targets .append (client )
127
+ plugin = loadPlugin ()
128
+ targets += plugin
116
129
117
130
with open (targetPath + '.new' , 'w' , 0o777 ) as fd :
118
131
json .dump (targets , fd , indent = 4 )
You can’t perform that action at this time.
0 commit comments