add os check in discovery for aix/freenas storage and cisco cdp (#15104)

* add os check in discovery for aix/freenas storage and cisco cdp

* use os_group = cisco
This commit is contained in:
Peter Childs
2023-07-25 09:37:23 +09:30
committed by GitHub
parent cce3dc0746
commit 0b98b6ff72
4 changed files with 80 additions and 71 deletions

View File

@@ -41,10 +41,11 @@ if ($device['os'] == 'ironware') {
echo PHP_EOL;
}//end if
echo ' CISCO-CDP-MIB: ';
$cdp_array = snmpwalk_group($device, 'cdpCache', 'CISCO-CDP-MIB', 2);
if (isset($device['os_group']) && $device['os_group'] == 'cisco') {
echo ' CISCO-CDP-MIB: ';
$cdp_array = snmpwalk_group($device, 'cdpCache', 'CISCO-CDP-MIB', 2);
foreach ($cdp_array as $key => $cdp_if_array) {
foreach ($cdp_array as $key => $cdp_if_array) {
$interface = get_port_by_ifIndex($device['device_id'], $key);
foreach ($cdp_if_array as $entry_key => $cdp) {
@@ -53,7 +54,8 @@ foreach ($cdp_array as $key => $cdp_if_array) {
$cdp_ip = IP::fromHexString($cdp['cdpCacheAddress'], true);
$remote_device_id = find_device_id($cdp['cdpCacheDeviceId'], $cdp_ip);
if (! $remote_device_id &&
if (
! $remote_device_id &&
! can_skip_discovery($cdp['cdpCacheDeviceId'], $cdp['cdpCacheVersion'], $cdp['cdpCachePlatform']) &&
Config::get('autodiscovery.xdp') === true
) {
@@ -78,9 +80,10 @@ foreach ($cdp_array as $key => $cdp_if_array) {
$remote_device_id
);
}
}//end foreach
}//end foreach
echo PHP_EOL;
} //end foreach
} //end foreach
echo PHP_EOL;
}//end if
if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) {
echo ' LLDP-MIB: ';

View File

@@ -8,9 +8,10 @@
* the source code distribution for details.
*/
$aix_filesystem = snmpwalk_cache_oid($device, 'aixFsTableEntry', [], 'IBM-AIX-MIB');
if ($device['os'] == 'aix') {
$aix_filesystem = snmpwalk_cache_oid($device, 'aixFsTableEntry', [], 'IBM-AIX-MIB');
if (is_array($aix_filesystem)) {
if (is_array($aix_filesystem)) {
echo 'aix_filesystem : ';
foreach ($aix_filesystem as $aix_fs) {
if (isset($aix_fs['aixFsMountPoint'])) {
@@ -23,5 +24,6 @@ if (is_array($aix_filesystem)) {
}
}
} // end foreach
} // endif
unset($aix_fs);
} // endif
unset($aix_fs);
}

View File

@@ -1,14 +1,15 @@
<?php
$datasetTable_array = snmpwalk_cache_oid($device, 'datasetTable', null, 'FREENAS-MIB');
if ($device['os'] == 'truenas') {
$datasetTable_array = snmpwalk_cache_oid($device, 'datasetTable', null, 'FREENAS-MIB');
$sql = "SELECT `storage_descr` FROM `storage` WHERE `device_id` = '" . $device['device_id'] . "' AND `storage_type` != 'dataset'";
$tmp_storage = dbFetchColumn($sql);
$sql = "SELECT `storage_descr` FROM `storage` WHERE `device_id` = '" . $device['device_id'] . "' AND `storage_type` != 'dataset'";
$tmp_storage = dbFetchColumn($sql);
if (is_array($datasetTable_array)) {
if (is_array($datasetTable_array)) {
foreach ($datasetTable_array as $index => $dataset) {
if (isset($dataset['datasetDescr'])) {
if (! in_array($dataset['datasetDescr'], $tmp_storage)) {
if (!in_array($dataset['datasetDescr'], $tmp_storage)) {
$dataset['datasetIndex'] = $index;
$dataset['datasetTotal'] = $dataset['datasetSize'] * $dataset['datasetAllocationUnits'];
$dataset['datasetAvail'] = ($dataset['datasetAvailable'] * $dataset['datasetAllocationUnits']);
@@ -18,4 +19,5 @@ if (is_array($datasetTable_array)) {
}
}
}
}
}

View File

@@ -1,14 +1,15 @@
<?php
$zpooltable_array = snmpwalk_cache_oid($device, 'zpoolTable', null, 'FREENAS-MIB');
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);
$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)) {
if (is_array($zpooltable_array)) {
foreach ($zpooltable_array as $index => $zpool) {
if (isset($zpool['zpoolDescr'])) {
if (! in_array($zpool['zpoolDescr'], $tmp_storage)) {
if (!in_array($zpool['zpoolDescr'], $tmp_storage)) {
$zpool['zpoolIndex'] = $index;
$zpool['zpoolTotal'] = $zpool['zpoolSize'] * $zpool['zpoolAllocationUnits'];
$zpool['zpoolAvail'] = ($zpool['zpoolAvailable'] * $zpool['zpoolAllocationUnits']);
@@ -18,4 +19,5 @@ if (is_array($zpooltable_array)) {
}
}
}
}
}