change setting to dp_autocreate (with fallback to cdp_autocreate), allowing new device discovery through discovery protocols to be disabled

git-svn-id: http://www.observium.org/svn/observer/trunk@2464 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-15 14:49:49 +00:00
parent 8188bc0799
commit 34bf22a7e0
3 changed files with 26 additions and 17 deletions

View File

@@ -71,7 +71,7 @@ $config['snmp']['transports'] = array('udp', 'udp6', 'tcp', 'tcp6');
### Autodiscovery Settings ### 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['snmp_autodiscovery'] = false; ## Autodiscover hosts on new subnets
$config['discover_services'] = false; ## Autodiscover services via SNMP on devices of type "server" $config['discover_services'] = false; ## Autodiscover services via SNMP on devices of type "server"

View File

@@ -14,25 +14,29 @@
function discover_new_device($hostname) function discover_new_device($hostname)
{ {
global $config; global $config;
if ( isDomainResolves($hostname . "." . $config['mydomain']) ) { if ($config['dp_autocreate'])
$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 (isDomainResolves($hostname . "." . $config['mydomain']))
if($remote_device_id) { {
$remote_device = device_by_id_cache($remote_device_id, 1); $dst_host = $hostname . "." . $config['mydomain'];
echo("+[".$remote_device['hostname']."(".$remote_device['device_id'].")]"); } else {
discover_device($remote_device); $dst_host = $hostname;
$remote_device = device_by_id_cache($remote_device_id, 1); }
return $remote_device_id; $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;
}
} }
} }
} }

View File

@@ -946,6 +946,11 @@ if (!isset($config['log_file']))
$config['log_file'] = $config['install_dir'] . "/observium.log"; $config['log_file'] = $config['install_dir'] . "/observium.log";
} }
if (isset($config['cdp_autocreate']))
{
$config['dp_autocreate'] = $config['cdp_autocreate'];
}
if (!isset($config['mibdir'])) if (!isset($config['mibdir']))
{ {
$config['mibdir'] = $config['install_dir']."/mibs/"; $config['mibdir'] = $config['install_dir']."/mibs/";