I propose to add functionality for changing the IP address of devices previously added through automation.
For example, there is a device added via automation. Someone on the network changed the IP address of this device but did not change the name in the settings. Our discovery (if you look at the debug) discards these devices because the name is already in the database.
I suggest doing something like this in poller_automation.php to automaticaly change IP address of the host after 1 day not accessibility:
Code: Select all
if ($network['same_sysname'] == '') {
$isDuplicateSysNameDiscovery = db_fetch_cell_prepared('SELECT COUNT(*)
FROM automation_devices
WHERE network_id = ?
AND sysName != ""
AND ip != ?
AND sysName = ?',
array($network_id, $device['ip_address'], $snmp_sysName));
$isDuplicateSysNameCacti = db_fetch_cell_prepared('SELECT COUNT(*)
FROM host
WHERE snmp_sysName = ?
AND hostname != ?',
array($snmp_sysName, $device['ip_address']));
if ($isDuplicateSysNameDiscovery || $isDuplicateSysNameCacti) {
$old_host_id = db_fetch_cell_prepared('SELECT h.id
FROM host h
WHERE h.snmp_sysName = ?
AND h.hostname != ?
AND h.status = 1 AND h.status_event_count * ( IFNULL( (SELECT value FROM settings WHERE name = \'poller_interval\' LIMIT 1), 300 ) ) > 1*24*60*60',
array($snmp_sysName, $device['ip_address']));
if ( $old_host_id ) {
db_execute_prepared('UPDATE host
SET hostname = ?
WHERE id = ?',
array($device['ip_address'], $old_host_id));
cacti_log(sprintf("INFO: Old device hostname not accesseble. Changeing hostname address to new - '" .$device['ip_address']. "'" ), true, 'AUTOM8');
}
automation_debug(", Skipping sysName '" . $snmp_sysName . "' already Discovered!\n");
markIPDone($device['ip_address'], $network_id);
continue;
}
}