diff --git a/includes/discovery/storage/cisco-flash.inc.php b/includes/discovery/storage/cisco-flash.inc.php new file mode 100644 index 0000000000..6ad3c129b7 --- /dev/null +++ b/includes/discovery/storage/cisco-flash.inc.php @@ -0,0 +1,42 @@ +. + * + * @package LibreNMS + * @link https://www.librenms.org + * @copyright 2022 Félix Bouynot + * @author Félix Bouynot + */ + +use LibreNMS\Util\Number; + +if ($device['os_group'] == 'cisco') { + $ciscoFlashPartitionName = snmpwalk_cache_oid($device, 'ciscoFlashPartitionName', null, 'CISCO-FLASH-MIB'); + $ciscoFlashDeviceName = snmpwalk_cache_oid($device, 'ciscoFlashDeviceName', null, 'CISCO-FLASH-MIB'); + foreach ($ciscoFlashPartitionName as $index => $partitionName) { + $name = array_shift($ciscoFlashDeviceName[$index[0]]) . '(' . array_shift($partitionName) . '):'; + $oids = array('ciscoFlashPartitionSize.' . $index, 'ciscoFlashPartitionFreeSpace.' . $index, 'ciscoFlashPartitionSizeExtended.' . $index, 'ciscoFlashPartitionFreeSpaceExtended.' . $index); + $entry = array_shift(snmp_get_multi($device, $oids, '-OQUs', 'CISCO-FLASH-MIB')); + $storage_size = (Number::cast($entry['ciscoFlashPartitionSize']) === 4294967295 ? $entry['ciscoFlashPartitionSizeExtended'] : $entry['ciscoFlashPartitionSize']); + $storage_free = (Number::cast($entry['ciscoFlashPartitionFreeSpace']) === 4294967295 ? $entry['ciscoFlashPartitionFreeSpaceExtended'] : $entry['ciscoFlashPartitionFreeSpace']); + $storage_used = $storage_size - $storage_free; + $storage_units = 1; + discover_storage($valid_storage, $device, $index, 'flash', 'cisco-flash', $name, $storage_size, $storage_units, $storage_used); + } + unset ($ciscoFlashPartitionName, $storage_size, $storage_free, $storage_used, $storage_units, $oids, $entry); +} diff --git a/includes/polling/storage/cisco-flash.inc.php b/includes/polling/storage/cisco-flash.inc.php new file mode 100644 index 0000000000..f2a092a23e --- /dev/null +++ b/includes/polling/storage/cisco-flash.inc.php @@ -0,0 +1,35 @@ +. + * + * @package LibreNMS + * @link https://www.librenms.org + * @copyright 2022 Félix Bouynot + * @author Félix Bouynot + */ + +use LibreNMS\Util\Number; + +$oids = array('ciscoFlashPartitionSize.' . $storage['storage_index'], 'ciscoFlashPartitionFreeSpace.' . $storage['storage_index'], 'ciscoFlashPartitionSizeExtended.' . $storage['storage_index'], 'ciscoFlashPartitionFreeSpaceExtended.' . $storage['storage_index']); +$entry = array_shift(snmp_get_multi($device, $oids, '-OQUs', 'CISCO-FLASH-MIB')); +$storage['size'] = (Number::cast($entry['ciscoFlashPartitionSize']) === 4294967295 ? $entry['ciscoFlashPartitionSizeExtended'] : $entry['ciscoFlashPartitionSize']); +$storage['free'] = (Number::cast($entry['ciscoFlashPartitionFreeSpace']) === 4294967295 ? $entry['ciscoFlashPartitionFreeSpaceExtended'] : $entry['ciscoFlashPartitionFreeSpace']); +$storage['used'] = $storage['size'] - $storage['free']; +$storage['units'] = 1; + +unset ($oids, $entry); diff --git a/tests/data/ios_c2960x-15.2.7.json b/tests/data/ios_c2960x-15.2.7.json new file mode 100644 index 0000000000..d4beddb044 --- /dev/null +++ b/tests/data/ios_c2960x-15.2.7.json @@ -0,0 +1,38 @@ +{ + "storage": { + "discovery": { + "storage": [ + { + "storage_mib": "cisco-flash", + "storage_index": "1.1", + "storage_type": "flash", + "storage_descr": "flash1(flash1):", + "storage_size": 122185728, + "storage_units": 1, + "storage_used": 53897216, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + } + ] + }, + "poller": { + "storage": [ + { + "storage_mib": "cisco-flash", + "storage_index": "1.1", + "storage_type": "flash", + "storage_descr": "flash1(flash1):", + "storage_size": 122185728, + "storage_units": 1, + "storage_used": 53897216, + "storage_free": 68288512, + "storage_perc": 44, + "storage_perc_warn": 60, + "storage_deleted": 0 + } + ] + } + } +} diff --git a/tests/data/nxos_n5548-7.3.3.json b/tests/data/nxos_n5548-7.3.3.json new file mode 100644 index 0000000000..c7f028fadd --- /dev/null +++ b/tests/data/nxos_n5548-7.3.3.json @@ -0,0 +1,116 @@ +{ + "storage": { + "discovery": { + "storage": [ + { + "storage_mib": "cisco-flash", + "storage_index": "1.1", + "storage_type": "flash", + "storage_descr": "bootflash(sup-local):", + "storage_size": 1650905088, + "storage_units": 1, + "storage_used": 898289664, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "2.1", + "storage_type": "flash", + "storage_descr": "debug(sup-local):", + "storage_size": 20971520, + "storage_units": 1, + "storage_used": 0, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "3.1", + "storage_type": "flash", + "storage_descr": "logflash(sup-local):", + "storage_size": 419430400, + "storage_units": 1, + "storage_used": 73793536, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "4.1", + "storage_type": "flash", + "storage_descr": "volatile(sup-local):", + "storage_size": 157286400, + "storage_units": 1, + "storage_used": 29515776, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + } + ] + }, + "poller": { + "storage": [ + { + "storage_mib": "cisco-flash", + "storage_index": "1.1", + "storage_type": "flash", + "storage_descr": "bootflash(sup-local):", + "storage_size": 1650905088, + "storage_units": 1, + "storage_used": 898289664, + "storage_free": 752615424, + "storage_perc": 54, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "2.1", + "storage_type": "flash", + "storage_descr": "debug(sup-local):", + "storage_size": 20971520, + "storage_units": 1, + "storage_used": 0, + "storage_free": 20971520, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "3.1", + "storage_type": "flash", + "storage_descr": "logflash(sup-local):", + "storage_size": 419430400, + "storage_units": 1, + "storage_used": 73793536, + "storage_free": 345636864, + "storage_perc": 18, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "4.1", + "storage_type": "flash", + "storage_descr": "volatile(sup-local):", + "storage_size": 157286400, + "storage_units": 1, + "storage_used": 29515776, + "storage_free": 127770624, + "storage_perc": 19, + "storage_perc_warn": 60, + "storage_deleted": 0 + } + ] + } + } +} diff --git a/tests/data/nxos_n9340-10.2.2.json b/tests/data/nxos_n9340-10.2.2.json new file mode 100644 index 0000000000..545748247e --- /dev/null +++ b/tests/data/nxos_n9340-10.2.2.json @@ -0,0 +1,116 @@ +{ + "storage": { + "discovery": { + "storage": [ + { + "storage_mib": "cisco-flash", + "storage_index": "1.1", + "storage_type": "flash", + "storage_descr": "bootflash(sup-local):", + "storage_size": 116589211648, + "storage_units": 1, + "storage_used": 11533791232, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "2.1", + "storage_type": "flash", + "storage_descr": "debug(sup-local):", + "storage_size": 5242880, + "storage_units": 1, + "storage_used": 1130496, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "3.1", + "storage_type": "flash", + "storage_descr": "logflash(sup-local):", + "storage_size": 8320901120, + "storage_units": 1, + "storage_used": 691933184, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "4.1", + "storage_type": "flash", + "storage_descr": "volatile(sup-local):", + "storage_size": 2147483648, + "storage_units": 1, + "storage_used": 28672, + "storage_free": 0, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + } + ] + }, + "poller": { + "storage": [ + { + "storage_mib": "cisco-flash", + "storage_index": "1.1", + "storage_type": "flash", + "storage_descr": "bootflash(sup-local):", + "storage_size": 116589211648, + "storage_units": 1, + "storage_used": 11533791232, + "storage_free": 105055420416, + "storage_perc": 10, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "2.1", + "storage_type": "flash", + "storage_descr": "debug(sup-local):", + "storage_size": 5242880, + "storage_units": 1, + "storage_used": 1130496, + "storage_free": 4112384, + "storage_perc": 22, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "3.1", + "storage_type": "flash", + "storage_descr": "logflash(sup-local):", + "storage_size": 8320901120, + "storage_units": 1, + "storage_used": 691933184, + "storage_free": 7628967936, + "storage_perc": 8, + "storage_perc_warn": 60, + "storage_deleted": 0 + }, + { + "storage_mib": "cisco-flash", + "storage_index": "4.1", + "storage_type": "flash", + "storage_descr": "volatile(sup-local):", + "storage_size": 2147483648, + "storage_units": 1, + "storage_used": 28672, + "storage_free": 2147454976, + "storage_perc": 0, + "storage_perc_warn": 60, + "storage_deleted": 0 + } + ] + } + } +} diff --git a/tests/snmpsim/ios_c2960x-15.2.7.snmprec b/tests/snmpsim/ios_c2960x-15.2.7.snmprec new file mode 100644 index 0000000000..f7b4b96854 --- /dev/null +++ b/tests/snmpsim/ios_c2960x-15.2.7.snmprec @@ -0,0 +1,14 @@ +1.3.6.1.2.1.1.1.0|4x|22436973636f20494f5320536f6674776172652c2043323936305820536f66747761726520284332393630582d554e4956455253414c4b392d4d292c2056657273696f6e2031352e322837294530612c2052454c4541534520534f4654574152452028666331290a546563686e6963616c20537570706f72743a20687474703a2f2f7777772e636973636f2e636f6d2f74656368737570706f72740d0a436f707972696768742028632920313938362d3230313920627920436973636f2053797374656d732c20496e632e0d0a436f6d70696c6564204672692031322d4170722d31392030343a30392062792070726f645f72656c5f7465616d22 +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.1208 +1.3.6.1.2.1.1.5.0|4| +1.3.6.1.4.1.9.9.10.1.1.2.1.7.1|4|flash1 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.2|4|flash2 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.3|4|flash3 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.4|4|flash4 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.5|4|flash5 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.6|4|flash6 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.7|4|flash7 +1.3.6.1.4.1.9.9.10.1.1.2.1.7.8|4|flash8 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.1.1|66|122185728 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.1.1|66|68288512 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.1.1|4|flash1 diff --git a/tests/snmpsim/nxos_n5548-7.3.3.snmprec b/tests/snmpsim/nxos_n5548-7.3.3.snmprec new file mode 100644 index 0000000000..86c0ddaeae --- /dev/null +++ b/tests/snmpsim/nxos_n5548-7.3.3.snmprec @@ -0,0 +1,27 @@ +1.3.6.1.2.1.1.1.0|4|Cisco NX-OS(tm) n5000, Software (n5000-uk9), Version 7.3(3)N1(1), RELEASE SOFTWARE Copyright (c) 2002-2012, 2016-2017 by Cisco Systems, Inc. Device Manager Version 6.0(2)N1(1),Compiled 4/27/2018 9:00:00 +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.12.3.1.3.1084 +1.3.6.1.2.1.1.5.0|4| +1.3.6.1.4.1.9.9.10.1.1.2.1.7.1|4|bootflash +1.3.6.1.4.1.9.9.10.1.1.2.1.7.2|4|debug +1.3.6.1.4.1.9.9.10.1.1.2.1.7.3|4|logflash +1.3.6.1.4.1.9.9.10.1.1.2.1.7.4|4|volatile +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.1.1|66|1650905088 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.2.1|66|20971520 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.3.1|66|419430400 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.4.1|66|157286400 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.1.1|66|752615424 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.2.1|66|20971520 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.3.1|66|345636864 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.4.1|66|127770624 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.1.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.2.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.3.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.4.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.1.1|70|1650905088 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.2.1|70|20971520 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.3.1|70|419430400 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.4.1|70|157286400 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.1.1|70|752615424 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.2.1|70|20971520 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.3.1|70|345636864 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.4.1|70|127770624 diff --git a/tests/snmpsim/nxos_n9340-10.2.2.snmprec b/tests/snmpsim/nxos_n9340-10.2.2.snmprec new file mode 100644 index 0000000000..f9e02c9faa --- /dev/null +++ b/tests/snmpsim/nxos_n9340-10.2.2.snmprec @@ -0,0 +1,27 @@ +1.3.6.1.2.1.1.1.0|4|Cisco NX-OS(tm) Nexus9000 C93240YC-FX2, Software (NXOS 64-bit), Version 10.2(2), RELEASE SOFTWARE Copyright (c) 2002-2021 by Cisco Systems, Inc. Compiled 12/14/2021 23:00:00 +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.12.3.1.3.2010 +1.3.6.1.2.1.1.5.0|4| +1.3.6.1.4.1.9.9.10.1.1.2.1.7.1|4|bootflash +1.3.6.1.4.1.9.9.10.1.1.2.1.7.2|4|debug +1.3.6.1.4.1.9.9.10.1.1.2.1.7.3|4|logflash +1.3.6.1.4.1.9.9.10.1.1.2.1.7.4|4|volatile +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.1.1|66|4294967295 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.2.1|66|5242880 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.3.1|66|4294967295 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.4.1|66|2147483648 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.1.1|66|4294967295 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.2.1|66|4112384 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.3.1|66|4294967295 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.4.1|66|2147454976 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.1.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.2.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.3.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.4.1|4|sup-local +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.1.1|70|116589211648 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.2.1|70|5242880 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.3.1|70|8320901120 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.4.1|70|2147483648 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.1.1|70|105055420416 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.2.1|70|4112384 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.3.1|70|7628967936 +1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.4.1|70|2147454976