Supporting MemAvailable on Linux

I’m working a a PR for snmpd for adding support of reporting MemAvailable.

If this gets checked in, any change it would be supported by LibreNMS?

isn’t this still implemented?

a Device -> Graph -> System -> Detailed Memory Usage ?

That would be great - though how is this being implemented without MemAvailable within /proc/memory being exported by snmpd?

Didn’t take a deeper look on it, but it looks like its the mempool poller which handles this.
To get knowledge about the way i would start with: includes/polling/mempools.inc.php
But it seems data are coming directly via SNMP.

You are right the data is coming from SNMP.

What I wanted to archive is to know the “available” memory.

From what I understood with the current LibreNMS implementation, it calculates the memory in two category:

Physical - counts All and Free(which is usually very small for the buffer/shared thing)
Virtual - this is simply the All and Free calculation on Physical + Swap, which doesn’t necessarily reflect the “Available” concept.

Hence the Feature Request here - And again, the underlying SNMP doesn’t export the “Available” memory so I don’t believe this is implemented in LibreNMS anyways (do correct me if wrong)

“free” Memory under linux is relative, it’s mostly reserved by kernel
as you can see free Memory would be used for caching (the orange bar in LibreNMS).

to get the free value … on looking on to the graph it should be a simple subscription of

total Memory (black line) - (red area + cyan area + blue area)
simple mathmatics

nethertheless the RAM may be “free” but as you can see there also, it’s used for caching
i’m not sure if it is needed to graph or print those value also

to clairify - I’m talking about the “available” memory, not free.

If you’d click in to the PR linked in the original post, you’ll get to see what I’m actually talking about.

that’s what i’m talking about

I doubt this is true:

total Memory - the physical mem installed on the machine
red - Buffers
cyan - sorry I’m not really an expert of color, but assuming it’s referring to?
blue - Shared

can you please be more clear on this?

And apparently “available” memory will contain part of “Cached/Buffers” where they are not marked “Free” but can be reallocated by other applications.

Take this as an example, how can we get the “available” column from the graph?

[email protected]:~# free -m
              total        used        free      shared  buff/cache   available
Mem:           2048         329         906         134         812        1718
Swap:             0           0           0

Incase any of these links help the PR:

Thanks, I’ve read this post and that’s the inspiration for me to raise the PR to snmpd instead of stuck in figuring out how to do this in LibreNMS

1 Like

Good stuff i hope you find a way :smiley:

I think the only other way without changing snmpd is just to make a calculation based off “Free + Buff/Cache”, and label it as Available. Your example above, so 906 + 812 = 1718 which is what your available is reporting, not always the case though. It’s meant to be roughly how it’s calculated according to the Googz.

1 Like

Yes thought the real calculation can be found here as noted in the PR:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773

1 Like

Update: the PR is merged and I’m getting to know when it will be released

1 Like

Thats awesome :+1:

PR to LibreNMS created: https://github.com/librenms/librenms/pull/12110

1 Like