Cacti / plugin_mactrack

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

Mactrack plugin doesn't create tables in DB when polling (A DB Exec Failed!, Error: Table 'cactidb.mac_track_ports' doesn't exist). #160

Closed sd3m0n closed 3 years ago

sd3m0n commented 3 years ago

Describe the bug I have these errors when trying to run poller. Found the similar issue on the forum: cacti.mac_track_ports doesn't exist. As I understood the plugin can't create the needed tables...

MariaDB config includes the following:

[mysqld]

sql_mode=ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

character-set-server    = utf8mb4
collation-server        = utf8mb4_unicode_ci
max_heap_table_size     = 128M
tmp_table_size          = 128M
join_buffer_size        = 256M
innodb_file_format      = Barracuda
innodb_large_prefix     = 1
innodb_buffer_pool_size = 2048M
innodb_flush_log_at_timeout = 3
innodb_read_io_threads  = 32
innodb_write_io_threads = 16
innodb_buffer_pool_instances = 17
innodb_io_capacity      = 5000
innodb_io_capacity_max  = 10000

And here is the Cacti log (after running php -q poller_mactrack.php -d -sid=1):

2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[881]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_ports' doesn't exist
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[877]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_ips' doesn't exist
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[875]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_temp_ports' doesn't exist
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[864]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_aggregated_ports' doesn't exist
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[863]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_aggregated_ports' doesn't exist
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[858]:mactrack_process_mac_auth_report(), /plugins/mactrack/poller_mactrack.php[892]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Row Failed!, Error: Table 'cactidb.mac_track_temp_ports' doesn't exist
2021-02-22 11:10:55 - MACTRACK DEBUG: Finished updating site table with collection statistics.
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[759]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Row Failed!, Error: Table 'cactidb.mac_track_ips' doesn't exist
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[679]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Row Failed!, Error: Table 'cactidb.mac_track_temp_ports' doesn't exist
2021-02-22 11:10:55 - MACTRACK DEBUG: Finished transferring scan results to main table.
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[663]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_ports' doesn't exist
2021-02-22 11:10:55 - MACTRACK DEBUG: MAC VLANs in VLAN Table Updated.
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[627]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_temp_ports' doesn't exist
2021-02-22 11:10:55 - MACTRACK DEBUG: MAC addresses to Vendor MACS association pass complete.
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[619]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_temp_ports' doesn't exist
2021-02-22 11:10:55 - MACTRACK DEBUG: Interum IP addresses to MAC addresses association pass complete.
2021-02-22 11:10:55 - CMDPHP SQL Backtrace: (/plugins/mactrack/poller_mactrack.php[144]:collect_mactrack_data(), /plugins/mactrack/poller_mactrack.php[614]:db_execute_prepared())
2021-02-22 11:10:55 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cactidb.mac_track_temp_ports' doesn't exist
2021-02-22 11:10:54 - MACTRACK WARNING: SITE: TechLAN, IP: 111.111.111.111, TYPE: ProCurve J8770A Switch 4204vl, revision , ERROR: Device Type Not Found in Device Type Table.
2021-02-22 11:10:54 - MACTRACK HOST: 111.111.111.111 is alive, processing has begun.
2021-02-22 11:10:54 - MACTRACK WARNING: SITE: TechLAN, IP: 111.111.111.112, TYPE: ProCurve J8770A Switch 4204vl, revision , ERROR: Device Type Not Found in Device Type Table.
2021-02-22 11:10:54 - MACTRACK HOST: 111.111.111.112 is alive, processing has begun.
2021-02-22 11:10:53 - MACTRACK DEBUG: A process cycle launch just completed.
2021-02-22 11:10:53 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /bin/php, ARGS: -q /var/www/cacti/plugins/mactrack/mactrack_scanner.php -id=2 -d]
2021-02-22 11:10:53 - MACTRACK CMD: /bin/php -q /var/www/cacti/plugins/mactrack/mactrack_scanner.php -id=2 -d
2021-02-22 11:10:53 - POLLER: Poller[Main Poller] DEBUG: About to Spawn a Remote Process [CMD: /bin/php, ARGS: -q /var/www/cacti/plugins/mactrack/mactrack_scanner.php -id=1 -d]
2021-02-22 11:10:53 - MACTRACK CMD: /bin/php -q /var/www/cacti/plugins/mactrack/mactrack_scanner.php -id=1 -d
2021-02-22 11:10:53 - MACTRACK DEBUG: About to enter Device Tracking Site Scan Processing

Plugin:

Server:

TheWitness commented 3 years ago

You SQL Mode should only be these two:

NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

You fail to mention what Cacti version you are at.

sd3m0n commented 3 years ago

You fail to mention what Cacti version you are at.

Sorry. Fixed that.

sd3m0n commented 3 years ago

I've changed SQL mode to the one you've mentioned above, thanx, but it wasn't the issue with this case (as expected). Do you have any idea what is wrong with the plugin or settings?

TheWitness commented 3 years ago

Was it working and then just stopped? If it was never working, just install and then reinstall. If you are sourcing an old *.SQL file, delete/stop that. The act of installing creates the tables. Clear log before installing, verify tables are gone, install, enable check log for errors.

sd3m0n commented 3 years ago

I tried to reinstall (tables in DB were dropped after uninstalling the plugin) the plugin and got this after attempting clean install:

2021-02-23 15:49:43 - CMDPHP SQL Backtrace: (/plugins.php[74]:api_plugin_install(), /lib/plugins.php[655]:plugin_mactrack_install(), /plugins/mactrack/setup.php[48]:mactrack_setup_table_new(), /plugins/mactrack/setup.php[217]:mactrack_setup_database(), /plugins/mactrack/includes/database.php[918]:api_plugin_db_table_create(), /lib/plugins.php[472]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-23 15:49:43 - CMDPHP ERROR: A DB Exec Failed!, Error: Invalid default value for 'port_number'
2021-02-23 15:49:43 - CMDPHP SQL Backtrace: (/plugins.php[74]:api_plugin_install(), /lib/plugins.php[655]:plugin_mactrack_install(), /plugins/mactrack/setup.php[48]:mactrack_setup_table_new(), /plugins/mactrack/setup.php[217]:mactrack_setup_database(), /plugins/mactrack/includes/database.php[811]:api_plugin_db_table_create(), /lib/plugins.php[472]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-23 15:49:43 - CMDPHP ERROR: A DB Exec Failed!, Error: Invalid default value for 'port_number'
2021-02-23 15:49:43 - CMDPHP SQL Backtrace: (/plugins.php[74]:api_plugin_install(), /lib/plugins.php[655]:plugin_mactrack_install(), /plugins/mactrack/setup.php[48]:mactrack_setup_table_new(), /plugins/mactrack/setup.php[217]:mactrack_setup_database(), /plugins/mactrack/includes/database.php[737]:api_plugin_db_table_create(), /lib/plugins.php[472]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-23 15:49:43 - CMDPHP ERROR: A DB Exec Failed!, Error: Invalid default value for 'port_number'
2021-02-23 15:49:43 - CMDPHP SQL Backtrace: (/plugins.php[74]:api_plugin_install(), /lib/plugins.php[655]:plugin_mactrack_install(), /plugins/mactrack/setup.php[48]:mactrack_setup_table_new(), /plugins/mactrack/setup.php[217]:mactrack_setup_database(), /plugins/mactrack/includes/database.php[494]:api_plugin_db_table_create(), /lib/plugins.php[472]:db_execute(), /lib/database.php[213]:db_execute_prepared())
2021-02-23 15:49:43 - CMDPHP ERROR: A DB Exec Failed!, Error: Invalid default value for 'port_number'
sd3m0n commented 3 years ago

I've resolved the issue by correcting default values in the /plugins/mactrack/includes/database.php.

TheWitness commented 3 years ago

You should create a pull request with the changes. Help out the team.

sd3m0n commented 3 years ago

You should create a pull request with the changes. Help out the team.

Done

TheWitness commented 3 years ago

Very much appreciated.