mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 00:24:21 +02:00
Improved the discovery of IP based devices
This commit is contained in:
@@ -69,17 +69,10 @@ foreach (dbFetchRows($sql, array($deviceid)) as $entry)
|
|||||||
}
|
}
|
||||||
arp_discovery_add_cache($ip);
|
arp_discovery_add_cache($ip);
|
||||||
|
|
||||||
// Log reverse DNS failures so the administrator can take action.
|
|
||||||
$name = gethostbyaddr($ip);
|
$name = gethostbyaddr($ip);
|
||||||
if ($name != $ip) { // gethostbyaddr returns the original argument on failure
|
echo("+");
|
||||||
echo("+");
|
$names[] = $name;
|
||||||
$names[] = $name;
|
$ips[$name] = $ip;
|
||||||
$ips[$name] = $ip;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo("-");
|
|
||||||
log_event("ARP discovery of $ip failed due to absent reverse DNS", $deviceid, 'interface', $if);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
echo("\n");
|
echo("\n");
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,14 @@ function discover_new_device($hostname)
|
|||||||
}
|
}
|
||||||
if ($debug) { echo("discovering $dst_host\n"); }
|
if ($debug) { echo("discovering $dst_host\n"); }
|
||||||
$ip = gethostbyname($dst_host);
|
$ip = gethostbyname($dst_host);
|
||||||
if ($ip == $dst_host) {
|
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) {
|
||||||
if ($debug) { echo("name lookup of $dst_host failed\n"); }
|
// $ip isn't a valid IP so it must be a name.
|
||||||
return FALSE;
|
if ($ip == $dst_host) {
|
||||||
} else {
|
if ($debug) { echo("name lookup of $dst_host failed\n"); }
|
||||||
if ($debug) { echo("ip lookup result: $ip\n"); }
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if ($debug) { echo("ip lookup result: $ip\n"); }
|
||||||
|
|
||||||
$dst_host = rtrim($dst_host, '.'); // remove trailing dot
|
$dst_host = rtrim($dst_host, '.'); // remove trailing dot
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user