Anyone has an idea how to detect notification script errors inside icinga2/icingaweb2?


i recently run into a problem where one of our clusters had a missing dependency for a notificationscript, so sometimes notifications could’nt be send. Does someone has check or idea, how to make notification errors visible inside Icingaweb2? I’am not sure if i catch everything, if i use check_logfiles for example.

Thanks for support!



are you using the standard mail script or your own? You yould write any error into the log. What I mean expand the script with a complete error handling.
Then check_logfiles should work I think

1 Like

What about modifying the notification to send a passive check result?

1 Like

What i want to accomplish is a way where i catch errors that i do not expect. Thinks i havbe not thought about. Its my Teams script, but it was not the first time i had this, i also had problems with th original script a while ago. I will check if ther is a generic error in the log, everytime the notification script has no exit code 0.

I will test that, maybe i can send a passive result evertime exitcode is not 0.

I took a look in your code. Some ideas:

  • Every step which could generate an error you could use the try-catch-function from perl
  • So for me it looks like you need to catch possible error, regardless of whether incorrect parameters were passed: connecting the API (line 139) and encode the JSON (line 123). If something went wrong, normally the UserAgent throws an HTTP code and also there should be an error message also you could print out, send to the icinga api or write in an log file/journalctl or whatever.
  • Anway I don’t find any error handling in your code. What happens if the useragent gets an http code != 200? What happens if the json is wrong? etc.

BTW: Some time ago I found this library very helpful for writing some scripts for icinga. :wink:

Thanks for looking into it. Honestly I’am not a perl developer at all, i just forked the code and changed it to work better with icinga2. There is a lot of work to to, i just havn’t found the time. The error ist logged to the icinga2 log, so i can see that the Notification isn’t send. If i find the time i will take a look into the code and try to send an errormessage vie api to icingaweb2.

1 Like