From ffce63968fd860dc6e34228523967f096e13d702 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 17:36:10 +0100 Subject: [PATCH] Fixed negative values for storage: http://munin-monitoring.org/ticket/1371 --- includes/discovery/storage/hrstorage.inc.php | 2 ++ includes/functions.php | 9 +++++++++ includes/polling/storage/hrstorage.inc.php | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/includes/discovery/storage/hrstorage.inc.php b/includes/discovery/storage/hrstorage.inc.php index 6183658f8..397872941 100644 --- a/includes/discovery/storage/hrstorage.inc.php +++ b/includes/discovery/storage/hrstorage.inc.php @@ -9,6 +9,8 @@ if (is_array($hrstorage_array)) { $fstype = $storage['hrStorageType']; $descr = $storage['hrStorageDescr']; + $storage['hrStorageSize'] = fix_integer_value($storage['hrStorageSize']); + $storage['hrStorageUsed'] = fix_integer_value($storage['hrStorageUsed']); $size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits']; $used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits']; $units = $storage['hrStorageAllocationUnits']; diff --git a/includes/functions.php b/includes/functions.php index ef3cd98e3..1b995bfdb 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1201,3 +1201,12 @@ function first_oid_match($device, $list) { } } } + +function fix_integer_value($value) { + if ($value < 0) { + $return = 4294967296+$value; + } else { + $return = $value; + } + return $return; +} diff --git a/includes/polling/storage/hrstorage.inc.php b/includes/polling/storage/hrstorage.inc.php index 304e61b7d..5ff95aa7b 100644 --- a/includes/polling/storage/hrstorage.inc.php +++ b/includes/polling/storage/hrstorage.inc.php @@ -11,8 +11,10 @@ if (!is_array($storage_cache['hrstorage'])) $entry = $storage_cache['hrstorage'][$storage[storage_index]]; $storage['units'] = $entry['hrStorageAllocationUnits']; +$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']); +$entry['hrStorageSize'] = fix_integer_value($entry['hrStorageSize']); $storage['used'] = $entry['hrStorageUsed'] * $storage['units']; $storage['size'] = $entry['hrStorageSize'] * $storage['units']; $storage['free'] = $storage['size'] - $storage['used']; -?> \ No newline at end of file +?>