Closed zhouleon closed 5 years ago
Yea, this is all likely to using php7.
My product NPC in PHP Version 5.5.9-1ubuntu4.17 works fine.
also, if I change from php7.2 to php5.6 in current test environment within Ubuntu 18.01 LST, some dependency problem will happen to other program. Could this issues be fixed in php7?
I have already made a change to one of the controllers regarding this in commit https://github.com/Cacti/plugin_npc/commit/49393403e3068937c638a02114813c07202ee035 but I hadn't realised at the time there were others.
It basically comes from the fact that PHP 5 was stupidly lax on the check of whether a function was being called as a static function of an object or a method of an instance of the object. As such, using $this when you were static, wasn't an issue as it referenced the static.
From PHP 7 (maybe 7.1 or 7.2 but in some version of 7), that is no longer valid and you MUST only use $self when you have an instance. Caught me out of a few times and this is historic code so it is probably all over the place.
I reinstall it with update code, still has some problem, please help to check, thanks!
2019.02.07 09:08:13 - ERROR PHP NOTICE in Plugin 'npc': Undefined offset: 0 in file: /usr/share/cacti/site/plugins/npc/controllers/hosts.php on line: 111 2019.02.07 09:08:13 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcHostsController->getStateInfo(), /plugins/npc/controllers/hosts.php[111]:CactiErrorHandler()) 2019.02.07 09:08:13 - ERROR PHP NOTICE in Plugin 'npc': Undefined offset: 0 in file: /usr/share/cacti/site/plugins/npc/controllers/hosts.php on line: 111 2019.02.07 09:08:13 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcHostsController->getStateInfo(), /plugins/npc/controllers/hosts.php[111]:NpcHostsController->formatStateInfo(), /plugins/npc/controllers/hosts.php[306]:CactiErrorHandler()) 2019.02.07 09:08:13 - ERROR PHP NOTICE in Plugin 'npc': Undefined index: in file: /usr/share/cacti/site/plugins/npc/controllers/hosts.php on line: 306 2019.02.07 09:08:13 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcHostsController->getStateInfo(), /plugins/npc/controllers/hosts.php[111]:CactiErrorHandler()) 2019.02.07 09:08:13 - ERROR PHP NOTICE in Plugin 'npc': Undefined offset: 0 in file: /usr/share/cacti/site/plugins/npc/controllers/hosts.php on line: 111 2019.02.07 09:08:07 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcNagiosController->getProgramStatus(), /plugins/npc/controllers/nagios.php[42]:NpcNagiosController->processInfo(), /plugins/npc/controllers/nagios.php[109]:CactiErrorHandler()) 2019.02.07 09:08:07 - ERROR PHP NOTICE in Plugin 'npc': Undefined offset: 0 in file: /usr/share/cacti/site/plugins/npc/controllers/nagios.php on line: 109 2019.02.07 09:08:07 - CMDPHP PHP ERROR Backtrace: (/plugins/npc/npc.php[83]:NpcHostgroupsController->getHostgroupServiceStatus(), /plugins/npc/controllers/hostgroups.php[119]:NpcHostgroupsController->getHostgroupMemberServiceStatus(), /plugins/npc/controllers/hostgroups.php[271]:CactiErrorHandler()) 2019.02.07 09:08:07 - ERROR PHP DEPRECATED in Plugin 'npc': Non-static method NpcServicesController::getServiceStatesByHost() should not be called statically in file: /usr/share/cacti/site/plugins/npc/controllers/hostgroups.php on line: 271 2019.02.07 09:07:58 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/npc/npc.php[83]:NpcServicegroupsController->getOverview(), /plugins/npc/controllers/servicegroups.php[206]:CactiErrorHandler()) 2019.02.07 09:07:58 - ERROR PHP WARNING in Plugin 'npc': Invalid argument supplied for foreach() in file: /usr/share/cacti/site/plugins/npc/controllers/servicegroups.php on line: 206 2019.02.07 09:07:58 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcServicegroupsController->getOverview(), /plugins/npc/controllers/servicegroups.php[206]:CactiErrorHandler()) 2019.02.07 09:07:58 - ERROR PHP NOTICE in Plugin 'npc': Undefined variable: temp in file: /usr/share/cacti/site/plugins/npc/controllers/servicegroups.php on line: 206 2019.02.07 09:07:50 - CMDPHP PHP ERROR Backtrace: (/plugins/npc/npc.php[83]:NpcHostgroupsController->getHostgroupServiceStatus(), /plugins/npc/controllers/hostgroups.php[119]:NpcHostgroupsController->getHostgroupMemberServiceStatus(), /plugins/npc/controllers/hostgroups.php[271]:CactiErrorHandler()) 2019.02.07 09:07:50 - ERROR PHP DEPRECATED in Plugin 'npc': Non-static method NpcServicesController::getServiceStatesByHost() should not be called statically in file: /usr/share/cacti/site/plugins/npc/controllers/hostgroups.php on line: 271 2019.02.07 09:07:50 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcNagiosController->getProgramStatus(), /plugins/npc/controllers/nagios.php[42]:NpcNagiosController->processInfo(), /plugins/npc/controllers/nagios.php[109]:CactiErrorHandler()) 2019.02.07 09:07:50 - ERROR PHP NOTICE in Plugin 'npc': Undefined offset: 0 in file: /usr/share/cacti/site/plugins/npc/controllers/nagios.php on line: 109
I have similar problems:
Type 1: NPC DEBUG [NpcHostgroupsController] (getHostgroupServiceStatus) - Script execution time: 0.08 seconds NPC DEBUG [NpcServicegroupsController] (getServicegroups) - Method execution time: 0.00 seconds NPC DEBUG [NpcServicegroupsController] (getServicegroupServiceStatus) - Method execution time: 0.00 seconds NPC DEBUG [NpcServicegroupsController] (getServicegroupServiceStatus) - Script execution time: 0.01 seconds NPC DEBUG [NpcHostgroupsController] (getHostgroupHostStatus) - Script execution time: 0.01 seconds NPC DEBUG [NpcServicegroupsController] (getHostStatusPortlet) - Method execution time: 0.00 seconds NPC DEBUG [NpcServicegroupsController] (getHostStatusPortlet) - Script execution time: 0.00 seconds NPC DEBUG [NpcHostsController] (summary) - Script execution time: 0.00 seconds NPC DEBUG [NpcServicesController] (summary) - Script execution time: 0.00 seconds NPC DEBUG [NpcNagiosController] (getProgramStatus) - Script execution time: 0.00 seconds NPC DEBUG [NpcHostsController] (getHosts) - Script execution time: 0.01 seconds NPC DEBUG [NpcServicesController] (getServices) - Script execution time: 0.01 seconds
Type 2: ERROR PHP DEPRECATED in Plugin 'npc': Non-static method NpcServicesController::getServiceStatesByHost() should not be called statically in file: /opt/cacti/plugins/npc/controllers/hostgroups.php on line: 271
Type 3: CMDPHP PHP ERROR Backtrace: (/plugins/npc/npc.php[83]:NpcHostgroupsController->getHostgroupServiceStatus(),/plugins/npc/controllers/hostgroups.php[119]:NpcHostgroupsController->getHostgroupMemberServiceStatus(), /plugins/npc/controllers/hostgroups.php[271]:CactiErrorHandler())
I have an open incidence also in: https://forums.cacti.net/viewtopic.php?f=14&t=59455
Version Info: Linux: Ubuntu 18.04.1 Apache: 2.4.29 MySQL 10.3.12-MariaDB-1:10.3.12+maria~bionic-log PHP 7.2.10 Nagios Core 4.4.3 Cacti 1.2.1 ndoutils 2.1.3
Create a separate issue fo4 each issue
After fix the problem of my.cnf with sql_mode=NO_ENGINE_SUBSTITUTION, here is the new issues. Please check, thanks.