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

Hi,

I use some simple script as local check to generate a service that goes crit once a week. This service can be treated as any other and can be used in notification rules, we use it to test our SMS gateways. You might adjust this to your needs.

Regards,
Tom

#!/bin/bash
#
# Description:  checkmk check that goes CRIT at a configurable date and time
#               and stays CRIT for a configurable count of seconds.
#               Useful for testing nofication subsystem on a regular base,
#               e.g. SMS gateways.
#
# Maintainer:   (ttr)
#
# Version:      0.1
#
# Created:      16.10.20
#
# Usage:        - checkmk local check
#               - discover service "SMS" and enable notification for that
#
# Changelog:    0.1   - 16.10.2020 - ttr
#                      - initial


# date of status change to crit
SMS_DATE="11:50 Fri"

# seconds to stay in CRIT state:
DURATION=300

# the messages, checkmk local check syntax
GOOD="0 SMS - SMS gateway, next check "$SMS_DATE
BAD="2 SMS - SMS gateway test message"


# calculate seconds to go
s=$(echo $(($(date -d "$SMS_DATE + $DURATION sec" +%s)-$(date +%s))))

# evaluate
[ $s -gt 0 -a $s -lt $DURATION ] && echo $BAD || echo $GOOD
1 Like