File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ def first_lvl_du():
87
87
try :
88
88
dirs = os .listdir (MONITOR_FIRSTLVL_DIR )
89
89
except Exception as e :
90
- general_logger .warn (f"Failed to listdir of { MONITOR_FIRSTLVL_DIR } : { str (e )} " )
90
+ general_logger .warning (f"Failed to listdir of { MONITOR_FIRSTLVL_DIR } : { str (e )} " )
91
91
return
92
92
93
93
for dir in dirs :
@@ -99,7 +99,7 @@ def first_lvl_du():
99
99
size_b , * _ = result .stdout .split ("\t " )
100
100
Singleton .cached_du [dir ] = int (size_b )
101
101
except Exception as e :
102
- general_logger .warn (f"Failed to check du of { str (path_to_dir )} : { str (e )} " )
102
+ general_logger .warning (f"Failed to check du of { str (path_to_dir )} : { str (e )} " )
103
103
104
104
@staticmethod
105
105
@cron .minutely
@@ -199,6 +199,20 @@ def refresh_metric():
199
199
200
200
def on_startup ():
201
201
"""On startup"""
202
+
203
+ # Set cached_metrics first
204
+ # Populating metrics takes a while
205
+
206
+ from prometheus_client import Gauge , CollectorRegistry , generate_latest
207
+ registry = CollectorRegistry ()
208
+ common_kwargs = {
209
+ 'registry' :registry ,
210
+ 'namespace' :NAME_SPACE ,
211
+ }
212
+ last_pinged = Gauge ("last_pinged" , "Last pinged time" , labelnames = [], ** common_kwargs )
213
+ last_pinged .set_to_current_time ()
214
+ Singleton .cached_metrics = generate_latest (registry )
215
+
202
216
cron .start ()
203
217
204
218
You can’t perform that action at this time.
0 commit comments