Device duplication via Automation

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Moderators, Developers

Post Reply
Author
Message
ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Device duplication via Automation

#1 Post by ign » Fri Mar 08, 2019 11:52 am

Hello,

I've been testing the automation rules on 1.2.1 and 1.2.2 for our company and found this duplication problem.

Device A is on different subnetworks, and even though "Allow same sysName on different hosts" is disabled, and the sysname is the same, I get the device added twice or more.
This automatic scan is done via two different "Network" entries. For example 192.168.1.0/24 and 192.168.0.0/24. Does this have anything to do?

Debug doesn't show any sign of trying to compare sysname:

Code: Select all

Device: 172.X.X.X, Checking DNS: Not found, Status: Not in Cacti, Ping: Responded, SNMP: A Responded, Template: Cisco Router
OS: Debian 9
Cacti: 1.2.2
MariaDB: 10.1
PHP: 7.0

Any help would be appreciated.
Thanks,
IGN.

ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Re: Device duplication via Automation

#2 Post by ign » Fri Mar 15, 2019 7:43 am

any idea?

netniV
Cacti Guru User
Posts: 2809
Joined: Sun Aug 27, 2017 12:05 am

Re: Device duplication via Automation

#3 Post by netniV » Sun Mar 17, 2019 6:55 pm

That option relates specifically to this bit of code during automation:

Code: Select all

if ($network['same_sysname'] == '') {
        $isDuplicateSysName = 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));
        if ($isDuplicateSysName) {
                automation_debug(", Skipping sysName '" . $snmp_sysName . "' already Discovered!\n");
                markIPDone($device['ip_address'], $network_id);
                continue;
        }
}
So, if the option is off, it will try to find the same system name used by a device with a different IP and if so, continues past it. My only suggestion is that whilst they may appear to look equal, they are in fact not.

ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Re: Device duplication via Automation

#4 Post by ign » Mon Mar 18, 2019 12:09 pm

Thanks for your help, it helped me debug a little bit more and I think the problem lies when enabling 'Automatically add to Cacti'. This option overrides the same sysname comparison, I disabled it and it works as expected.

Furthermore, if I understood the code correctly, using the 'automation_devices' table limits the comparison to same network, I thought the comparison was done to devices already present in Cacti. This will cause duplications in my case anyway. Was this behaviour intended?

ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Re: Device duplication via Automation

#5 Post by ign » Thu Mar 21, 2019 9:38 am

Should i file the incompatibility between 'Automatically add to Cacti' and 'Allow same sysName on different hosts' as a bug? does anyone believe i'm considering something wrong?

netniV
Cacti Guru User
Posts: 2809
Joined: Sun Aug 27, 2017 12:05 am

Re: Device duplication via Automation

#6 Post by netniV » Thu Mar 21, 2019 10:25 am

I think it's more a feature request than a bug since it has always operated that way. We would need a second option for blocking it when adding to the system (though I did think the system tried to detect the same hostname... but this is the description).

ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Re: Device duplication via Automation

#7 Post by ign » Thu Mar 21, 2019 3:56 pm

I found that indeed there was a comparison to devices present in cacti, but it didn't work in my case because the column "snmp_sysname" from table "host", has some symbols (example: \"AAA\") which is different to column "sysname" from table "automation_devices" so it didn't match the SELECT. I don't know if this is the result of changing the db encoding to utf8mb4, but changing (with duct tape) that SELECT statement with some wildcards made it work.

netniV
Cacti Guru User
Posts: 2809
Joined: Sun Aug 27, 2017 12:05 am

Re: Device duplication via Automation

#8 Post by netniV » Thu Mar 21, 2019 5:11 pm

Have to be careful with wildcards as one hostname could be subset of another.

Post Reply