Cacti / plugin_npc

Nagios Plugin for Cacti is a complete UI replacement for Nagios fully integrated into Cacti.
GNU General Public License v3.0
4 stars 3 forks source link

After fix the problem of my.cnf with sql_mode=NO_ENGINE_SUBSTITUTION, here is the new issues #2

Closed zhouleon closed 5 years ago

zhouleon commented 5 years ago

After fix the problem of my.cnf with sql_mode=NO_ENGINE_SUBSTITUTION, here is the new issues. Please check, thanks.

2019.02.03 08:52:04 - 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.03 08:52:04 - 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.03 08:51:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcNagiosController->getProcessInfoGrid(), /plugins/npc/controllers/nagios.php[75]:NpcNagiosController->processInfo(), /plugins/npc/controllers/nagios.php[109]:CactiErrorHandler())
2019.02.03 08:51:55 - 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.03 08:51:46 - SYSTEM WARNING: Primary Admin account notifications disabled! Unable to send administrative Email.
2019.02.03 08:51:46 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'npc'
2019.02.03 08:51:46 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())
2019.02.03 08:51:46 - ERROR PHP ERROR in Plugin 'npc': Uncaught Error: Using $this when not in object context in /usr/share/cacti/site/plugins/npc/controllers/hostgroups.php:332 Stack trace: #0 /usr/share/cacti/site/plugins/npc/controllers/sync.php(150): NpcHostgroupsController::getHostgroups() #1 /usr/share/cacti/site/plugins/npc/npc.php(83): NpcSyncController->listHostgroups(Array) #2 {main} thrown in file: /usr/share/cacti/site/plugins/npc/controllers/hostgroups.php on line: 332
2019.02.03 08:51:46 - CMDPHP PHP ERROR Backtrace: (/plugins/npc/npc.php[83]:NpcSyncController->listHostgroups(), /plugins/npc/controllers/sync.php[150]:CactiErrorHandler())
2019.02.03 08:51:46 - ERROR PHP DEPRECATED in Plugin 'npc': Non-static method NpcHostgroupsController::getHostgroups() should not be called statically in file: /usr/share/cacti/site/plugins/npc/controllers/sync.php on line: 150
2019.02.03 08:51:21 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcNagiosController->getProcessInfoGrid(), /plugins/npc/controllers/nagios.php[75]:NpcNagiosController->processInfo(), /plugins/npc/controllers/nagios.php[109]:CactiErrorHandler())
2019.02.03 08:51:21 - 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.03 08:51:13 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/npc/npc.php[83]:NpcServicegroupsController->getOverview(), /plugins/npc/controllers/servicegroups.php[206]:CactiErrorHandler())
2019.02.03 08:51:13 - 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.03 08:51:13 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcServicegroupsController->getOverview(), /plugins/npc/controllers/servicegroups.php[206]:CactiErrorHandler())
2019.02.03 08:51:13 - 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.03 08:51:10 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/npc/npc.php[83]:NpcHostgroupsController->getOverview(), /plugins/npc/controllers/hostgroups.php[188]:CactiErrorHandler())
2019.02.03 08:51:10 - ERROR PHP WARNING in Plugin 'npc': Invalid argument supplied for foreach() in file: /usr/share/cacti/site/plugins/npc/controllers/hostgroups.php on line: 188
2019.02.03 08:51:10 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/npc/npc.php[83]:NpcHostgroupsController->getOverview(), /plugins/npc/controllers/hostgroups.php[188]:CactiErrorHandler())
2019.02.03 08:51:10 - ERROR PHP NOTICE in Plugin 'npc': Undefined variable: temp in file: /usr/share/cacti/site/plugins/npc/controllers/hostgroups.php on line: 188
2019.02.03 08:51:04 - 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.03 08:51:04 - ERROR PHP NOTICE in Plugin 'npc': Undefined offset: 0 in file: /usr/share/cacti/site/plugins/npc/controllers/nagios.php on line: 109

Version Info:
Linux: Ubuntu 18.01 LST
Apache 2.4.29
MySQL 5.7.25-0ubuntu0.18.04.2
PHP 7.2.10-0ubuntu0.18.04.1
Nagios Core 4.4.3
Cacti 1.2.1
ndoutils 2.1.3
cigamit commented 5 years ago

Yea, this is all likely to using php7.

zhouleon commented 5 years ago

My product NPC in PHP Version 5.5.9-1ubuntu4.17 works fine.

zhouleon commented 5 years ago

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?

netniV commented 5 years ago

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.

zhouleon commented 5 years ago

I reinstall it with update code, still has some problem, please help to check, thanks!

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]: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

boluser commented 5 years ago

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

netniV commented 5 years ago

Create a separate issue fo4 each issue