mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
autodiscovery fix (#14213)
* autodiscovery fix * much simpler approach * murrant suggestion * Simplify even more * Use nullable operator Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -76,18 +76,14 @@ function discover_new_device($hostname, $device = [], $method = '', $interface =
|
||||
}
|
||||
|
||||
try {
|
||||
$remote_device_id = addHost($hostname, '', '161', 'udp', Config::get('default_poller_group'));
|
||||
$remote_device_id = addHost($hostname, '', '161', 'udp', $device['poller_group']); // discover with actual poller group
|
||||
$remote_device = device_by_id_cache($remote_device_id, 1);
|
||||
echo '+[' . $remote_device['hostname'] . '(' . $remote_device['device_id'] . ')]';
|
||||
discover_device($remote_device);
|
||||
device_by_id_cache($remote_device_id, 1);
|
||||
|
||||
if ($remote_device_id && is_array($device) && ! empty($method)) {
|
||||
$extra_log = '';
|
||||
$int = cleanPort($interface);
|
||||
if (is_array($int)) {
|
||||
$extra_log = ' (port ' . $int['label'] . ') ';
|
||||
}
|
||||
$extra_log = is_array($interface) ? ' (port ' . cleanPort($interface)['label'] . ') ' : '';
|
||||
|
||||
log_event('Device ' . $remote_device['hostname'] . " ($ip) $extra_log autodiscovered through $method on " . $device['hostname'], $remote_device_id, 'discovery', 1);
|
||||
} else {
|
||||
|
@@ -41,9 +41,10 @@ function cleanPort($interface, $device = null)
|
||||
if (! $interface) {
|
||||
return $interface;
|
||||
}
|
||||
$interface['ifAlias'] = htmlentities($interface['ifAlias']);
|
||||
$interface['ifName'] = htmlentities($interface['ifName']);
|
||||
$interface['ifDescr'] = htmlentities($interface['ifDescr']);
|
||||
|
||||
$interface['ifAlias'] = htmlentities($interface['ifAlias'] ?? '');
|
||||
$interface['ifName'] = htmlentities($interface['ifName'] ?? '');
|
||||
$interface['ifDescr'] = htmlentities($interface['ifDescr'] ?? '');
|
||||
|
||||
if (! $device) {
|
||||
$device = device_by_id_cache($interface['device_id']);
|
||||
|
Reference in New Issue
Block a user