From ce02f001cef41fe19c2ce6464980987f01034fa1 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 1 Nov 2023 23:00:58 -0500 Subject: [PATCH] TrueNAS no longer supports zpool space usage (#15490) * Freenas zpool improvement Don't try to multiply two strings (cast units to int) No need to double fetch database entries to check if it exists. Only poll zpoolUsed to speed up polling * Block zpool usage on new devices, they dropped support. TRUENAS-MIB included for reference * Fix polling, update test data --- .../discovery/storage/freenas-zpool.inc.php | 23 +- .../polling/storage/freenas-zpool.inc.php | 16 +- mibs/ixsystems/TRUENAS-MIB | 466 ++++++++++++++++++ tests/data/truenas.json | 12 +- tests/data/truenas_11-3.json | 6 +- 5 files changed, 497 insertions(+), 26 deletions(-) create mode 100644 mibs/ixsystems/TRUENAS-MIB diff --git a/includes/discovery/storage/freenas-zpool.inc.php b/includes/discovery/storage/freenas-zpool.inc.php index e02ed96e6f..b670a38460 100644 --- a/includes/discovery/storage/freenas-zpool.inc.php +++ b/includes/discovery/storage/freenas-zpool.inc.php @@ -3,20 +3,21 @@ if ($device['os'] == 'truenas') { $zpooltable_array = snmpwalk_cache_oid($device, 'zpoolTable', null, 'FREENAS-MIB'); - $sql = "SELECT `storage_descr` FROM `storage` WHERE `device_id` = '" . $device['device_id'] . "' AND `storage_type` != 'zpool'"; - $tmp_storage = dbFetchColumn($sql); - if (is_array($zpooltable_array)) { foreach ($zpooltable_array as $index => $zpool) { - if (isset($zpool['zpoolDescr'])) { - if (!in_array($zpool['zpoolDescr'], $tmp_storage)) { - $zpool['zpoolIndex'] = $index; - $zpool['zpoolTotal'] = $zpool['zpoolSize'] * $zpool['zpoolAllocationUnits']; - $zpool['zpoolAvail'] = ($zpool['zpoolAvailable'] * $zpool['zpoolAllocationUnits']); - $zpool['zpoolUsed'] = $zpool['zpoolTotal'] - $zpool['zpoolAvail']; + // new devices return a status string at zpoolAllocationUnits (.1.3.6.1.4.1.50536.1.1.1.1.3) and no longer support zpool usage stats + if (is_numeric($zpool['zpoolAllocationUnits'])) { + $units = (int) $zpool['zpoolAllocationUnits']; - discover_storage($valid_storage, $device, $zpool['zpoolIndex'], 'zpool', 'freenas-zpool', $zpool['zpoolDescr'], $zpool['zpoolTotal'], $zpool['zpoolAllocationUnits'], $zpool['zpoolUsed']); - } + discover_storage($valid_storage, $device, + $index, + 'zpool', + 'freenas-zpool', + $zpool['zpoolDescr'], + $zpool['zpoolSize'] * $units, + $units, + $zpool['zpoolUsed'] * $units, + ); } } } diff --git a/includes/polling/storage/freenas-zpool.inc.php b/includes/polling/storage/freenas-zpool.inc.php index 712dafaa21..2b02687d46 100644 --- a/includes/polling/storage/freenas-zpool.inc.php +++ b/includes/polling/storage/freenas-zpool.inc.php @@ -1,13 +1,17 @@