Custom notification script execution

CMK version: 2.3.0p10
OS version: ubuntu 24.04
Output of “cmk --debug -vvn hostname”: Success

I create a custom notification script, copying the foobar example in the documentation ( 11.3. A simple sample script).

I can execute the script with the site user, it works, i added a rule to launch the script in notifications, but when testing the notification, in notify.log i see:

would notify USERNAME via foobar, parameters: 1, 2, 3, bulk: no
would notify USERNAME via mail, parameters: from, disable_multiplexing, graphs_per_notification, notifications_with_graphs, bulk: no

i get the mail but in site home /tmp folder there’s no output (the script dump env vars to /tmp/foobar.txt)

I had disabled also apparmor, any help ?

Igor

1 Like

Basically I do the same even that it is no more necessary because you see all the macros if you enable debugging.

Did you checked that the script is really owned by the site user and is executable:

My script:

#!/bin/bash
#Export Environment
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! From env.sh to stdout !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "################################## From nv.sh to stderr  ####################################################################" >&2
/usr/bin/env > ~/tmp/notification_env.txt

Has following rights:

OMD[master]:~/local$ ll ./share/check_mk/notifications/env.sh
-rwxr-xr-x 1 master master 344 Jun 25 10:36 ./share/check_mk/notifications/env.sh*

i’m to lazy go lookup the example script, can you link it?

I have however written several notifications scripts in python, php and bash and permissions are the normal issue.

you can check web.log, cmc.log and notify.log - also try to create a file in /tmp as the site user to see if its works. (or create it under ~/tmp )

Hi @Anders,

The link to the script is here: https://docs.checkmk.com/latest/en/notifications.html#example

I have the same issue as @barsigor under RedHat 9.4, Checkmk EE 2.3.0p13.
There are no messages in web.log, cmc.log, and notify.log. Also checked the file permissions and tested Python and Bash scripts. Also turned off SELinux for testing purposes.

Best,
MAp

1 Like

you are referring to a completely different script than what you showed
you could also show the output of the script logs

have you developed bash script before?

Hey all,

So I figured it out… It was the “Test notification”:

When I use this function it does NOT run the scripts, despite the fact that notify.log says, it did. So when I configure a rule that matches some “real-life” notification, the custom scripts run as intended.

Best,
MAp

Yea it seems the test function only cares about the HTML plugin, I have never used it.

I normally use “fake notifications” as this will trigger any plugin that is relevant and configures.

1 Like

I have the same problem. If I try to triger the notification from command, it doesn’t run the script. In nagios.log I can see there is an entry like:

EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;e137srv01;CPU utilization;3;mmartoss;

But in notify.log there’re not any event related with the event I triggered before.

Is like the notify is never triggered. :frowning: :frowning:

Don’t know what more I can do or how to debug this. Real notifications are sent, but forced notifications are not triggered.

I’m on the actual last version: Checkmk Raw Edition 2.3.0p21

Hi all, ran into similar needs to execute notification script.
This can be done as documented in Commands

Use the Fake Check Results command (thanks Anders for this) and you’re good to go (you need to show all commands in the UI - it’s not displayed by default) - the notification script will be triggered.

Following your fake result execution, just do a service recheck to bring back the status et voilà!

Hope this helps!

One think to keep in mind however: Checkmk will report the service as flapping if you “play” around with it for too many times in a short time internval and you will not see any notifications

Is there a way to avoid such behavior during “play”/development ?

Not really unless you want to change config around it and do it in production
I generally just switch between two services or two host if I need the same service.

in our dev/stage environments this is not a problem