Add Cisco Flash storage support (#14219)

* Add Cisco flash storage discovery

* Add Cisco flash storage polling

* LibreNMS indentation

* Move file to storage module

* move file to storage module

* Rename and check

Rename the file and add a check only against Cisco devices

* Rename file

* Change parameter from mib name to file name

Co-authored-by: Tony Murray <murraytony@gmail.com>

* Add a first test file for review - Nexus C9340 NXOS ver 10.2.2

* Add first device test files for review - Nexus 9340 ver 10.2.2

* Add Cisco IOS 15.2.7 on C2960X snmprec file

* Add Cisco IOS 15.2.7 on C2960X test data file

* Create nxos_n5548-7.3.3.snmprec

* Create nxos_n5548-7.3.3.json

* Update nxos_n5548-7.3.3.snmprec

* Update nxos_n9340-10.2.2.snmprec

* Update ios_c2960x-15.2.7.snmprec

* Update nxos_n5548-7.3.3.json

* Update nxos_n9340-10.2.2.json

* Update ios_c2960x-15.2.7.json

* Update cisco-flash.inc.php

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Félix Bouynot
2022-08-23 11:31:47 +02:00
committed by GitHub
parent 465fa3986a
commit b643a5033f
8 changed files with 415 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
/**
* cisco-flash.inc.php
*
* LibreNMS storage discovery module for Cisco Flash
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
* @copyright 2022 Félix Bouynot
* @author Félix Bouynot <felix.bouynot@setenforce.one>
*/
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);
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* cisco-flash.inc.php
*
* LibreNMS storage polling module for Cisco Flash
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link https://www.librenms.org
* @copyright 2022 Félix Bouynot
* @author Félix Bouynot <felix.bouynot@setenforce.one>
*/
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);

View File

@@ -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
}
]
}
}
}

View File

@@ -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
}
]
}
}
}

View File

@@ -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
}
]
}
}
}

View File

@@ -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|<private>
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

View File

@@ -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|<private>
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

View File

@@ -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|<private>
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