True. Because we can of course not cover all specific use cases. But you will find the answer to making a custom copy in there. And from there it is up to you to update the plugin to fulfil your needs.
Was digging deeper with our slack understanding person and figured out why the slack notifications don’t work, it currently says please take a look @username, when it needs to be "please take a look <@username> , could someone point me at where these modules are on the monitoring server and i could try change that small part for me
(also username needs to be your slack id, not name, planning to create notification users specifically for these)
where 2.2.x will be your currently running version.
I still don’t get, however, how checkmk team tested this plugin and why it is not fixed already.
I have exactly the same issue, that notification sent to Slack do not mention users because of lacking <>
Do not change this file, as it is part of the Checkmk installation itself, and you will lose these changes upon upgrade. Please refer to the link I posted above and how to make custom copies of built-in notification plugins.
prepares user names to be mentioned on Slack but they are treated literally and user is not mentioned at all, i.e. @username is displayed as regular text, not a “mention”
notifications stared to properly mention user but only one of them (I don’t know why not both, I’m not skillful enough in python to catch this message):
(screen in my next message, as new users can only embed one media )
This mention is a proper mention which triggers Slack’s notification rules, display info on hover etc. and this is the mention I would like to have out of the box, without the need of writing my own notification plugin that will basically fix just that.
Side note:
Sorry readers if this topic looks a bit messy. If I knew replies are placed also at the end of the topic I would rather just quote the question and reply to it. There are also some limitations for new users I wasn’t aware of. Hopefully, next time I’ll do it better
Hi @robin.gierse
Didn’t hear from you after my explanations. Are they clear enough? Will you process this issue somehow internally? Or maybe I should create a separate topic for this issue? If so - which category is the best one for reporting such things?
My colleague’s account was created before those changes so @username worked for him but I have to use @user-id for me to work.
Let me describe my way of “fixing” Slack mentions in checkmk notifications.
A way faster than writing a plugin but with one caveat.
!WARNING!
You will change internal chekcmk file that will be overwritten during update, but at the moment of writing (2024-03) this is the only way for Slack mentions to work properly.
Open /omd/versions/2.x.y.crx/lib/python3/cmk/notification_plugins/slack.py
Chagne line 67 (add <> to @{} and change CONTACTNAME to CONTACTPAGER)
For Cthulhu’s sake!
Do not modify built-in Checkmk files!
I said it several times now, but I’ll spell it our for you, as apparently the article is not clear enough about it.
cp $OMD_ROOT/lib/python3/cmk/notification_plugins/slack.py $OMD_ROOT/local/share/check_mk/notifications/slack.py
vim $OMD_ROOT/local/share/check_mk/notifications/slack.py
# Make your modifications
chmod +x $OMD_ROOT/local/share/check_mk/notifications/slack.py
That way you get a custom copy, that will not be overwritten on update.
Alternatively you can override the built-in files like this:
cp $OMD_ROOT/lib/python3/cmk/notification_plugins/slack.py $OMD_ROOT/local/lib/python3/cmk/notification_plugins/slack.py
vim $OMD_ROOT/local/lib/python3/cmk/notification_plugins/slack.py
You are absolutely right. This article is not THAT clear as your short description. Thanks a lot for it
However, I’ve updated my checkmk instances a few days ago - tried both suggestions but neither of them worked (so I fall back to Cuthulu’s unholy solution ) - what do I miss?
Regarding PR - I can create one regarding the missing brackets, but I’m not skilled enough to add CONTACTSLACK variable to be visible in UI and be later passed to notification script. So maybe a better idea is to create feature request here - let me know what do you think.
I did not test the second approach, but it should work. You just need to make sure, that the path below $OMD_ROOT/local/ is exactly the same as in the source. And that the file is executable. For the first approach you would probably need to modify the source code further, which is beyond my skills.