Merge pull request #3759 from Misch-/master

Always log why discovery fails
This commit is contained in:
Neil Lathwood
2016-07-11 19:02:51 +01:00
committed by GitHub

View File

@@ -28,13 +28,16 @@ function discover_new_device($hostname, $device = '', $method = '', $interface =
// $ip isn't a valid IP so it must be a name.
if ($ip == $dst_host) {
d_echo("name lookup of $dst_host failed\n");
log_event("$method discovery of " . $dst_host . " failed - Check name lookup", $device['device_id'], 'discovery');
return false;
}
} elseif (filter_var($dst_host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === true || filter_var($dst_host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === true) {
// gethostbyname returned a valid $ip, was $dst_host an IP?
if ($config['discovery_by_ip'] === false) {
d_echo('Discovery by IP disabled, skipping ' . $dst_host);
log_event("$method discovery of " . $dst_host . " failed - Discovery by IP disabled", $device['device_id'], 'discovery');
return false;
}
}
@@ -65,10 +68,13 @@ function discover_new_device($hostname, $device = '', $method = '', $interface =
log_event('Device ' . $remote_device['hostname'] . " ($ip) $extra_log autodiscovered through $method on " . $device['hostname'], $remote_device_id, 'discovery');
} else {
log_event("$method discovery of " . $remote_device['hostname'] . " ($ip) failed - check ping and SNMP access", $device['device_id'], 'discovery');
log_event("$method discovery of " . $remote_device['hostname'] . " ($ip) failed - Check ping and SNMP access", $device['device_id'], 'discovery');
}
return $remote_device_id;
}
else {
log_event("$method discovery of " . $dst_host . " ($ip) failed - Check ping and SNMP access", $device['device_id'], 'discovery');
}
} else {
d_echo("$ip not in a matched network - skipping\n");