Device duplication via Automation

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

Moderators: Developers, Moderators

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

Device duplication via Automation

Post by ign »

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

Post by ign »

any idea?
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Device duplication via Automation

Post by netniV »

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.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Re: Device duplication via Automation

Post by ign »

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

Post by ign »

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: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Device duplication via Automation

Post by netniV »

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).
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
ign
Posts: 8
Joined: Fri Mar 08, 2019 11:39 am

Re: Device duplication via Automation

Post by ign »

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: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Device duplication via Automation

Post by netniV »

Have to be careful with wildcards as one hostname could be subset of another.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests