Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with traps and host groups after upgrading to 1.0.6 #52

Open
manfredw opened this issue Jan 1, 2021 · 5 comments
Open

Errors with traps and host groups after upgrading to 1.0.6 #52

manfredw opened this issue Jan 1, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@manfredw
Copy link

manfredw commented Jan 1, 2021

Describe the bug

Trap handles for host groups stopped working after upgrade to TrapDirector 1.0.6.
Traps for dedicated hosts still work.

Also I'm not able to create new trap handlers for host groups (GUI : Error : count(): Parameter must be an array or an object that implements Countable). Selection of host groups works, but saving is not possible.

To Reproduce

Syslog starting with new incoming Link Down Trap:
2021-01-01T21:53:44.888000+01:00 host snmptrapd[2071]: 10.10.10.2: Link Down Trap (0) Uptime: 94 days, 12:20:24.83, .1.3.6.1.2.1.2.2.1.1.10106 = INTEGER: 10106, .1.3.6.1.2.1.2.2.1.2.10106 = STRING: GigabitEthernet1/0/6, .1.3.6.1.2.1.2.2.1.3.10106 = INTEGER: 6, .1.3.6.1.4.1.9.2.2.1.1.20.10106 = STRING: "down"
2021-01-01T21:53:44.977469+01:00 host snmptrapd[2071]: PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 327
2021-01-01T21:53:44.979448+01:00 host snmptrapd[2071]: message repeated 4 times: [ PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 327]
2021-01-01T21:53:44.979714+01:00 host snmptrapd[2071]: PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 341
2021-01-01T21:53:45.116622+01:00 host snmptrapd[2071]: PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 327
2021-01-01T21:53:45.117056+01:00 host snmptrapd[2071]: PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 341
2021-01-01T21:53:45.254773+01:00 host snmptrapd[2071]: PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 327
2021-01-01T21:53:45.255220+01:00 host snmptrapd[2071]: PHP Notice: Trying to access array offset on value of type bool in /usr/share/icingaweb2/modules/trapdirector/library/Trapdirector/TrapsProcess/Trap.php on line 341

A truncation and rebuild of the MIB cache DB tables did not change the behavior.

Your Environment:

  • trapdirector version (in icinga web 2 : System - About): 1.0.6
  • Icinga Web 2 version and modules (in icinga web 2 : System - About): 2.8.2
  • Icinga 2 version (icinga2 --version): 2.12.3
  • Operating System and version: openSUSE Leap 15.2
  • Webserver, PHP versions: Apache 2.4, PHP 7.4
@patrickpr patrickpr self-assigned this Jan 2, 2021
@patrickpr patrickpr added the bug Something isn't working label Jan 2, 2021
@patrickpr
Copy link
Owner

Hi,
The first error is weird but should not impact the trap processing : can you put the debug mode on and give me the logs ?

For the GUI error : when does this happen ? When you save / add from existing trap / Check "hostgroup" ?

Did you check the permission changes in API needed by 1.0.6 ?

Regards

@manfredw
Copy link
Author

manfredw commented Jan 6, 2021

Hi Patrick,

the GUI error only happens when saving a new trap handler for a host group.
The API permissions should be correct - there is also a builtin check for the query/hostgroup access.
GUI actions are not logged within trapdirector log file, so we need another way for debugging.

When using the log option "trace" or "ALL", only infos about incoming traps (sql queries,...) are logged and looked good, but the php errors cannot be found in the file. These are only visible in syslog caused by snmptrapd which called the php trap handler.
This is only a PHP notice, it seems that with PHP 7.4 the preferred way to check for existence of a array values has changed.

Instead of
if ($name['name'] != null)
the code
if ( isset($name['name']) )
fixes the problem.

Regards
Manfred

PS: when changing log level in GUI, the log file is truncated - is this a desired behavior?

@p4k8
Copy link
Contributor

p4k8 commented Feb 4, 2021

Same GUI problem persists after applying Manfred's changes to lines 327 and 341 of Trap.php
Error points to application/controllers/HandlerController.php, line 549
Might be related to fetching hostgroup id from API, but have no idea how to troubleshoot it.

@manfredw
Copy link
Author

manfredw commented Feb 4, 2021

My solution only addresses the PHP 7.4 warning which is thrown by each incoming trap.

Regarding the web GUI issue within Icingaweb2 maybe the developer team of Icingaweb can help. I'm pretty sure that there are debugging capabilities. Icingaweb2 is a complex and extensible system, I'm not a web programmer and so it's hard for me to deliver detailed information. Who created the Trapdirector web interface?

godrockz added a commit to godrockz/trapdirector that referenced this issue Feb 28, 2023
count(): Parameter must be an array or an object that implements Countable
@ankost403
Copy link

Hi there, I just installed 1.0.7a and faced the same issue. Applied the patch and the problem seems have been fixed, at least I was able to create a new handler with a hostgroup. I can confirm, that getting list of hostgroups and then list of services takes some time, maybe 20-30 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants