Updated autodiscovery to use log_event better

This commit is contained in:
laf
2015-07-13 11:52:38 +01:00
parent 05d315775f
commit adb036759e
2 changed files with 12 additions and 27 deletions

View File

@ -11,7 +11,7 @@
* See COPYING for more details.
*/
function discover_new_device($hostname,$device,$method)
function discover_new_device($hostname,$device='',$method='', $interface='')
{
global $config, $debug;
@ -46,8 +46,13 @@ function discover_new_device($hostname,$device,$method)
echo("+[".$remote_device['hostname']."(".$remote_device['device_id'].")]");
discover_device($remote_device);
device_by_id_cache($remote_device_id, 1);
if ($remote_device_id) {
log_event("Device $". $remote_device['hostname'] ." ($ip) autodiscovered through $method on ".$device['hostname'], $remote_device_id, 'system');
if ($remote_device_id && is_array($device) && !empty($method)) {
$extra_log = '';
$int = ifNameDescr($interface);
if (is_array($int)) {
$extra_log = " (port " . $int['label'] . ") ";
}
log_event("Device $". $remote_device['hostname'] ." ($ip) $extra_log autodiscovered through $method on ".$device['hostname'], $remote_device_id, 'system');
} else {
log_event("$method discovery of ". $remote_device['hostname'] ." ($ip) failed - check ping and SNMP access", $device['device_id'], 'system');
}