Notifications into MS Teams
Notifications into MS Teams
I am wondering if anyone has gotten this plugin working and could lend some help. https://exchange.nagios.org/directory/P ... ms/details
I have the webhook setup in Teams and the test command is working to send messages into the our Teams channel. My question is more how to setup contact and command configurations.
This is in my contacts config.
define contact {
contact_name notify_teams
alias MS Teams
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7
service_notification_period 24x7
host_notification_options d,u,r,f,s
service_notification_options w,u,c,r,f
host_notification_commands notify_teams
service_notification_commands notify_teams
}
This is the command.cfg
define command {
command_name notify_teams
command_line /usr/bin/printf "$LONGSERVICEOUTPUT$" | /usr/lib64/nagios/plugins/nagios-msteams.pl "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" "$SERVICEOUTPUT$" $_CONTACTWEBHOOKURL$
}
I am guessing my configuration error is in the command.cfg above and perhaps I am calling the perl script wrong. Can anyone lend advice on how this should be formatted?
Thanks,
Eric
~
I have the webhook setup in Teams and the test command is working to send messages into the our Teams channel. My question is more how to setup contact and command configurations.
This is in my contacts config.
define contact {
contact_name notify_teams
alias MS Teams
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7
service_notification_period 24x7
host_notification_options d,u,r,f,s
service_notification_options w,u,c,r,f
host_notification_commands notify_teams
service_notification_commands notify_teams
}
This is the command.cfg
define command {
command_name notify_teams
command_line /usr/bin/printf "$LONGSERVICEOUTPUT$" | /usr/lib64/nagios/plugins/nagios-msteams.pl "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" "$SERVICEOUTPUT$" $_CONTACTWEBHOOKURL$
}
I am guessing my configuration error is in the command.cfg above and perhaps I am calling the perl script wrong. Can anyone lend advice on how this should be formatted?
Thanks,
Eric
~
Re: Notifications into MS Teams
After doing a little more research, I think this is the proper command format however the notifications still don't seem to be sending.
define command {
command_name notify_teams
command_line $USER1$/nagios-msteams.pl
}
define command {
command_name notify_teams
command_line $USER1$/nagios-msteams.pl
}
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Notifications into MS Teams
This is not our plugin so we are not familiar with it, but the usage on this page looks quote different
Code: Select all
https://github.com/akadoya/nagios-msteams-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Notifications into MS Teams
I believe you need to pass this to the command
and based on the looks of it, it may expect you have environment macros turned on in the nagios.cfg
Code: Select all
--webhook 'https://your incoming webhook url'Re: Notifications into MS Teams
The web hook URL is a variable in the perl script, so I have it set there. Also, the environment macros are turned on.scottwilkerson wrote:I believe you need to pass this to the commandand based on the looks of it, it may expect you have environment macros turned on in the nagios.cfgCode: Select all
--webhook 'https://your incoming webhook url'
Should I see an error in the logs if the notification tries to fire but fails? I see notifications going out for emails etc but no sign of the MS teams hook either failing or attempting, etc.
Eric
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Notifications into MS Teams
Have you added the notify_teams contact to any of the hosts/services?
Re: Notifications into MS Teams
Yes, I've added them to all of my contact groups and reloaded Nagios after doing so. I tested the notifications and I see for example the email notifications in the log but nothing referencing notify_teams.scottwilkerson wrote:Have you added the notify_teams contact to any of the hosts/services?
[1583531546] SERVICE NOTIFICATION: Eric_Email;xxxx.yyyy.com;SMTP Service;OK;notify-service-by-email;
SMTP OK - 0.013 sec. response time
Mar 6 16:52:26 mon01 nagios: SERVICE NOTIFICATION: Eric_Email;xxxx.yyyy.com;SMTP Service;OK
;notify-service-by-email;SMTP OK - 0.013 sec. response time
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Notifications into MS Teams
Do all of your hosts have a contact_group assigned?sozotech wrote:[1583531546] SERVICE NOTIFICATION: Eric_Email;xxxx.yyyy.com;SMTP Service;OK;notify-service-by-email;
SMTP OK - 0.013 sec. response time
Mar 6 16:52:26 mon01 nagios: SERVICE NOTIFICATION: Eric_Email;xxxx.yyyy.com;SMTP Service;OK
;notify-service-by-email;SMTP OK - 0.013 sec. response time
Re: Notifications into MS Teams
Yes, here is an example.scottwilkerson wrote:Do all of your hosts have a contact_group assigned?sozotech wrote:[1583531546] SERVICE NOTIFICATION: Eric_Email;xxxx.yyyy.com;SMTP Service;OK;notify-service-by-email;
SMTP OK - 0.013 sec. response time
Mar 6 16:52:26 mon01 nagios: SERVICE NOTIFICATION: Eric_Email;xxxx.yyyy.com;SMTP Service;OK
;notify-service-by-email;SMTP OK - 0.013 sec. response time
define host{
use generic-host
host_name xxxx.yyyy.com
alias scrollpens.webhsp.com
address X.Y.Z.104
check_command check-host-alive
max_check_attempts 5
contact_groups somename
}
Contacts.cfg
define contactgroup{
contactgroup_name somename
alias Administrators
members Eric_Email,Eric_Phone,Ben_Email,Ben_Phone,notify_teams
}
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Notifications into MS Teams
Can you submit a custom notification for xxxx.yyyy.com and see it in the logs?