Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.64k stars 405 forks source link

After fixing both #5812 and #5829, multiple CMDPHP ERROR: A DB related function/command/queried failed. #5832

Closed MSS970 closed 1 month ago

MSS970 commented 1 month ago

CACTI version [1.3.0 - Dev] Windows 2019 server

This bug is related to bug #5812 and #5829. After fixing both #5812 and #5829, the blow errors started to get reported:

2024-09-23 05:23:01 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[793]:db_execute(), D:\cacti\apache\htdocs\cacti\lib\database.php[496]:db_execute_prepared())

2024-09-23 05:23:01 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown table 'poller_output_boost_temp_664038111_1727054581.709'

2024-09-23 05:23:01 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[787]:db_fetch_assoc_prepared(), D:\cacti\apache\htdocs\cacti\lib\database.php[909]:db_execute_prepared())

2024-09-23 05:23:01 - CMDPHP ERROR: A DB Row Failed!, Error: SELECT command denied to user 'cactiuser'@'localhost' for table '709'

2024-09-23 05:23:01 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[745]:db_execute(), D:\cacti\apache\htdocs\cacti\lib\database.php[496]:db_execute_prepared())

2024-09-23 05:23:01 - CMDPHP ERROR: A DB Exec Failed!, Error: Access denied for user 'cactiuser'@'localhost' to database 'poller_output_boost_temp_664038111_1727054581'

2024-09-23 05:23:01 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[793]:db_execute(), D:\cacti\apache\htdocs\cacti\lib\database.php[496]:db_execute_prepared())

2024-09-23 05:23:01 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown table 'poller_output_boost_temp_1872566092_1727054581.4767'

2024-09-23 05:23:01 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[787]:db_fetch_assoc_prepared(), D:\cacti\apache\htdocs\cacti\lib\database.php[909]:db_execute_prepared())

2024-09-23 05:23:01 - CMDPHP ERROR: A DB Row Failed!, Error: SELECT command denied to user 'cactiuser'@'localhost' for table '4767'

2024-09-23 05:23:01 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[745]:db_execute(), D:\cacti\apache\htdocs\cacti\lib\database.php[496]:db_execute_prepared())

2024-09-23 05:23:01 - CMDPHP ERROR: A DB Exec Failed!, Error: Access denied for user 'cactiuser'@'localhost' to database 'poller_output_boost_temp_1872566092_1727054581'

TheWitness commented 1 month ago

I'm not working out of develop right now. Does this issue happen in 1.2.x?

TheWitness commented 1 month ago

Run this command. Output should be similar. Adjust per your setup:

MariaDB [cacti]> show grants for 'cactiuser'@'localhost';
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for cactiuser@localhost                                                                                                                                                                                                             |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `cactiuser`@`localhost` IDENTIFIED BY PASSWORD '*43DD7940383044FBDE5B177730FAD3405BC6DAD7'                                                                                                                           |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `cacti`.* TO `cactiuser`@`localhost` |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.003 sec)
TheWitness commented 1 month ago

I did make a minor edit to lib/boost.php this morning. Likely not material though.

MSS970 commented 1 month ago

Thanks for the support. I have applied the new lib/boost.php file this morning and will update you by tomorrow morning. Much appreciated.

TheWitness commented 1 month ago

You did not answer my question though.

MSS970 commented 1 month ago

I don't have 1.2.x in my environment, I run 1.3.0 Dev.

TheWitness commented 1 month ago

I'm talking about the grants.

MSS970 commented 1 month ago

Good morning @TheWitness ,

The cactiuser was found: show grants for 'cactiuser'@'localhost';

GRANT ALL PRIVILEGES ON cacti. TO cactiuser@localhost GRANT SELECT ON mysql. TO cactiuser@localhost

Then I have applied yesterday:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON . TO cactiuser@localhost

and applied the lib/boot.php and left it till this morning to see the results.

MSS970 commented 1 month ago

2024-09-26 05:56:54 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[793]:db_execute(), D:\cacti\apache\htdocs\cacti\lib\database.php[496]:db_execute_prepared())

2024-09-26 05:56:54 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown table 'poller_output_boost_temp_98_1929877246_1727315814.985'

2024-09-26 05:56:54 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[787]:db_fetch_assoc_prepared(), D:\cacti\apache\htdocs\cacti\lib\database.php[909]:db_execute_prepared())

2024-09-26 05:56:54 - CMDPHP ERROR: A DB Row Failed!, Error: Unknown database 'poller_output_boost_temp_98_1929877246_1727315814'

2024-09-26 05:56:54 - SQL Backtrace: (D:\cacti\apache\htdocs\cacti\poller.php[960]:api_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[97]:api_plugin_run_plugin_hook(), D:\cacti\apache\htdocs\cacti\lib\plugins.php[243]:weathermap_poller_bottom(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\setup.php[1169]:weathermap_run_maps(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\poller-common.php[430]:WeatherMap->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\WeatherMap.class.php[1058]:WeatherMapDataSource_rrd->ReadData(), D:\cacti\apache\htdocs\cacti\plugins\weathermap\lib\datasources\WeatherMapDataSource_rrd.php[647]:rrdtool_function_fetch(), D:\cacti\apache\htdocs\cacti\lib\rrd.php[1063]:boost_fetch_cache_check(), D:\cacti\apache\htdocs\cacti\lib\boost.php[306]:boost_process_poller_output(), D:\cacti\apache\htdocs\cacti\lib\boost.php[745]:db_execute(), D:\cacti\apache\htdocs\cacti\lib\database.php[496]:db_execute_prepared())

2024-09-26 05:56:54 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown database 'poller_output_boost_temp_98_1929877246_1727315814'

MSS970 commented 1 month ago

I will grant DBA permission to cactiuser and monitor till tomorrow morning.

TheWitness commented 1 month ago

Those errors are from a non-updated lib/boost.php.

TheWitness commented 1 month ago

Run this command, post the output:

SHOW GRANTS FOR 'cactiuser'@'localhost';
MSS970 commented 1 month ago

Granted DBA to cactiuser.

SHOW GRANTS FOR 'cactiuser'@'localhost';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON . TO cactiuser@localhost WITH GRANT OPTION GRANT ALL PRIVILEGES ON cacti. TO cactiuser@localhost GRANT SELECT ON mysql. TO cactiuser@localhost

MSS970 commented 1 month ago

If those errors are from a non-updated lib/boost.php, then I will stop and start the Apache service to ensure the system reads lib/boost.php freshly.

and monitor for 1 day.

MSS970 commented 1 month ago

I have modified lib/boost.php line #743:

//$temp_table = 'poller_output_boosttemp' . $local_dataid . '' . mtrand() . '' . microtime(true); $temp_table = 'poller_output_boosttemp' . $local_dataid . '' . mtrand() . '' . strreplace('.', '', microtime());

will update the case tomorrow morning.

TheWitness commented 1 month ago

Seriously, your lib/boost.is still wrong. So, instead of updating you simply hacked the old version. Well fine.

MSS970 commented 1 month ago

Seriously, your lib/boost.is still wrong. So, instead of updating you simply hacked the old version. Well fine.

The solution is:

MSS970 commented 1 month ago

Seriously, your lib/boost.is still wrong. So, instead of updating you simply hacked the old version. Well fine.

@TheWitness , I did not hack any old version! the version I run is always updated from the cacti/cacti 1.3.0 Dev.

furthermore, I am trying to help and fix the incident which has been resolved by creating a permanent table instead of temporary.

I ain't sure of what you are trying to point to!

Anyways, the incident has been resolved, it is up to you to consider the fix!

TheWitness commented 1 month ago

The solution is what is currently in the devekopment branch. My recommendation is to update to that and report your findings.

MSS970 commented 1 month ago

@TheWitness , What I have is the same what is currently in the development branch. And what I have mentioned in my fix has already resolve the issue I have reported earlier.

I have raised a pull request as well as merge what I have fixed to the development branch.

Let me know if I am missing any point!