I already used the check command on github to test if its working. So regarding this command it works but I dont get any notificaiton in Mattermost. Seems like its not a plugin problem more an icinga problem.
Because when I use a dummy host check which is down i should get a notfication but when i check on icinga web it shows this :
did is miss a simple part where i have to enable notification in Icinga??
I hope anyone can give me a Hint.
object User "mattermost" {
import "generic-user"
display_name = "Mattermost User"
enable_notifications = true
vars.channel = "Icinga2" /* Use here the url channel name, ie. without special characters and spaces */
vars.url = "https://xxxxxxxxxxx.com/hooks/xxxxxxxxxxxxxxx" /* Copy incoming Webhook URL defined in mattermost */
vars.oneline = false /* Use true if you prefer having all output squashed on one line */
}
notifications.conf:
apply Notification "mattermost_service" to Service {
assign where true
command = "mattermost_service"
users = [ "mattermost" ]
period = "24x7"
types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
states = [ OK, Warning, Critical, Unknown ]
}
apply Notification "mattermost_host" to Host {
assign where true
command = "mattermost_host"
users = [ "mattermost" ]
period = "24x7"
types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
states = [ Up, Down ]
}
I think there is a problem with sending notification here, it seems like the icingaweb can’t send notification. If I try it here manually it does not send any notificition and still write “for this problem was not notification send”. I think somewhere are the notification disabled but I can’t find where?
I am running the command ./mattermost.py --url https://mattermost.xxxxxxxxxx.com/hooks/xxxxxxxxxxxx --notificationtype CUSTOM --hostalias myexample.com
as root
in the folder /usr/lib64/nagios/plugins/icinga2-mattermost
I can’t change the user with su icinga ? I tried but I get an error. This seems not the problem because on my second icinga istance it works fine with the root user. I can’t even send a notification manually when I am on the icinga webinterface. Or how do I run a command as a different user?
Since the “icinga” user does not have a login shell, you can not directly login.
As a workaround, you can use sudo here:
sudo -u icinga /path/to/the/script # Directly executing the script
# alternatively to get a shell: sudo -u icinga bash
# or whatever shell instead of bash (/bin/sh, ...)
Assuming that you are using RedHat/CentOS (because the user is “icinga”):
Did you check for SELinux related problems?
I just checked I can run the command as icinga user manually and it works, I get a notification in my mattermost channel. I will check for SELinux problems and let you know what I find.