[Feature-Request] Multiple Alert Profiles
sectary-want-holly opened this issue · 5 comments
Hi -
Thanks for this script. It works great. Quick question though, how would one go about utilising the script for multiple different alert Groups in Telegram? Clone the script and change reference to an individualised config.xml file?
Hi, thanks, nice to hear.
You want to granularly differentiate in Check_MK, which alert group should be notified via Telegram? Then a clone would certainly be a pragmatic way to go. To meet this requirement, I would personally take the following approach:
Under notification rules > notification method there is also an option to call the method "Push Notification (using Telegram)" with a parameter (Call with the following parameter).
Here you could pass the Telegram GroupID (maybe also the token) directly. Take a look at the manual:
Check_MK Manual > Notifications > Chapter: 11.3. A simple example
OMD[mysite]:~$ grep PARAMETER $OMD_ROOT/tmp/telegram.out
NOTIFY_PARAMETERS=bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 -123456789
NOTIFY_PARAMETER_1=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
NOTIFY_PARAMETER_2=-123456789
Inside check_mk_telegram-notify.sh, the lines
TOKEN=$(xmllint --xpath 'string(/config/telegram_api_token)' $CONFIGFILE)
CHAT_ID=$(xmllint --xpath 'string(/config/telegram_chat_id)' $CONFIGFILE)
need to be changed to something like
TOKEN=$NOTIFY_PARAMETER_1
CHAT_ID=$NOTIFY_PARAMETER_2
So far the theory, the config.xml might even be omitted completely. I don't have time to try it out myself at the moment. If you are faster, I would be glad about a feedback. I would then adapt the code and documentation accordingly.
Good morning sectary-want-holly, I was up early and then curious myself. I tested it on one of my Check_MK instances, works with parameter passing as described above. Code and documentation are adjusted, don't forget to restart the OMD instance. Thanks for your question, this is now much more charmingly solved.
Hey @filipnet - apologies for the delayed replies. We're in different TZ's and I read the reply in the morning then forget to reply later! Just wanted to say many thanks for this - I have it working beautifully now!
A different approach is to use the 'Pager address' field in Check_MK's user properties. This gets exported as $NOTIFY_CONTACTPAGER
variable to the script and as such all that's needed is
if [ -z ${NOTIFY_CONTACTPAGER} ]; then
echo "No pager address provided to be used as Chat-ID. Exiting" >&2
exit 2
else
CHAT_ID="${NOTIFY_CONTACTPAGER}"
fi
i am having a problem that i can only send to 1 telegram user.How can send notifications to multiple users telegram