Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sun May 26, 2019 4:26 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Device duplication via Automation
PostPosted: Fri Mar 08, 2019 11:52 am 
Offline

Joined: Fri Mar 08, 2019 11:39 am
Posts: 8
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:
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.


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Fri Mar 15, 2019 7:43 am 
Offline

Joined: Fri Mar 08, 2019 11:39 am
Posts: 8
any idea?


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Sun Mar 17, 2019 6:55 pm 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2474
That option relates specifically to this bit of code during automation:
Code:
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.

_________________
Official Cacti Developer

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

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Mon Mar 18, 2019 12:09 pm 
Offline

Joined: Fri Mar 08, 2019 11:39 am
Posts: 8
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?


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Thu Mar 21, 2019 9:38 am 
Offline

Joined: Fri Mar 08, 2019 11:39 am
Posts: 8
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?


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Thu Mar 21, 2019 10:25 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2474
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).

_________________
Official Cacti Developer

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

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Thu Mar 21, 2019 3:56 pm 
Offline

Joined: Fri Mar 08, 2019 11:39 am
Posts: 8
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.


Top
 Profile  
 
 Post subject: Re: Device duplication via Automation
PostPosted: Thu Mar 21, 2019 5:11 pm 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2474
Have to be careful with wildcards as one hostname could be subset of another.

_________________
Official Cacti Developer

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

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group