patrickpr / trapdirector

Icingaweb2 module for receiving and handling snmp traps
GNU General Public License v3.0
53 stars 15 forks source link

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

Open manfredw opened 3 years ago

manfredw commented 3 years ago

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:

patrickpr commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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?

ankost403 commented 1 year ago

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.