> Way back in February Dave Shield wrote:
> >>>   b)  Should 'memAvailSwapTXT' and 'memAvailRealTXT' report the
> >>>       amount of memory free, or the amount used?
> >>>       The MIB object name implies one, the description the other!

The latest HAL-based memory module followed the name of the MIB object
(thus introducing a change in behaviour for the sole current implementation
of these objects).
  Feedback from IRC indicates that this was seen as inappropriate.

I therefore offer the following patch which:
   -  reports the amount of memory used rather than free,
   -  introduces new MIB objects with consistent names/descriptions
   -  deprecates (but retains) the inconsistent MIB objects.

Dave
Index: agent/mibgroup/ucd-snmp/memory.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/ucd-snmp/memory.c,v
retrieving revision 5.17
diff -u -r5.17 memory.c
--- agent/mibgroup/ucd-snmp/memory.c	30 Oct 2006 21:43:28 -0000	5.17
+++ agent/mibgroup/ucd-snmp/memory.c	6 Nov 2006 10:27:55 -0000
@@ -28,7 +28,7 @@
         netsnmp_create_handler_registration("memory", handle_memory,
                                  memory_oid, memory_object_index,
                                              HANDLER_CAN_RONLY),
-                                 1, 15);
+                                 1, 17);
     netsnmp_register_scalar(
         netsnmp_create_handler_registration("memSwapError", handle_memory,
                            memSwapError_oid, memory_object_index+1,
@@ -118,11 +118,19 @@
             val  =  mem_info->size;
             val *= (mem_info->units/1024);
             break;
-        case MEMORY_STXT_AVAIL:    /* XXX - Or used ? */
+        case MEMORY_STXT_AVAIL:
+        case MEMORY_STXT_USED:
+            /*
+             *   The original MIB description of memAvailSwapTXT
+             * was inconsistent with that implied by the name.
+             *   Retain the actual behaviour for the (sole)
+             * implementation of this object, but deprecate it in
+             * favour of a more consistently named replacement object.
+             */
             mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_STEXT, 0 );
             if (!mem_info)
                goto NOSUCH;
-            val  =  mem_info->free;  /* XXX - Or size-free ? */
+            val  = (mem_info->size - mem_info->free);
             val *= (mem_info->units/1024);
             break;
         case MEMORY_RTXT_TOTAL:
@@ -132,11 +140,19 @@
             val  =  mem_info->size;
             val *= (mem_info->units/1024);
             break;
-        case MEMORY_RTXT_AVAIL:    /* XXX - Or used ? */
+        case MEMORY_STXT_AVAIL:
+        case MEMORY_STXT_USED:
+            /*
+             *   The original MIB description of memAvailRealTXT
+             * was inconsistent with that implied by the name.
+             *   Retain the actual behaviour for the (sole)
+             * implementation of this object, but deprecate it in
+             * favour of a more consistently named replacement object.
+             */
             mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_RTEXT, 0 );
             if (!mem_info)
                goto NOSUCH;
-            val  =  mem_info->free;  /* XXX - Or size-free ? */
+            val  = (mem_info->size - mem_info->free);
             val *= (mem_info->units/1024);
             break;
         case MEMORY_FREE:
Index: agent/mibgroup/ucd-snmp/memory.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/ucd-snmp/memory.h,v
retrieving revision 5.4
diff -u -r5.4 memory.h
--- agent/mibgroup/ucd-snmp/memory.h	27 Feb 2006 12:07:44 -0000	5.4
+++ agent/mibgroup/ucd-snmp/memory.h	6 Nov 2006 10:27:55 -0000
@@ -22,14 +22,16 @@
 #define MEMORY_REAL_TOTAL    5
 #define MEMORY_REAL_AVAIL    6
 #define MEMORY_STXT_TOTAL    7
-#define MEMORY_STXT_AVAIL    8
+#define MEMORY_STXT_AVAIL    8   /* Deprecated */
 #define MEMORY_RTXT_TOTAL    9
-#define MEMORY_RTXT_AVAIL   10
+#define MEMORY_RTXT_AVAIL   10   /* Deprecated */
 #define MEMORY_FREE         11
 #define MEMORY_SWAP_MIN     12
 #define MEMORY_SHARED       13
 #define MEMORY_BUFFER       14
 #define MEMORY_CACHED       15
+#define MEMORY_STXT_USED    16
+#define MEMORY_RTXT_USED    17
 #define MEMORY_SWAP_ERROR  100
 #define MEMORY_SWAP_ERRMSG 101
 #endif                          /* MEMORY_H */
Index: mibs/UCD-SNMP-MIB.txt
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/mibs/UCD-SNMP-MIB.txt,v
retrieving revision 5.6
diff -u -r5.6 UCD-SNMP-MIB.txt
--- mibs/UCD-SNMP-MIB.txt	10 Feb 2005 19:53:26 -0000	5.6
+++ mibs/UCD-SNMP-MIB.txt	6 Nov 2006 10:27:55 -0000
@@ -432,9 +432,14 @@
 memAvailSwapTXT OBJECT-TYPE
     SYNTAX	Integer32
     MAX-ACCESS	read-only
-    STATUS	current
+    STATUS	deprecated
     DESCRIPTION	
-	"Active virtual memory used by text."
+	"Active virtual memory used by text.
+         Note that despite the name of the object,
+         this value did in practise monitor the
+         memory *used* rather than available.
+         For clarity, this object is being deprecated
+         in favour of 'memUsedSwapTXT(16)."
     ::= { memory 8 }
 
 memTotalRealTXT OBJECT-TYPE
@@ -448,9 +453,14 @@
 memAvailRealTXT OBJECT-TYPE
     SYNTAX	Integer32
     MAX-ACCESS	read-only
-    STATUS	current
+    STATUS	deprecated
     DESCRIPTION
-	"Active Real/Physical Memory Space used by text."
+	"Active Real/Physical Memory Space used by text.
+         Note that despite the name of the object,
+         this value did in practise monitor the
+         memory *used* rather than available.
+         For clarity, this object is being deprecated
+         in favour of 'memUsedRealTXT(17)."
     ::= { memory 10 }
 
 memTotalFree OBJECT-TYPE
@@ -495,6 +505,22 @@
 	"Total Cached Memory"
     ::= { memory 15 }
 
+memUsedSwapTXT OBJECT-TYPE
+    SYNTAX	Integer32
+    MAX-ACCESS	read-only
+    STATUS	current
+    DESCRIPTION	
+	"Active virtual memory used by text."
+    ::= { memory 16 }
+
+memUsedRealTXT OBJECT-TYPE
+    SYNTAX	Integer32
+    MAX-ACCESS	read-only
+    STATUS	current
+    DESCRIPTION
+	"Active Real/Physical Memory Space used by text."
+    ::= { memory 17 }
+
 memSwapError OBJECT-TYPE
     SYNTAX	Integer32
     MAX-ACCESS	read-only
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to