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
This commit is contained in:
Tony Murray 2023-11-01 23:00:58 -05:00 committed by GitHub
parent f0bbab2419
commit ce02f001ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 497 additions and 26 deletions

View File

@ -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,
);
}
}
}

View File

@ -1,13 +1,17 @@
<?php
if (! isset($storage_cache['zpool'])) {
$storage_cache['zpool'] = snmpwalk_cache_oid($device, 'zpoolTable', null, 'FREENAS-MIB');
$storage_cache['zpool'] = snmpwalk_cache_oid($device, 'zpoolUsed', null, 'FREENAS-MIB');
d_echo($storage_cache);
}
$entry = $storage_cache['zpool'][$storage['storage_index']];
if (isset($storage_cache['zpool'][$storage['storage_index']]['zpoolUsed'])) {
$used = $storage_cache['zpool'][$storage['storage_index']]['zpoolUsed'];
$storage['units'] = $entry['zpoolAllocationUnits'];
$storage['size'] = ($entry['zpoolSize'] * $storage['units']);
$storage['free'] = ($entry['zpoolAvailable'] * $storage['units']);
$storage['used'] = ($storage['size'] - $storage['free']);
$storage['used'] = $used * $storage['storage_units'];
$storage['free'] = $storage['storage_size'] - $storage['used'];
// leave these the same
$storage['size'] = $storage['storage_size'];
$storage['units'] = $storage['storage_units'];
}

466
mibs/ixsystems/TRUENAS-MIB Normal file
View File

@ -0,0 +1,466 @@
TRUENAS-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE, enterprises,
Integer32, Counter32, Counter64, Gauge32 FROM SNMPv2-SMI
TEXTUAL-CONVENTION, DisplayString FROM SNMPv2-TC;
trueNas MODULE-IDENTITY
LAST-UPDATED "202212211800Z"
ORGANIZATION "www.ixsystems.com"
CONTACT-INFO
"postal: 2490 Kruse Dr
San Jose, CA 95131
email: support@iXsystems.com"
DESCRIPTION
"TrueNAS Specific MIBs"
REVISION "202212211800Z"
DESCRIPTION
""
::= { enterprises 50536 }
AlertLevelType ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
""
SYNTAX INTEGER {
info(1),
notice(2),
warning(3),
error(4),
critical(5),
alert(6),
emergency(7)
}
zfs OBJECT IDENTIFIER ::= { trueNas 1 }
notifications OBJECT IDENTIFIER ::= { trueNas 2 }
notificationPrefix OBJECT IDENTIFIER ::= { notifications 1 }
notificationObjects OBJECT IDENTIFIER ::= { notifications 2 }
zpool OBJECT IDENTIFIER ::= { zfs 1 }
zvol OBJECT IDENTIFIER ::= { zfs 2 }
arc OBJECT IDENTIFIER ::= { zfs 3 }
l2arc OBJECT IDENTIFIER ::= { zfs 4 }
zil OBJECT IDENTIFIER ::= { zfs 5 }
zpoolTable OBJECT-TYPE
SYNTAX SEQUENCE OF ZpoolEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
::= { zpool 1 }
zpoolEntry OBJECT-TYPE
SYNTAX ZpoolEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
INDEX { zpoolIndex }
::= { zpoolTable 1 }
ZpoolEntry ::= SEQUENCE {
zpoolIndex Integer32,
zpoolName DisplayString,
zpoolHealth DisplayString,
zpoolReadOps Counter64,
zpoolWriteOps Counter64,
zpoolReadBytes Counter64,
zpoolWriteBytes Counter64,
zpoolReadOps1sec Counter64,
zpoolWriteOps1sec Counter64,
zpoolReadBytes1sec Counter64,
zpoolWriteBytes1sec Counter64
}
zpoolIndex OBJECT-TYPE
SYNTAX Integer32 (1..2147483647)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
::= { zpoolEntry 1 }
zpoolName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The name of the zpool"
::= { zpoolEntry 2 }
zpoolHealth OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The health of the zpool"
::= { zpoolEntry 3 }
zpoolReadOps OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of read I/O operations sent to the pool or device,
including metadata requests (averaged since system booted)."
::= { zpoolEntry 4 }
zpoolWriteOps OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of write I/O operations sent to the pool or device
(averaged since system booted)."
::= { zpoolEntry 5 }
zpoolReadBytes OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The bandwidth of all read operations (including metadata),
expressed as units per second (averaged since system booted)"
::= { zpoolEntry 6 }
zpoolWriteBytes OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The bandwidth of all write operations, expressed as units per
second (averaged since system booted)."
::= { zpoolEntry 7 }
zpoolReadOps1sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of read I/O operations sent to the pool or device,
including metadata requests (over 1 second interval)."
::= { zpoolEntry 8 }
zpoolWriteOps1sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of write I/O operations sent to the pool or device
(over 1 second interval)."
::= { zpoolEntry 9 }
zpoolReadBytes1sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The bandwidth of all read operations (including metadata),
expressed as units per second (over 1 second interval)"
::= { zpoolEntry 10 }
zpoolWriteBytes1sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The bandwidth of all write operations, expressed as units per
second (over 1 second interval)."
::= { zpoolEntry 11 }
zvolTable OBJECT-TYPE
SYNTAX SEQUENCE OF ZvolEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
::= { zvol 1 }
zvolEntry OBJECT-TYPE
SYNTAX ZvolEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
INDEX { zvolIndex }
::= { zvolTable 1 }
ZvolEntry ::= SEQUENCE {
zvolIndex Integer32,
zvolDescr DisplayString,
zvolUsedBytes Counter64,
zvolAvailableBytes Counter64,
zvolReferencedBytes Counter64
}
zvolIndex OBJECT-TYPE
SYNTAX Integer32 (1..2147483647)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
::= { zvolEntry 1 }
zvolDescr OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The name of the zvol"
::= { zvolEntry 2 }
zvolUsedBytes OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The zfs used property value"
::= { zvolEntry 3 }
zvolAvailableBytes OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The zfs available property value"
::= { zvolEntry 4 }
zvolReferencedBytes OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The zfs referenced property value"
::= { zvolEntry 5 }
zfsArcSize OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { arc 1 }
zfsArcMeta OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { arc 2 }
zfsArcData OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { arc 3 }
zfsArcHits OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { arc 4 }
zfsArcMisses OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { arc 5 }
zfsArcC OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { arc 6 }
zfsArcMissPercent OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Arc Miss Percentage.
(Note: Floating precision sent across SNMP as a String"
::= { arc 8 }
zfsArcCacheHitRatio OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Arc Cache Hit Ration Percentage.
(Note: Floating precision sent across SNMP as a String"
::= { arc 9 }
zfsArcCacheMissRatio OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Arc Cache Miss Ration Percentage.
(Note: Floating precision sent across SNMP as a String"
::= { arc 10 }
zfsL2ArcHits OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { l2arc 1 }
zfsL2ArcMisses OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { l2arc 2 }
zfsL2ArcRead OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { l2arc 3 }
zfsL2ArcWrite OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { l2arc 4 }
zfsL2ArcSize OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { l2arc 5 }
zfsZilstatOps1sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { zil 1 }
zfsZilstatOps5sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { zil 2 }
zfsZilstatOps10sec OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { zil 3 }
alert NOTIFICATION-TYPE
OBJECTS { alertId, alertLevel, alertMessage }
STATUS current
DESCRIPTION
"An alert raised"
::= { notificationPrefix 1 }
alertId OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { notificationObjects 1 }
alertLevel OBJECT-TYPE
SYNTAX AlertLevelType
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { notificationObjects 2 }
alertMessage OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { notificationObjects 3 }
alertCancellation NOTIFICATION-TYPE
OBJECTS { alertId }
STATUS current
DESCRIPTION
"An alert cancelled"
::= { notificationPrefix 2 }
hddTempTable OBJECT-TYPE
SYNTAX SEQUENCE OF HDDTempEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Table of HDDs and their temperatures."
::= { trueNas 3 }
hddTempEntry OBJECT-TYPE
SYNTAX HDDTempEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"An entry containing a HDD and its temperature."
INDEX { hddTempIndex }
::= { hddTempTable 1 }
HDDTempEntry ::= SEQUENCE {
hddTempIndex Integer32,
hddTempDevice DisplayString,
hddTempValue Gauge32
}
hddTempIndex OBJECT-TYPE
SYNTAX Integer32 (0..65535)
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Reference index for each observed HDD."
::= { hddTempEntry 1 }
hddTempDevice OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The name of the HDD we are reading temperature from."
::= { hddTempEntry 2 }
hddTempValue OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The temperature of this HDD in mC."
::= { hddTempEntry 3 }
END

View File

@ -3549,7 +3549,7 @@
"storage_descr": "freenas-boot",
"storage_size": 14763950080,
"storage_units": 4096,
"storage_used": 9247969280,
"storage_used": 9247965184,
"storage_free": 0,
"storage_perc": 0,
"storage_perc_warn": 60,
@ -3705,7 +3705,7 @@
"storage_descr": "tank",
"storage_size": 191315023233024,
"storage_units": 131072,
"storage_used": 43403846877184,
"storage_used": 43403846746112,
"storage_free": 0,
"storage_perc": 0,
"storage_perc_warn": 60,
@ -4333,8 +4333,8 @@
"storage_descr": "freenas-boot",
"storage_size": 14763950080,
"storage_units": 4096,
"storage_used": 9247969280,
"storage_free": 5515980800,
"storage_used": 9247965184,
"storage_free": 5515984896,
"storage_perc": 63,
"storage_perc_warn": 60,
"storage_deleted": 0
@ -4489,8 +4489,8 @@
"storage_descr": "tank",
"storage_size": 191315023233024,
"storage_units": 131072,
"storage_used": 43403846877184,
"storage_free": 147911176355840,
"storage_used": 43403846746112,
"storage_free": 147911176486912,
"storage_perc": 23,
"storage_perc_warn": 60,
"storage_deleted": 0

View File

@ -1537,7 +1537,7 @@
"storage_descr": "freenas-boot",
"storage_size": 53150220288,
"storage_units": 4096,
"storage_used": 1074348032,
"storage_used": 1074343936,
"storage_free": 0,
"storage_perc": 0,
"storage_perc_warn": 60,
@ -1827,8 +1827,8 @@
"storage_descr": "freenas-boot",
"storage_size": 53150220288,
"storage_units": 4096,
"storage_used": 1074348032,
"storage_free": 52075872256,
"storage_used": 1074343936,
"storage_free": 52075876352,
"storage_perc": 2,
"storage_perc_warn": 60,
"storage_deleted": 0