Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory stat seems to be off running in MacOS with docker agent #287

Open
austinliuu opened this issue Nov 17, 2024 · 6 comments
Open

Memory stat seems to be off running in MacOS with docker agent #287

austinliuu opened this issue Nov 17, 2024 · 6 comments
Labels
troubleshooting Maybe bug, maybe not

Comments

@austinliuu
Copy link

I was running the binary which was reporting the correct RAM usage but once I switched to docker agent, the RAM usage seems only reports what docker container/services are using. I'm running MacOS 15.1 with Orbstack+Portainer

image
@henrygd
Copy link
Owner

henrygd commented Nov 17, 2024

Thanks for reporting this.

Mac and Linux have different methods for calculating memory usage. When you run the binary, it uses the native method for Mac.

When you run on Docker / Orbstack on Mac, I'm assuming it uses the Linux method (directly reading /proc/meminfo), and the values are incorrect due to how /proc is implemented. This may even differ between Docker Desktop, Orbstack, and Podman.

From a quick google, Orbstack says it has its own "dynamic memory management" implementation, so it may have something to do with that.

Unfortunately I can't troubleshoot because I don't have a MacOS device. It would be helpful to confirm the meminfo values, though. beszel-agent doesn't have a shell, but if you have another orbstack container running you should be able to do this:

docker exec -it container-name sh
cat /proc/meminfo

@henrygd henrygd added the troubleshooting Maybe bug, maybe not label Nov 17, 2024
@austinliuu
Copy link
Author

I have run the meminfo commend inside the Portainer container (which I used to deploy beszel-agent), here is the output

❯ cat /proc/meminfo
MemTotal:        5441096 kB
MemFree:         5003708 kB
MemAvailable:    5025512 kB
Buffers:             392 kB
Cached:           164196 kB
SwapCached:            0 kB
Active:            78824 kB
Inactive:         189504 kB
Active(anon):      10672 kB
Inactive(anon):   113888 kB
Active(file):      68152 kB
Inactive(file):    75616 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       6489664 kB
SwapFree:        6489664 kB
Dirty:               160 kB
Writeback:             0 kB
AnonPages:        101764 kB
Mapped:            67308 kB
Shmem:             20820 kB
KReclaimable:      30512 kB
Slab:              73840 kB
SReclaimable:      30512 kB
SUnreclaim:        43328 kB
KernelStack:        5408 kB
PageTables:         2392 kB
SecPageTables:         0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     9210212 kB
Committed_AS:     758632 kB
VmallocTotal:   135288315904 kB
VmallocUsed:       26620 kB
VmallocChunk:          0 kB
Percpu:             2520 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB

@austinliuu
Copy link
Author

I'm not sure if these number match with what MacOS shows, here is the number from the activity manager
image

@henrygd
Copy link
Owner

henrygd commented Nov 18, 2024

Thanks, it looks like Orbstack runs containers in a memory-limited environment, and meminfo is based on the LXC container, VM, or whatever they use for this.

I doubt there's anything we can do on this side to work around it, unfortunately. I'd recommend sticking with the binary for the time being. Or maybe test with Podman to see if the behavior is any different.

@austinliuu
Copy link
Author

Yeah that makes sense, but I’m having trouble setting the binary to auto start on boot up in MacOS(it needs to be done by using .plist) and my binary agent seems to stop sending telematics after some time sitting idle. Is there a way to debug why? I don’t see any error when running in terminal

@henrygd
Copy link
Owner

henrygd commented Nov 18, 2024

You're not the only one who ran into that. There's another issue here: #248

I don't know why that would happen. Maybe it needs to continuously print output or interact with the filesystem for it to be considered active?

Try adding LOG_LEVEL=debug and see if it continues to run when it's logging things. Otherwise let me know what it logs just before it terminates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Maybe bug, maybe not
Projects
None yet
Development

No branches or pull requests

2 participants