netlab status: show memory usage per node and per lab - #3794
Conversation
|
I contributed a PR to Containerlab over the weekend: srl-labs/containerlab#3325 These cgroups allow you to collect lots of stats directly: I suspect Linux sys/fs could give us all those numbers without going through those separate tools |
Just to make sure I understand: when your PR gets into a containerlab release, and when we switch to that release, and (optionally) when we update the clab.yml, we will be able to read these things directly. Right? |
Well, actually we could read it today:
The cgroup parent grouping can be helpful to get the aggregate, and makes the lookup slightly simpler. |
|
Aaah, I forgot to remove my Multilab commit... I'll remove it later. I didn't know about |
487513d to
b3b44a7
Compare
|
We could also use the ╰─❯ cat /run/libvirt/qemu/ml-2_aruba0.pid -p
1997096
╰─❯ cat /proc/1997096/cgroup -p
0::/machine.slice/machine-qemu\x2d2\x2dml\x2d2aruba0.scope/libvirt/emulator
╰─❯ cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d2\\x2dml\\x2d2aruba0.scope/memory.current -p
1977995264 |
Yeah, I found that recipe, and figured out it does not work on my Docker/Ubuntu combo 🤷♂️ @sdargoeuves -- I would suggest we use the orchestration tools (Docker/libvirt) to fetch the stats. Let them deal with the underlying OS mess. See also: https://www.youtube.com/watch?v=oebqlzblfyo |
|
Finally got a chance to start my main lab to look at the memory usage with this branch. The Now I can see which node(s) are the hungry ones... no surprises, but still nice to see! Here is an extract: |
As it has been discussed on the Network Automagic podcast, I wanted to give (AI a) go at showing the memory usage of a lab, per node.
This is the output for a lab with libvirt+clab:
Disclosure: high risk of AI slop from this point.
Implementation — each provider's
get_lab_statusenriches its status box with amemorykey;fetch_node_statuscopies it into the node status and sums the total intolab_state.memory(so it also lands in--format json/yaml).docker stats --no-stream --format json→MemUsage, "used" half only. The value after the slash is the host total when no limit is set (always, for netlab-generated labs), so it's dropped.virsh domstats --balloon --list-running→balloon.rss(host RSS of the QEMU process). Falls back toballoon.currentsuffixed(max)when the guest has no balloon driver. Domain names are matched back to Vagrant machine names via the_<node>suffix; no new keys are added to the status box.format_memory_size/parse_memory_sizehelpers, docker's1.521GiB/184.5MiBstyle.Both collectors are non-fatal — failures are
print_verboseonly, memory is extra info.Caveats / things you may want changed:
netlab statusfor a clab lab (docker stats --no-streamsamples every container on the host, not just the lab's).used / allocateddisplay, which could be useful for libvirt.