ports/133758: new net-snmp does not count inactive memory as free

Michael W Lucas mwlucas at blackhelicopters.org
Wed Apr 15 18:00:07 UTC 2009


>Number:         133758
>Category:       ports
>Synopsis:       new net-snmp does not count inactive memory as free
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 15 18:00:05 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Michael W Lucas
>Release:        6.2, current ports tree
>Organization:
none
>Environment:
FreeBSD aubsr086.us.add 6.2-STABLE FreeBSD 6.2-STABLE #1: Mon Mar 12 13:24:16 EST 2007     system_mwl at aubsr023.us.add:/usr/obj/usr/src/sys/NSONE  i386

>Description:
Hi,

Previous versions of the net-snmp port counted inactive memory as free.  This is important for monitoring tools, such as Nagios.  Without this behavior, net-snmp reports an alarm when the system has large amounts of inactive memory.

The net-snmp folks seems calculate this value in several places; I'm not sure if they keep changing it or if the way we build our ports changes it.  In any event, the attached patch tells the new net-snmp to count inactive as free.

I'll also send this to the net-snmp people, try to get this incorporated upstream.
>How-To-Repeat:
set snmpd to flag an alarm when the system has less than a certain amount free.  Let inactive memory+used memory rise above that level.  Use snmpwalk to verify that snmpd reports an alarm.
>Fix:
see attached patch

Patch attached with submission follows:

--- memory_freebsd.c	Wed Apr 15 12:33:51 2009
+++ memory_freebsd.c.orig	Wed May 28 07:48:46 2008
@@ -59,7 +59,6 @@
     sysctlbyname("vfs.bufspace",    &bufspace,    &buf_size, NULL, 0);
     sysctlbyname("vfs.maxbufspace", &maxbufspace, &buf_size, NULL, 0);
     auto_nlist(SUM_SYMBOL,      (char *) &vmem,     sizeof(vmem));
-    auto_nlist(BUFSPACE_SYMBOL, (char *) &bufspace, sizeof(bufspace));
 #ifndef freebsd4
     pagesize = 1024;
 #else
@@ -76,7 +75,7 @@
         if (!mem->descr)
              mem->descr = strdup("Physical memory");
         mem->units = pagesize;
-        mem->size  = phys_mem/pagesize;
+        mem->size  = user_mem/pagesize;
         mem->free  = total.t_free;
     }
 
@@ -132,18 +131,7 @@
              mem->descr = strdup("Cached memory");
         mem->units = vmem.v_page_size;
         mem->size  = vmem.v_cache_max;
-        mem->free  = vmem.v_cache_max - (vmem.v_cache_count + vmem.v_inactive_count);
-    }
-
-    mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_MBUF, 1 );
-    if (!mem) {
-        snmp_log_perror("No Memory Buffer info entry");
-    } else {
-        if (!mem->descr)
-            mem->descr = strdup("Memory Buffer");
-        mem->units = pagesize;
-        mem->size  = bufspace/pagesize;
-        mem->free  = -1;
+        mem->free  = vmem.v_cache_max - vmem.v_cache_count;
     }
 
     nswap = swapmode(pagesize);


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list