Cacti / plugin_mactrack

Mactrack Plugin for Cacti
GNU General Public License v2.0
12 stars 25 forks source link

CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '7' for key 'PRIMARY' #137

Closed Hub18 closed 3 years ago

Hub18 commented 4 years ago

Hi there,

We are experiencing following error messages starting with "Error: Duplicate entry '7' for key 'PRIMARY'".

We had this issue while using cmd.php and now after updating to spine it's still not resolved. After digging more into the logs I have found that duplicate entry have been attempted for Primary key. Can anyone please help for us to understand this issue.

Cacti Version | 1.2.3 Cacti OS | unix SPINE 1.2.13 Copyright 2004-2020 by The Cacti Group (Different version of Cacti and Spine!)

Concurrent Processes 80
Max Threads 50
PHP Servers 50
Script Timeout 25
Max OID 10
PHP Version 7.2.24-0ubuntu0.18.04.6
version 10.1.44-MariaDB-0ubuntu0.18.04.1

Error message in Log:

2020/07/15 14:26:05 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[228]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[880]:db_execute(), /lib/database.php[187]:db_execute_prepared())
--
2020/07/15 14:26:05 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cacti.mac_track_ports' doesn't exist
2020/07/15 14:26:05 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[228]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[863]:db_execute(), /lib/database.php[187]:db_execute_prepared())
2020/07/15 14:26:05 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cacti.mac_track_aggregated_ports' doesn't exist

2020/07/15 14:26:05 - CMDPHP SQL Backtrace: (/plugins/mactrack/mactrack_resolver.php[186]:db_execute(), /lib/database.php[187]:db_execute_prepared())
2020/07/15 14:26:04 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown column 'N' in 'field list'

2020/07/15 14:22:19 - CMDPHP SQL Backtrace: (/plugins/mactrack/mactrack_scanner.php[111]:db_process_add(), /plugins/mactrack/lib/mactrack_functions.php[2104]:db_execute_prepared())
2020/07/15 14:22:19 - CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '7' for key 'PRIMARY'
bmfmancini commented 4 years ago

I would move this over to the mactrack tracker also there was a fix pushed out for 1.2.12 that corrected this type of error in Cacti

TheWitness commented 4 years ago

I've just installed version 4.4 and though I don't see the missing tables, I would not think that these issues would occur on a Cacti version 1.2.14 system. I'll make some updates relative to this ticket, but re-install once you are on 1.2.14.

luisanfe commented 3 years ago

I see this error when I launch one of my 6 Automation Netwoks discovery, and only with one of them, since I had an error launching it. I am running cacti 1.2.15. I've tested to delete the network and adding it again with the same result. With other networks runs OK.

Debug log: 2021-06-29 07:34:46 - AUTOM8 [PID: 3400393] Found 0 Threads

2021-06-29 07:34:41 - AUTOM8 [PID: 3400393] Found 0 Threads 2021-06-29 07:34:36 - AUTOM8 [PID: 3400393] Found 0 Threads 2021-06-29 07:34:31 - AUTOM8 [PID: 3400393] Found 0 Threads 2021-06-29 07:34:26 - AUTOM8 [PID: 3400393] Found 0 Threads 2021-06-29 07:34:26 - AUTOM8 [PID: 3400393] Checking for Running Threads 2021-06-29 07:34:21 - AUTOM8 [PID: 3400421] Network PAL Networks Thread 10 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400415] Network PAL Networks Thread 8 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400411] Network PAL Networks Thread 7 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400417] Network PAL Networks Thread 9 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400405] Network PAL Networks Thread 5 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400403] Network PAL Networks Thread 4 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400407] Network PAL Networks Thread 6 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:21 - AUTOM8 [PID: 3400399] Network PAL Networks Thread 2 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:20 - AUTOM8 [PID: 3400397] Network PAL Networks Thread 1 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:20 - AUTOM8 [PID: 3400401] Network PAL Networks Thread 3 Finished, 0 IPs Scanned, 0 IPs Responded to Ping, 0 Responded to SNMP, 0 Device Added, 0 Graphs Added to Cacti 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=10 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 10 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=9 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 9 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=8 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 8 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=7 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 7 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=6 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 6 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=5 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 5 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=4 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 4 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=3 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 3 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=2 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 2 2021-06-29 07:34:20 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /usr/share/cacti/poller_automation.php --poller=1 --thread=1 --network=8 --force --debug] 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Launching Thread 1 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Automation will use 10 Threads 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] A Total of 381 IP Addresses Primed 2021-06-29 07:34:20 - CMDPHP SQL Backtrace: (/poller_automation.php[276]:automation_primeIPAddressTable(), /lib/api_automation.php[3208]:db_execute(), /lib/database.php[213]:db_execute_prepared()) 2021-06-29 07:34:20 - CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '10.229.90.250' for key 'PRIMARY' 2021-06-29 07:34:20 - CMDPHP SQL Backtrace: (/poller_automation.php[276]:automation_primeIPAddressTable(), /lib/api_automation.php[3208]:db_execute(), /lib/database.php[213]:db_execute_prepared()) 2021-06-29 07:34:20 - CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '10.229.84.129' for key 'PRIMARY' 2021-06-29 07:34:20 - CMDPHP SQL Backtrace: (/poller_automation.php[276]:automation_primeIPAddressTable(), /lib/api_automation.php[3208]:db_execute(), /lib/database.php[213]:db_execute_prepared()) 2021-06-29 07:34:20 - CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '10.229.88.1' for key 'PRIMARY' 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Network Discover is now running for Subnet Range '8' 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Removing any orphan entries 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Killing any prior running threads 2021-06-29 07:34:20 - AUTOM8 [PID: 3400393] Thread master about to launch collector threads

luisanfe commented 3 years ago

I've solved my issue with: TRUNCATE TABLE automation_ips;

TheWitness commented 3 years ago

It think there maght be some vilidity to cross reference CIDR's for overlap, or change the design slightly so that two separate zones scanning the same range can run concurrently, but it also Amy be true that I'm uncertain.