Scheduled notifications possible? API? Scheduled test of notification rules?

Hi!

After lots of further tests and analysis of the logs in var/log/notify.log, I realized that the old external command file still works as expected in checkmk. The custom notifications are correctly evaluated by the notification rules in checkmk.

So as information to anyone facing the same task: One of the possible approaches for sending scheduled notifications is by using nagios.cmd, which is still supported in checkmk 2.0.0p1.

Example script:

#!/bin/bash

NAGIOS_CMDFILE="/opt/omd/sites/yoursite/tmp/run/nagios.cmd"
now=`date +%s`

# --  Test SMS to Linux oncall --
/bin/echo "[$now] SEND_CUSTOM_SVC_NOTIFICATION;yourlinuxhost;Check_MK;3;checkmk scheduled message;Test-SMS to Linux oncall"  >> $NAGIOS_CMDFILE

If there is a notification rule, which sends out notifications for service Check_MK for host “yourlinuxhost”, the contacts from this rule will get the scheduled notification. You can add further commands for notifying other teams, by using different hosts or service checks.

However, contact groups are a tricky thing. “Service contacts” only lists the intended contacts, but “Service contact groups” in our configuration includes “all” by default. So I had to change the rules to send to the specific contact groups only, not to “all contacts of this host or service”.

I still have a problem with a rule that won’t accept the custom notifications due to their event type. But I’ll post that to a new thread, as this is not a topic about scheduled notifications anymore.

Thanks for your input!
Bye, Dirk.

Edit: Just to add this information: My problem with one of the rules was that service state “OK → OK” was not selected, which is required for such custom alerts, where the state stays at OK. If you see log entries in notify.log that event type ‘rr’ is not allowed in a rule, that’s the option to activate! (I guess it stands for recovery → recovery.)

1 Like