diff -ur nagios-plugins-snmp-orig/src/check_snmp_storage.c nagios-plugins-snmp/src/check_snmp_storage.c --- nagios-plugins-snmp-orig/src/check_snmp_storage.c 2007-06-01 19:30:51.000000000 +0200 +++ nagios-plugins-snmp/src/check_snmp_storage.c 2011-01-14 15:43:05.759881308 +0100 @@ -497,13 +497,13 @@ index_match=(int) tempT->name[tempT->name_length-1]; /* get used value */ - if (get_value_ulint(used_table,sizeof (used_table)/sizeof (oid),index_match,valueT,&(storage_state[i].used))!=0) { + if (get_value_ulint_hacked(used_table,sizeof (used_table)/sizeof (oid),index_match,valueT,&(storage_state[i].used))!=0) { printf(_("Cannot get used value for %s\n"),tempT->value);return N_UNKNOWN; } - if (get_value_ulint(size_table,sizeof (size_table)/sizeof (oid),index_match,valueT,&(storage_state[i].size))!=0) { + if (get_value_ulint_hacked(size_table,sizeof (size_table)/sizeof (oid),index_match,valueT,&(storage_state[i].size))!=0) { printf(_("Cannot get size value for %s\n"),tempT->value);return N_UNKNOWN; } - if (get_value_ulint(alloc_units,sizeof (alloc_units)/sizeof (oid),index_match,valueT,&(storage_state[i].alloc_unit))!=0) { + if (get_value_ulint_hacked(alloc_units,sizeof (alloc_units)/sizeof (oid),index_match,valueT,&(storage_state[i].alloc_unit))!=0) { printf(_("Cannot get alloc unit value for %s\n"),tempT->value);return N_UNKNOWN; } if (o_verb) printf("Storage %s : %lu used, %lu size, %lu alloc unit\n",tempT->value,storage_state[i].used,storage_state[i].size,storage_state[i].alloc_unit); diff -ur nagios-plugins-snmp-orig/src/nagios_common_snmp.c nagios-plugins-snmp/src/nagios_common_snmp.c --- nagios-plugins-snmp-orig/src/nagios_common_snmp.c 2007-05-29 00:07:59.000000000 +0200 +++ nagios-plugins-snmp/src/nagios_common_snmp.c 2011-01-14 15:23:53.603463408 +0100 @@ -113,6 +113,21 @@ return 0; } +int get_value_ulint_hacked(oid* base_oid,size_t base_oid_len, int index_oid,snmp_table * val_table,unsigned long *returned_val) { + // Hacked by Troels Arvin to handle an inter overflow which may happen for devices with very many blocks. + // The hack only works to a limited extend, though: If there are many, many blocks involved, + // the unsigned integer may have overflowed "many times". + long tmp_value_l; + base_oid[base_oid_len++]=(oid) index_oid; + if ((val_table=search_oid(base_oid,base_oid_len,val_table)) == NULL) return 1; + tmp_value_l = val_table->value_l; + if (tmp_value_l < 0) { + tmp_value_l += 4294967296; + } + *returned_val=tmp_value_l; + return 0; +} + int get_value_long(oid* base_oid,size_t base_oid_len, int index_oid,snmp_table * val_table,unsigned long long *returned_val) { base_oid[base_oid_len++]=(oid) index_oid; if ((val_table=search_oid(base_oid,base_oid_len,val_table)) == NULL) return 1; diff -ur nagios-plugins-snmp-orig/src/nagios_common_snmp.h nagios-plugins-snmp/src/nagios_common_snmp.h --- nagios-plugins-snmp-orig/src/nagios_common_snmp.h 2007-05-30 11:51:59.000000000 +0200 +++ nagios-plugins-snmp/src/nagios_common_snmp.h 2011-01-14 15:23:53.604463409 +0100 @@ -192,6 +192,7 @@ /* get value in snmp table chain by OID : int / unsigned long long */ int get_value_int(oid* base_oid,size_t base_oid_len, int index_oid,snmp_table * val_table,int *returned_val); int get_value_ulint(oid* base_oid,size_t base_oid_len, int index_oid,snmp_table * val_table,unsigned long *returned_val); +int get_value_ulint_hacked(oid* base_oid,size_t base_oid_len, int index_oid,snmp_table * val_table,unsigned long *returned_val); int get_value_long(oid* base_oid,size_t base_oid_len, int index_oid,snmp_table * val_table,unsigned long long *returned_val); int init_snmp_session();