15372155 SUNBT6513126 SNMP monitoring large(>1Tb) ZFS filesystem reports faulty disk size
--- /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
+@@ -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;
+@@ -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();
+@@ -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 )
+@@ -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;
+@@ -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;