Skip to content

Commit 733ff0e

Browse files
committed
Possible fix for race condition where fullmem cannot be read
1 parent d303825 commit 733ff0e

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

treecript/collector.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def analyse_list_of_processes(
156156
attrs=[
157157
"name",
158158
"cpu_times",
159-
"memory_full_info",
160159
"net_connections",
161160
"pid",
162161
"cpu_percent",
@@ -168,6 +167,8 @@ def analyse_list_of_processes(
168167
"status",
169168
"io_counters",
170169
"ppid",
170+
"memory_info",
171+
"memory_full_info",
171172
],
172173
)
173174

@@ -595,13 +596,18 @@ def process_metrics_collector(
595596
tcp_connections += 1
596597

597598
c_cpu = child_d["cpu_times"]
598-
c_mem = child_d["memory_full_info"]
599+
c_mem = child_d["memory_info"]
600+
c_mem_vms = c_mem.vms
601+
c_mem_rss = c_mem.rss
602+
c_full_mem = child_d["memory_full_info"]
603+
c_full_mem_uss = c_full_mem.uss
604+
c_full_mem_swap = c_full_mem.swap
599605
c_io = child_d["io_counters"]
600606
metrics = (
601607
timestamp_str,
602608
child_pid_str,
603-
str(c_mem.vms),
604-
str(c_mem.rss),
609+
str(c_mem_vms),
610+
str(c_mem_rss),
605611
str(child_d["cpu_percent"]),
606612
str(child_d["memory_percent"]),
607613
str(tcp_connections),
@@ -611,8 +617,8 @@ def process_metrics_collector(
611617
str(c_cpu.children_user),
612618
str(c_cpu.children_system),
613619
str(c_cpu.iowait),
614-
str(c_mem.uss),
615-
str(c_mem.swap),
620+
str(c_full_mem_uss),
621+
str(c_full_mem_swap),
616622
str(len(child_d["threads_processor_num"])),
617623
str(len(child_d["threads_core_num"])),
618624
str(len(child_d["threads_cpu_num"])),
@@ -633,8 +639,8 @@ def process_metrics_collector(
633639
unique_processors.update(child_d["threads_processor_num"])
634640
unique_cores.update(child_d["threads_core_num"])
635641
unique_cpus.update(child_d["threads_cpu_num"])
636-
sumuss += c_mem.uss
637-
sumswap += c_mem.swap
642+
sumuss += c_full_mem_uss
643+
sumswap += c_full_mem_swap
638644
sumthreads += child_d["num_threads"]
639645
sum_read_count += c_io.read_count
640646
sum_write_count += c_io.write_count

0 commit comments

Comments
 (0)