RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1601012 - net-snmp overestimates RHEL7 memory usage
Summary: net-snmp overestimates RHEL7 memory usage
Keywords:
Status: CLOSED DUPLICATE of bug 1250060
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: net-snmp
Version: 7.5
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Josef Ridky
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-07-13 14:57 UTC by Ravindra Patil
Modified: 2022-01-17 09:33 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-05-31 11:35:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Ravindra Patil 2018-07-13 14:57:59 UTC
Description of problem:
currently net-snmp overestimates RHEL7 memory usage which result lot of wrong memory alert

Description	
net-snmp overestimates the memory usage than that of free output

Reason : free command includes slab allocation in cache, which is not included by HOST-RESOURCES-MIB i.e. net-snmp. 


# snmpwalk -Os -v2c -cpublic localhost hrStorage | grep '\.[167] ='
hrStorageIndex.1 = INTEGER: 1
hrStorageIndex.6 = INTEGER: 6
hrStorageIndex.7 = INTEGER: 7
hrStorageType.1 = OID: hrStorageRam
hrStorageType.6 = OID: hrStorageOther
hrStorageType.7 = OID: hrStorageOther
hrStorageDescr.1 = STRING: Physical memory
hrStorageDescr.6 = STRING: Memory buffers
hrStorageDescr.7 = STRING: Cached memory
hrStorageAllocationUnits.1 = INTEGER: 1024 Bytes
hrStorageAllocationUnits.6 = INTEGER: 1024 Bytes
hrStorageAllocationUnits.7 = INTEGER: 1024 Bytes
hrStorageSize.1 = INTEGER: 19799404
hrStorageSize.6 = INTEGER: 19799404
hrStorageSize.7 = INTEGER: 2428420
hrStorageUsed.1 = INTEGER: 6758148
hrStorageUsed.6 = INTEGER: 279280
hrStorageUsed.7 = INTEGER: 2428420

hrStorageUsed includes buffers and cache, so you can get an estimate of total free RAM like this:
totFree = total - used + buffers + cache

As per above outputs
totFree = hrStorageSize.1 - hrStorageUsed.1 + hrStorageUsed.6 + hrStorageUsed.7
        = 19799404        - 6792488         + 280040          + 2447248
        = 15734204 KB

As per free output total free memory would be as follows :
# free
              total        used        free      shared  buff/cache   available
Mem:       19799404     3709992    13008312      846124     3081100    14787728
Swap:      10027004           0    10027004

totFree = free   + buff/cache
        = 13008312 + 3081100
        = 16089412 KB

Here is the discrepancy in memory usage between net-snmp and free. Though both free and HOST-RESOURCES-MIB get their data from /proc/meminfo, but use slightly different metrics. From man free:

buffers : Memory used by kernel buffers (Buffers in /proc/meminfo)
cache : Memory used by the page cache and slabs (Cached and Slab in /proc/meminfo)

So free includes slab allocation in cache, while HOST-RESOURCES-MIB doesn't. If we get the slab allocation:

# grep Slab /proc/meminfo
Slab:             353696 kB

and add it to what we got from SNMP, we have:

totFree = 15734204 + 353696
        = 16087900 KB

Is it possible to include slab allocation in net-snmp memroy usage ?

Version-Release number of selected component (if applicable):
net-snmp-5.7.2-24.el7_3.2.x86_64


How reproducible:
1. Install net-snmp
2. Start the service
3. Collect memory usage using net-snmp

Steps to Reproduce:
1. Check memory usage using net-snmp
2. Check memory usage using free command 
3. Compare the memory usage

Actual results:
net-snmp over estimates memory usage on the system

Expected results:
net-snmp and free should show similar memory usage

Additional info:

slab allocation is not considered by net-snmp memory usage

Comment 2 Nat Guyton 2018-08-24 20:42:44 UTC
Note that Slab breaks down to Slab Reclaimable and Slab Unreclaimable; only Slab Reclaimable should be considered as part of free memory, I believe.

from /proc/meminfo:
...
Slab:             753336 kB
SReclaimable:     640876 kB
SUnreclaim:       112460 kB
...

Comment 3 Nat Guyton 2018-08-24 20:53:54 UTC
There seems to be a patch on net-snmp developer site, but was last touched over a year and a half ago:

https://sourceforge.net/p/net-snmp/patches/1338/

Comment 4 Josef Ridky 2018-09-05 10:55:43 UTC
Wait for upstream response.

Comment 5 Barend Havenga 2018-10-16 20:15:05 UTC
Any updates on this issue?

Comment 6 Josef Ridky 2018-10-18 06:41:32 UTC
Moving to RHEL-7.7 due due upstream haven't responded yet.

Comment 11 Tom Manor 2019-05-30 20:08:14 UTC
Was this added to RHEL 7.7?  I don't recall seeing anything regarding this bz.

Thanks,

Comment 12 Josef Ridky 2019-05-31 11:35:06 UTC
Yes, this issue was solved by bz#1250060.

Closing as DUPLICATE of 1250060.

*** This bug has been marked as a duplicate of bug 1250060 ***


Note You need to log in before you can comment on or make changes to this bug.