diff --git a/includes/discovery/discovery-protocols.inc.php b/includes/discovery/discovery-protocols.inc.php index be1f93ea83..e91822bc01 100644 --- a/includes/discovery/discovery-protocols.inc.php +++ b/includes/discovery/discovery-protocols.inc.php @@ -41,46 +41,49 @@ 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) { - $interface = get_port_by_ifIndex($device['device_id'], $key); + 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) { - d_echo($cdp); + foreach ($cdp_if_array as $entry_key => $cdp) { + d_echo($cdp); - $cdp_ip = IP::fromHexString($cdp['cdpCacheAddress'], true); - $remote_device_id = find_device_id($cdp['cdpCacheDeviceId'], $cdp_ip); + $cdp_ip = IP::fromHexString($cdp['cdpCacheAddress'], true); + $remote_device_id = find_device_id($cdp['cdpCacheDeviceId'], $cdp_ip); - if (! $remote_device_id && - ! can_skip_discovery($cdp['cdpCacheDeviceId'], $cdp['cdpCacheVersion'], $cdp['cdpCachePlatform']) && - Config::get('autodiscovery.xdp') === true - ) { - $remote_device_id = discover_new_device($cdp['cdpCacheDeviceId'], $device, 'CDP', $interface); + if ( + ! $remote_device_id && + ! can_skip_discovery($cdp['cdpCacheDeviceId'], $cdp['cdpCacheVersion'], $cdp['cdpCachePlatform']) && + Config::get('autodiscovery.xdp') === true + ) { + $remote_device_id = discover_new_device($cdp['cdpCacheDeviceId'], $device, 'CDP', $interface); - if (! $remote_device_id && Config::get('discovery_by_ip', false)) { - $remote_device_id = discover_new_device($cdp_ip, $device, 'CDP', $interface); + if (! $remote_device_id && Config::get('discovery_by_ip', false)) { + $remote_device_id = discover_new_device($cdp_ip, $device, 'CDP', $interface); + } } - } - if ($interface['port_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) { - $remote_port_id = find_port_id($cdp['cdpCacheDevicePort'], '', $remote_device_id); - discover_link( - $interface['port_id'], - 'cdp', - $remote_port_id, - $cdp['cdpCacheDeviceId'], - $cdp['cdpCacheDevicePort'], - $cdp['cdpCachePlatform'], - $cdp['cdpCacheVersion'], - $device['device_id'], - $remote_device_id - ); - } - }//end foreach -}//end foreach -echo PHP_EOL; + if ($interface['port_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) { + $remote_port_id = find_port_id($cdp['cdpCacheDevicePort'], '', $remote_device_id); + discover_link( + $interface['port_id'], + 'cdp', + $remote_port_id, + $cdp['cdpCacheDeviceId'], + $cdp['cdpCacheDevicePort'], + $cdp['cdpCachePlatform'], + $cdp['cdpCacheVersion'], + $device['device_id'], + $remote_device_id + ); + } + } //end foreach + } //end foreach + echo PHP_EOL; +}//end if if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) { echo ' LLDP-MIB: '; diff --git a/includes/discovery/storage/aix.inc.php b/includes/discovery/storage/aix.inc.php index 6a56cb2a42..52819c5e81 100644 --- a/includes/discovery/storage/aix.inc.php +++ b/includes/discovery/storage/aix.inc.php @@ -8,20 +8,22 @@ * 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)) { - echo 'aix_filesystem : '; - foreach ($aix_filesystem as $aix_fs) { - if (isset($aix_fs['aixFsMountPoint'])) { - if ($aix_fs['aixFsType'] == 'jfs' || $aix_fs['aixFsType'] == 'jfs2') { // Only JFS or JFS2 - $aix_fs['aixFsSize'] = $aix_fs['aixFsSize'] * 1024 * 1024; - $aix_fs['aixFsFree'] = $aix_fs['aixFsFree'] * 1024 * 1024; - $aix_fs['aixFsUsed'] = $aix_fs['aixFsSize'] - $aix_fs['aixFsFree']; + if (is_array($aix_filesystem)) { + echo 'aix_filesystem : '; + foreach ($aix_filesystem as $aix_fs) { + if (isset($aix_fs['aixFsMountPoint'])) { + if ($aix_fs['aixFsType'] == 'jfs' || $aix_fs['aixFsType'] == 'jfs2') { // Only JFS or JFS2 + $aix_fs['aixFsSize'] = $aix_fs['aixFsSize'] * 1024 * 1024; + $aix_fs['aixFsFree'] = $aix_fs['aixFsFree'] * 1024 * 1024; + $aix_fs['aixFsUsed'] = $aix_fs['aixFsSize'] - $aix_fs['aixFsFree']; - discover_storage($valid_storage, $device, $aix_fs['aixFsIndex'], 'aixFileSystem', 'aix', $aix_fs['aixFsMountPoint'], $aix_fs['aixFsSize'], 1024 * 1024, $aix_fs['aixFsUsed']); + discover_storage($valid_storage, $device, $aix_fs['aixFsIndex'], 'aixFileSystem', 'aix', $aix_fs['aixFsMountPoint'], $aix_fs['aixFsSize'], 1024 * 1024, $aix_fs['aixFsUsed']); + } } - } - } // end foreach -} // endif -unset($aix_fs); + } // end foreach + } // endif + unset($aix_fs); +} diff --git a/includes/discovery/storage/freenas-dataset.inc.php b/includes/discovery/storage/freenas-dataset.inc.php index 56e6116611..b94786860f 100644 --- a/includes/discovery/storage/freenas-dataset.inc.php +++ b/includes/discovery/storage/freenas-dataset.inc.php @@ -1,20 +1,22 @@ $dataset) { - if (isset($dataset['datasetDescr'])) { - if (! in_array($dataset['datasetDescr'], $tmp_storage)) { - $dataset['datasetIndex'] = $index; - $dataset['datasetTotal'] = $dataset['datasetSize'] * $dataset['datasetAllocationUnits']; - $dataset['datasetAvail'] = ($dataset['datasetAvailable'] * $dataset['datasetAllocationUnits']); - $dataset['datasetUsed'] = $dataset['datasetTotal'] - $dataset['datasetAvail']; + if (is_array($datasetTable_array)) { + foreach ($datasetTable_array as $index => $dataset) { + if (isset($dataset['datasetDescr'])) { + if (!in_array($dataset['datasetDescr'], $tmp_storage)) { + $dataset['datasetIndex'] = $index; + $dataset['datasetTotal'] = $dataset['datasetSize'] * $dataset['datasetAllocationUnits']; + $dataset['datasetAvail'] = ($dataset['datasetAvailable'] * $dataset['datasetAllocationUnits']); + $dataset['datasetUsed'] = $dataset['datasetTotal'] - $dataset['datasetAvail']; - discover_storage($valid_storage, $device, $dataset['datasetIndex'], 'dataset', 'freenas-dataset', $dataset['datasetDescr'], $dataset['datasetTotal'], $dataset['datasetAllocationUnits'], $dataset['datasetUsed']); + discover_storage($valid_storage, $device, $dataset['datasetIndex'], 'dataset', 'freenas-dataset', $dataset['datasetDescr'], $dataset['datasetTotal'], $dataset['datasetAllocationUnits'], $dataset['datasetUsed']); + } } } } diff --git a/includes/discovery/storage/freenas-zpool.inc.php b/includes/discovery/storage/freenas-zpool.inc.php index e6a243673f..e02ed96e6f 100644 --- a/includes/discovery/storage/freenas-zpool.inc.php +++ b/includes/discovery/storage/freenas-zpool.inc.php @@ -1,20 +1,22 @@ $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']; + 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']; - discover_storage($valid_storage, $device, $zpool['zpoolIndex'], 'zpool', 'freenas-zpool', $zpool['zpoolDescr'], $zpool['zpoolTotal'], $zpool['zpoolAllocationUnits'], $zpool['zpoolUsed']); + discover_storage($valid_storage, $device, $zpool['zpoolIndex'], 'zpool', 'freenas-zpool', $zpool['zpoolDescr'], $zpool['zpoolTotal'], $zpool['zpoolAllocationUnits'], $zpool['zpoolUsed']); + } } } }