15372155 SUNBT6513126 SNMP monitoring large(>1Tb) ZFS filesystem reports faulty disk size s11u3-sru
authorSowrabha H G<sowrabha.hg@oracle.com>
Thu, 26 Nov 2015 21:27:25 -0800
branchs11u3-sru
changeset 5132 048ccb1a7e2c
parent 5120 22fdde0a7fbe
child 5133 19d9e2477ac2
15372155 SUNBT6513126 SNMP monitoring large(>1Tb) ZFS filesystem reports faulty disk size
components/net-snmp/patches/056.15372155.hr_storage.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/net-snmp/patches/056.15372155.hr_storage.patch	Thu Nov 26 21:27:25 2015 -0800
@@ -0,0 +1,67 @@
+This patch fixes an issue where snmpdf was not returning the 
+correct total disk size and available disk size when the size 
+of the filesystem is larger than 1TB.This bug is already fixed 
+in the community and the fix is available from the net-snmp 
+version 5.6 onwards.The fix here slightly differs from the community 
+since the patch in the community is applied on net-snmp version 5.6 .
+This patch is taken from the below link.
+
+https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/865268
+
+
+--- net-snmp-5.4.1/agent/mibgroup/host/hr_storage.c	Thu May 21 23:47:45 2015
++++ net-snmp-5.4.1/agent/mibgroup/host/hr_storage.c	Thu May 21 23:55:59 2015
[email protected]@ -505,6 +505,7 @@
+             int exact, size_t * var_len, WriteMethod ** write_method)
+ {
+     int             store_idx = 0;
++    int             factor = 0;
+     static char     string[1024];
+     struct HRFS_statfs stat_buf;
+     void                *ptr;
[email protected]@ -537,9 +538,14 @@
+ 	    mem = (netsnmp_memory_info*)ptr;
+         }
+     }
++/* Scaling factor for large filesystems */
++    if (store_idx > NETSNMP_MEM_TYPE_MAX) {
++        unsigned long long tmp = stat_buf.f_blocks;
++        while (tmp > 0x7fffffff)
++            tmp >>= 1, factor++;
++    }
+ 
+ 
+-
+     switch (vp->magic) {
+     case HRSTORE_MEMSIZE:
+         netsnmp_memory_load();
[email protected]@ -593,9 +599,9 @@
+     case HRSTORE_UNITS:
+         if (store_idx > NETSNMP_MEM_TYPE_MAX)
+ #if HRFS_HAS_FRSIZE
+-            long_return = stat_buf.f_frsize;
++            long_return = stat_buf.f_frsize << factor;
+ #else
+-            long_return = stat_buf.f_bsize;
++            long_return = stat_buf.f_bsize << factor;
+ #endif
+         else {
+             if ( !mem || mem->units == -1 )
[email protected]@ -605,7 +611,7 @@
+         return (u_char *) & long_return;
+     case HRSTORE_SIZE:
+         if (store_idx > NETSNMP_MEM_TYPE_MAX)
+-            long_return = stat_buf.f_blocks;
++            long_return = stat_buf.f_blocks >> factor;
+         else {
+             if ( !mem || mem->size == -1 )
+                 goto try_next;
[email protected]@ -614,7 +620,7 @@
+         return (u_char *) & long_return;
+     case HRSTORE_USED:
+         if (store_idx > NETSNMP_MEM_TYPE_MAX)
+-            long_return = (stat_buf.f_blocks - stat_buf.f_bfree);
++            long_return = (stat_buf.f_blocks - stat_buf.f_bfree) >> factor;
+         else {
+             if ( !mem || mem->size == -1 || mem->free == -1 )
+                 goto try_next;