diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 5a93cbde6..001125d13 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -71,7 +71,7 @@ $config['snmp']['transports'] = array('udp', 'udp6', 'tcp', 'tcp6'); ### Autodiscovery Settings -$config['cdp_autocreate'] = false; ## Autodiscover unknown hosts seen via CDP +$config['dp_autocreate'] = false; ## Autodiscover unknown hosts seen via discovery protocols $config['snmp_autodiscovery'] = false; ## Autodiscover hosts on new subnets $config['discover_services'] = false; ## Autodiscover services via SNMP on devices of type "server" diff --git a/includes/discovery.inc.php b/includes/discovery.inc.php index 0cbb21654..49d2e4372 100755 --- a/includes/discovery.inc.php +++ b/includes/discovery.inc.php @@ -14,25 +14,29 @@ function discover_new_device($hostname) { - global $config; - if ( isDomainResolves($hostname . "." . $config['mydomain']) ) { - $dst_host = $hostname . "." . $config['mydomain']; - } else { - $dst_host = $hostname; - } - $ip = gethostbyname($dst_host); - - if ( match_network($config['nets'], $ip) ) + if ($config['dp_autocreate']) { - $remote_device_id = addHost ($dst_host, NULL, "v2c"); - if($remote_device_id) { - $remote_device = device_by_id_cache($remote_device_id, 1); - echo("+[".$remote_device['hostname']."(".$remote_device['device_id'].")]"); - discover_device($remote_device); - $remote_device = device_by_id_cache($remote_device_id, 1); - return $remote_device_id; + if (isDomainResolves($hostname . "." . $config['mydomain'])) + { + $dst_host = $hostname . "." . $config['mydomain']; + } else { + $dst_host = $hostname; + } + $ip = gethostbyname($dst_host); + + if (match_network($config['nets'], $ip)) + { + $remote_device_id = addHost ($dst_host, NULL, "v2c"); + if($remote_device_id) + { + $remote_device = device_by_id_cache($remote_device_id, 1); + echo("+[".$remote_device['hostname']."(".$remote_device['device_id'].")]"); + discover_device($remote_device); + $remote_device = device_by_id_cache($remote_device_id, 1); + return $remote_device_id; + } } } } diff --git a/includes/static-config.php b/includes/static-config.php index 44580f9be..cb6a81a02 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -946,6 +946,11 @@ if (!isset($config['log_file'])) $config['log_file'] = $config['install_dir'] . "/observium.log"; } +if (isset($config['cdp_autocreate'])) +{ + $config['dp_autocreate'] = $config['cdp_autocreate']; +} + if (!isset($config['mibdir'])) { $config['mibdir'] = $config['install_dir']."/mibs/";