When Redis Sentinel notifies about events, it does not provide the name of the Redis master.
An excerpt from the config:
# sentinel notification-script <master-name> <script-path>
#
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.
So there only is the event type (e.g. +odown
) and the event description, which in case of +odown
simply is master
. Somehow I feel this is lacking important information. We do not only want to notify users that something has changed but where it changed.
You can't register a script with additional parameters, e.g.
sentinel notification-script <master-name> "<script-path> <master-name>"
Redis will use the value as a whole and check if it exists and is executable.
We solved this by creating small wrapper scripts, one for each master instance.
$ cat /some/path/notify-master42.sh
#!/bin/sh
/some/path/notify.sh master42 $1 $2
This wrapper script then is attached to the master:
sentinel notification-script <master-name> notification-script /some/path/notify-<master-name>.sh
That's a bit uncomfortable but not too bad, as long as you have a fixed number of masters and do not create them on the fly over the net.
You can register new masters by simply interacting with the sentinel over the net. (redis-cli -h <host> -p <port> sentinel whatever...
) But creating those wrapper scripts is more complicated. Not that this is impossible, but it feels like jumping through burning hoops for nothing.
Is there a way to notify including master names:
- without patching redis
- without having wrapper scripts
?