nook24 / statusengine

New PHP based MySQL Backend for Naemon and Nagios 4 + responsive web frontend
https://statusengine.org/
GNU General Public License v2.0
16 stars 8 forks source link

Skip job processing if payload isn't a json object #30

Closed dhoffend closed 7 years ago

dhoffend commented 7 years ago

Fixed an issue where invalid/empty data in the gearman queues throws errors/exceptions in the workers process jobs.

nook24 commented 7 years ago

Hi @dhoffend, basically it should not be possible, that there are broken records in the gearman queue without a third party application consuming the same queues.

But at the moment im working on your last PR :D

dhoffend commented 7 years ago

Here's the example (log) for the first fix:

Mar 23 10:06:22 xxxx statusengine: notice: Notice (8): Trying to get property of non-object in [/srv/drbd/statusengine-2.0.5/cakephp/app/Console/Command/StatusengineLegacyShell.php, line 1496]
Mar 23 10:06:22 xxxx statusengine: notice: Trace:
Mar 23 10:06:22 xxxx statusengine: notice: StatusengineLegacyShell::processServicechecks() - /srv/drbd/statusengine-2.0.5/cakephp/app/Console/Command/StatusengineLegacyShell.php, line 1496
Mar 23 10:06:22 xxxx statusengine: notice: GearmanWorker::work() - [internal], line ??
Mar 23 10:06:22 xxxx statusengine: notice: StatusengineLegacyShell::childWork() - /srv/drbd/statusengine-2.0.5/cakephp/app/Console/Command/StatusengineLegacyShell.php, line 2869
Mar 23 10:06:22 xxxx statusengine: notice: StatusengineLegacyShell::waitForInstructions() - /srv/drbd/statusengine-2.0.5/cakephp/app/Console/Command/StatusengineLegacyShell.php, line 2846
Mar 23 10:06:22 xxxx statusengine: notice: StatusengineLegacyShell::forkWorker() - /srv/drbd/statusengine-2.0.5/cakephp/app/Console/Command/StatusengineLegacyShell.php, line 2728
Mar 23 10:06:22 xxxx statusengine: notice: StatusengineLegacyShell::main() - /srv/drbd/statusengine-2.0.5/cakephp/app/Console/Command/StatusengineLegacyShell.php, line 234
Mar 23 10:06:22 xxxx statusengine: notice: Shell::runCommand() - CORE/Cake/Console/Shell.php, line 461
Mar 23 10:06:22 xxxx statusengine: notice: ShellDispatcher::dispatch() - CORE/Cake/Console/ShellDispatcher.php, line 212
Mar 23 10:06:22 xxxx statusengine: notice: ShellDispatcher::run() - CORE/Cake/Console/ShellDispatcher.php, line 66
Mar 23 10:06:22 xxxx statusengine: notice: [main] - /srv/drbd/statusengine-2.0.5/cakephp/app/Console/cake.php, line 47

The line "StatusengineLegacyShell.php, line 1496" referes to the initial bulk version https://github.com/nook24/statusengine/blob/ba13e66fa7565a2b969cd273df2f5512c2f4883d/cakephp/app/Console/Command/StatusengineLegacyShell.php#L1496

In the meantime i've locally fixed it but there's no external process pushing stuff into the servicestatus queue ... Maybe it could be a bad json formatted object. The json_decode() fails resulting in an empty payload variable. I guess additionally we should check for json parsing errors http://php.net/manual/de/function.json-last-error.php and log them. Maybe the naemon objects contains invalid characters or has syntax problems. If we log the invalid object we could easily debug them.

dhoffend commented 7 years ago

I've updated the pull request completly.