Current hrStorageTable supports only 32bit hrStorageSize. With 4096 big
allocation units, it supports disks up to 16 TB. These sizes are
pretty common nowdays and I got few requests to do something about it. The
only thing which comes to my mind is to lie about hrStorageAllocationUnits
and report something bigger that 4096, so hrStorageSize fits into 32bits.
This has obvious problems:
1) we lie about allocation units.
2) we loose few bits in precission of the total size of the device,
size * allocation units won't give real size of the drive but some
aproximation only.
On the other hand, I think that something is better than completely broken
hrStorageSize for such devices.
What is your opinion? You can see a patch below, feel free to suggest
better solution. I've kept original (=real) size and allocation units, in case
somebody needs it and added new *_32 fields to struct netsnmp_fsys_info_s.
Jan
---
.../agent/mibgroup/hardware/fsys/fsys_getfsstats.c | 2 +-
.../agent/mibgroup/hardware/fsys/fsys_mntctl.c | 1 +
.../agent/mibgroup/hardware/fsys/fsys_mntent.c | 1 +
net-snmp/agent/mibgroup/hardware/fsys/hw_fsys.c | 24 +++++++++++++++++++-
net-snmp/agent/mibgroup/host/hrh_storage.c | 6 +++--
net-snmp/include/net-snmp/agent/hardware/fsys.h | 20 ++++++++++++-----
6 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/net-snmp/agent/mibgroup/hardware/fsys/fsys_getfsstats.c
b/net-snmp/agent/mibgroup/hardware/fsys/fsys_getfsstats.c
index c3e4c9d..ce720f2 100755
--- a/net-snmp/agent/mibgroup/hardware/fsys/fsys_getfsstats.c
+++ b/net-snmp/agent/mibgroup/hardware/fsys/fsys_getfsstats.c
@@ -173,6 +173,6 @@ netsnmp_fsys_arch_load( void )
if ( stats[i].NSFS_FLAGS & MNT_ROOTFS ) {
entry->flags |= NETSNMP_FS_FLAG_BOOTABLE;
}
-
+ netsnmp_fsys_calculate32(entry);
}
}
diff --git a/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntctl.c
b/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntctl.c
index 06c2ebf..e65d6d5 100755
--- a/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntctl.c
+++ b/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntctl.c
@@ -171,6 +171,7 @@ netsnmp_fsys_arch_load( void )
entry->avail = stat_buf.f_bavail;
entry->inums_total = stat_buf.f_files;
entry->inums_avail = stat_buf.f_ffree;
+ netsnmp_fsys_calculate32(entry);
}
free(aixmnt);
aixmnt = NULL;
diff --git a/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntent.c
b/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntent.c
index d1120b5..1874481 100755
--- a/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntent.c
+++ b/net-snmp/agent/mibgroup/hardware/fsys/fsys_mntent.c
@@ -235,6 +235,7 @@ netsnmp_fsys_arch_load( void )
entry->avail = stat_buf.f_bavail;
entry->inums_total = stat_buf.f_files;
entry->inums_avail = stat_buf.f_ffree;
+ netsnmp_fsys_calculate32(entry);
}
fclose( fp );
}
diff --git a/net-snmp/agent/mibgroup/hardware/fsys/hw_fsys.c
b/net-snmp/agent/mibgroup/hardware/fsys/hw_fsys.c
index ce8e2c0..4f52b0c 100644
--- a/net-snmp/agent/mibgroup/hardware/fsys/hw_fsys.c
+++ b/net-snmp/agent/mibgroup/hardware/fsys/hw_fsys.c
@@ -249,7 +249,7 @@ _fsys_create_entry( void )
* (attempting to avoid 32-bit overflow!)
*/
unsigned long long
-_fsys_to_K( int size, int units )
+_fsys_to_K( unsigned long long size, unsigned long long units )
{
int factor = 1;
@@ -311,3 +311,25 @@ netsnmp_fsys_avail( netsnmp_fsys_info *f) {
return (int)v;
}
+#ifndef INT32_MAX
+#define INT32_MAX 0x7fffffff
+#endif
+
+/* recalculate f->size_32, used_32, avail_32 and units_32 from f->size &
comp.*/
+void
+netsnmp_fsys_calculate32( netsnmp_fsys_info *f)
+{
+ unsigned long long s = f->size;
+ unsigned long long u = f->units;
+ int factor = 0;
+ while (s > INT32_MAX) {
+ s = s >> 1;
+ u = u << 1;
+ factor++;
+ }
+
+ f->size_32 = s;
+ f->units_32 = u;
+ f->avail_32 = f->avail << factor;
+ f->used_32 = f->used << factor;
+}
diff --git a/net-snmp/agent/mibgroup/host/hrh_storage.c
b/net-snmp/agent/mibgroup/host/hrh_storage.c
index 67c586f..05c267e 100644
--- a/net-snmp/agent/mibgroup/host/hrh_storage.c
+++ b/net-snmp/agent/mibgroup/host/hrh_storage.c
@@ -416,7 +416,7 @@ really_try_next:
}
case HRSTORE_UNITS:
if (store_idx > NETSNMP_MEM_TYPE_MAX)
- long_return = HRFS_entry->units;
+ long_return = HRFS_entry->units_32;
else {
if ( !mem || mem->units == -1 )
goto try_next;
@@ -425,7 +425,7 @@ really_try_next:
return (u_char *) & long_return;
case HRSTORE_SIZE:
if (store_idx > NETSNMP_MEM_TYPE_MAX)
- long_return = HRFS_entry->size;
+ long_return = HRFS_entry->size_32;
else {
if ( !mem || mem->size == -1 )
goto try_next;
@@ -434,7 +434,7 @@ really_try_next:
return (u_char *) & long_return;
case HRSTORE_USED:
if (store_idx > NETSNMP_MEM_TYPE_MAX)
- long_return = HRFS_entry->used;
+ long_return = HRFS_entry->used_32;
else {
if ( !mem || mem->size == -1 || mem->free == -1 )
goto try_next;
diff --git a/net-snmp/include/net-snmp/agent/hardware/fsys.h
b/net-snmp/include/net-snmp/agent/hardware/fsys.h
index 5a1e5ef..91e8e17 100644
--- a/net-snmp/include/net-snmp/agent/hardware/fsys.h
+++ b/net-snmp/include/net-snmp/agent/hardware/fsys.h
@@ -60,13 +60,19 @@ struct netsnmp_fsys_info_s {
char device[SNMP_MAXPATH+1];
int type;
- long size;
- long used;
- long avail;
- long units;
+ unsigned long long size;
+ unsigned long long used;
+ unsigned long long avail;
+ unsigned long long units;
- long inums_total;
- long inums_avail;
+ /* artificially computed values, both 'size_32' and 'units_32' fit INT32
*/
+ unsigned long size_32;
+ unsigned long used_32;
+ unsigned long avail_32;
+ unsigned long units_32;
+
+ unsigned long long inums_total;
+ unsigned long long inums_avail;
int minspace;
int minpercent;
@@ -99,3 +105,5 @@ int netsnmp_fsys_avail(netsnmp_fsys_info* );
unsigned long long netsnmp_fsys_size_ull( netsnmp_fsys_info* );
unsigned long long netsnmp_fsys_used_ull( netsnmp_fsys_info* );
unsigned long long netsnmp_fsys_avail_ull(netsnmp_fsys_info* );
+
+void netsnmp_fsys_calculate32( netsnmp_fsys_info *f);
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders