File tree Expand file tree Collapse file tree 2 files changed +15
-14
lines changed Expand file tree Collapse file tree 2 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,19 @@ async def get(self):
47
47
48
48
metrics = {"rss" : rss , "limits" : limits }
49
49
50
- # Always get cpu usage information
51
- cpu_count = psutil .cpu_count ()
52
- cpu_percent = await self ._get_cpu_percent (all_processes )
53
-
54
- if config .cpu_limit != 0 :
55
- limits ["cpu" ] = {"cpu" : config .cpu_limit }
56
- if config .cpu_warning_threshold != 0 :
57
- limits ["cpu" ]["warn" ] = (config .cpu_limit - cpu_percent ) < (
58
- config .cpu_limit * config .cpu_warning_threshold
59
- )
60
-
61
- metrics .update (cpu_percent = cpu_percent , cpu_count = cpu_count )
50
+ # Optionally get CPU information
51
+ if config .track_cpu_percent :
52
+ cpu_count = psutil .cpu_count ()
53
+ cpu_percent = await self ._get_cpu_percent (all_processes )
54
+
55
+ if config .cpu_limit != 0 :
56
+ limits ["cpu" ] = {"cpu" : config .cpu_limit }
57
+ if config .cpu_warning_threshold != 0 :
58
+ limits ["cpu" ]["warn" ] = (config .cpu_limit - cpu_percent ) < (
59
+ config .cpu_limit * config .cpu_warning_threshold
60
+ )
61
+
62
+ metrics .update (cpu_percent = cpu_percent , cpu_count = cpu_count )
62
63
63
64
self .write (json .dumps (metrics ))
64
65
Original file line number Diff line number Diff line change @@ -87,9 +87,9 @@ def _mem_limit_default(self):
87
87
return int (os .environ .get ("MEM_LIMIT" , 0 ))
88
88
89
89
track_cpu_percent = Bool (
90
- default_value = False ,
90
+ default_value = True ,
91
91
help = """
92
- Set to True in order to enable reporting of CPU usage statistics.
92
+ Set to False in order to disable reporting of CPU usage statistics.
93
93
""" ,
94
94
).tag (config = True )
95
95
You can’t perform that action at this time.
0 commit comments