Malcolm is a powerful, easily deployable network traffic analysis tool suite for full packet capture artifacts (PCAP files), Zeek logs and Suricata alerts.
cpu = 0
mem = 0
cpu_mem = stats_api.get_namespaced_custom_object(
"metrics.k8s.io", "v1beta1", namespace, "pods", pod_name
)
for c in cpu_mem['containers']:
if c['usage']['cpu'] == '0':
pass
else:
cpu = +int(c['usage']['cpu'][:-1])
cpu = str(cpu) + 'n'
cpu = _nanocore_to_millicore(cpu)
for m in cpu_mem['containers']:
mem = +int(m['usage']['memory'][:-2])
mem = str(mem) + 'Ki'
mem = _to_gibibyte_or_mebibyte(mem)
Should cpu = +int(c['usage']['cpu'][:-1]) be cpu += int(c['usage']['cpu'][:-1])? Similarly, mem = +int(m['usage']['memory'][:-2]) may also be mem += int(m['usage']['memory'][:-2])?
🐛 Summary
Here is a code snippet in function
pod_stats
:Should
cpu = +int(c['usage']['cpu'][:-1])
becpu += int(c['usage']['cpu'][:-1])
? Similarly,mem = +int(m['usage']['memory'][:-2])
may also bemem += int(m['usage']['memory'][:-2])
?To reproduce
Steps to reproduce the behavior:
Expected behavior
What did you expect to happen that didn't?
Any helpful log output or screenshots
Paste the results here:
Add any screenshots of the problem here.