Icinga2 not updating status on custom plugin

Hello all. So I created a new plugin to check /var/log/auth.log for updates on a VNC connection and then update the service to “WARNING” state when someone is logged on. The plugin works great and I’ve manually tested it to make sure the correct output and exit code is returned.

I noticed however, that the debug logs seem to show a different exit code run literally seconds after manually testing the plugin. It just doesn’t make sense. I am certain that all the arguments are included aswell.

[2020-08-27 01:37:45 -0400] notice/Process: PID 9488 ('/usr/lib/nagios/plugins/check_vnc.py' '-f' '/var/log/auth.log') terminated with exit code 0

root@dell999:/etc/icinga2/conf.d# /usr/lib/nagios/plugins/check_vnc.py -f /var/log/auth.log
WARNING
root@dell999:/etc/icinga2/conf.d# echo $?
1

Could anyone tell me why that is? I’ve even updated the check intervals to every 10 seconds.

Hi & welcome,

Icinga runs your check as user nagios or icinga (depending on your distribution) and both do not have access rights to read auth.log. You run it manually as user root and this is the reason why your script returns the correct exit code.

2 Likes

Thankyou so much I can’t believe I didn’t think of that. Just out of curiosity is there somewhere that logs the output of plugins for debugging purposes?

Hi.

You can enable debuglog on the host where the plugin gets executed.

icinga feature enable debuglog

Afterwards Icinga2 has to be restarted.


Greetings.

So the output of the plugins should be in /var/log/icinga2/debug.log?