Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Dec 2023 00:37:48 +0700
From:      Yuri <yuri@aetern.org>
To:        "Patrick M. Hausen" <hausen@punkt.de>
Cc:        FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>, FreeBSD Net <freebsd-net@freebsd.org>
Subject:   Re: Odd values for various memory metrics via SNMP
Message-ID:  <5f884312-4a66-43d6-b0bc-b3d70c4337ab@aetern.org>
In-Reply-To: <8f4cf72e-8320-4bfd-a4d9-3db34db4580d@aetern.org>
References:  <1EDAF2AC-3A2B-43BE-B66B-E095F5A80C2C@punkt.de> <de2988a0-00d6-4b4b-8150-bfa235649d64@aetern.org> <84B7C7D7-BC06-4944-A7E0-5AFC47B6BC0E@punkt.de> <8f4cf72e-8320-4bfd-a4d9-3db34db4580d@aetern.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Yuri wrote:
> Patrick M. Hausen wrote:
>> HI Yuri,
>>
>>> Am 19.12.2023 um 09:50 schrieb Yuri <yuri@aetern.org>:
>>> Let's start with OIDs, which ones exactly you are looking at (numeric or
>>> textual will do)?
>>
>> To start I'll post the 4 odd ones of my OPNsense system, FreeBSD 13.2-p7, net-snmp 5.9.1_4,1:
> 
> OK, guess the following (physical memory) looks correct for you as well?
> 
> ---
> HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1
> HOST-RESOURCES-MIB::hrStorageType.1 = OID:
> HOST-RESOURCES-TYPES::hrStorageRam
> HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory
> HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 4096 Bytes
> HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 4183816
> HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 1499092
> HOST-RESOURCES-MIB::hrStorageAllocationFailures.1 = Counter32: 0
> ---
> 
>> HOST-RESOURCES-MIB::hrStorageIndex.2 = INTEGER: 2
>> HOST-RESOURCES-MIB::hrStorageType.2 = OID: HOST-RESOURCES-TYPES::hrStorageRam
>> HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real memory
>> HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 4096 Bytes
>> HOST-RESOURCES-MIB::hrStorageSize.2 = INTEGER: 191414
>> HOST-RESOURCES-MIB::hrStorageUsed.2 = INTEGER: 189988
>> HOST-RESOURCES-MIB::hrStorageAllocationFailures.2 = Counter32: 0
>> ---
>> HOST-RESOURCES-MIB::hrStorageIndex.9 = INTEGER: 9
>> HOST-RESOURCES-MIB::hrStorageType.9 = OID: HOST-RESOURCES-TYPES::hrStorageOther
>> HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: Shared real memory
>> HOST-RESOURCES-MIB::hrStorageAllocationUnits.9 = INTEGER: 4096 Bytes
>> HOST-RESOURCES-MIB::hrStorageSize.9 = INTEGER: 25627
>> HOST-RESOURCES-MIB::hrStorageUsed.9 = INTEGER: 24175
>> HOST-RESOURCES-MIB::hrStorageAllocationFailures.9 = Counter32: 0
>> ---
>> HOST-RESOURCES-MIB::hrStorageIndex.8 = INTEGER: 8
>> HOST-RESOURCES-MIB::hrStorageType.8 = OID: HOST-RESOURCES-TYPES::hrStorageOther
>> HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: Shared virtual memory
>> HOST-RESOURCES-MIB::hrStorageAllocationUnits.8 = INTEGER: 4096 Bytes
>> HOST-RESOURCES-MIB::hrStorageSize.8 = INTEGER: 54962
>> HOST-RESOURCES-MIB::hrStorageUsed.8 = INTEGER: 41268
>> HOST-RESOURCES-MIB::hrStorageAllocationFailures.8 = Counter32: 0
>> ---
>> HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3
>> HOST-RESOURCES-MIB::hrStorageType.3 = OID: HOST-RESOURCES-TYPES::hrStorageVirtualMemory
>> HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory
>> HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 4096 Bytes
>> HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 1279129
>> HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 1258824
>> HOST-RESOURCES-MIB::hrStorageAllocationFailures.3 = Counter32: 0
> 
> I took a look at FreeBSD-specific interface for getting memory values
> (agent/mibgroup/hardware/memory/memory_freebsd.c) and all it does is
> parsing the following sysctl (vm.vmtotal) output:
> 
> ---
> vm.vmtotal:
> System wide totals computed every five seconds: (values in kilobytes)
> ===============================================
> Processes:              (RUNQ: 2 Disk Wait: 0 Page Wait: 0 Sleep: 30)
> Virtual Memory:         (Total: 538434716K Active: 538414860K)
> Real Memory:            (Total: 78488K Active: 75752K)
> Shared Virtual Memory:  (Total: 52052K Active: 32236K)
> Shared Real Memory:     (Total: 27284K Active: 24588K)
> Free Memory:    9474964K
> ---
> 
> So I guess what net-snmp reports makes sense and the only value that
> should be used for alerts is that "physical memory" one.

OTOH, using the other way to get these values (the code checks for
VM_TOTAL define) seems to provide somewhat saner values, try editing
agent/mibgroup/hardware/memory/memory_freebsd.c after doing `make patch`
and add the #undef as below (not providing diff output as it won't make
much sense here):

---
#if HAVE_SYS_VMPARAM_H
#include <sys/vmparam.h>
#else
#include <vm/vm_param.h>
#endif

#undef VM_TOTAL
---



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5f884312-4a66-43d6-b0bc-b3d70c4337ab>