Page 1 of 2

Notifications into MS Teams

Posted: Fri Mar 06, 2020 3:53 pm
by sozotech
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

~

Re: Notifications into MS Teams

Posted: Fri Mar 06, 2020 4:45 pm
by sozotech
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
}

Re: Notifications into MS Teams

Posted: Mon Mar 09, 2020 4:41 pm
by scottwilkerson
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

Re: Notifications into MS Teams

Posted: Mon Mar 09, 2020 4:42 pm
by scottwilkerson
I believe you need to pass this to the command

Code: Select all

 --webhook 'https://your incoming webhook url'
and based on the looks of it, it may expect you have environment macros turned on in the nagios.cfg

Re: Notifications into MS Teams

Posted: Mon Mar 09, 2020 8:40 pm
by sozotech
scottwilkerson wrote:I believe you need to pass this to the command

Code: Select all

 --webhook 'https://your incoming webhook url'
and based on the looks of it, it may expect you have environment macros turned on in the nagios.cfg
The web hook URL is a variable in the perl script, so I have it set there. Also, the environment macros are turned on.

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

Re: Notifications into MS Teams

Posted: Tue Mar 10, 2020 8:19 am
by scottwilkerson
Have you added the notify_teams contact to any of the hosts/services?

Re: Notifications into MS Teams

Posted: Tue Mar 10, 2020 9:02 am
by sozotech
scottwilkerson wrote:Have you added the notify_teams contact to any of the hosts/services?
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.

[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

Posted: Tue Mar 10, 2020 9:36 am
by scottwilkerson
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
Do all of your hosts have a contact_group assigned?

Re: Notifications into MS Teams

Posted: Tue Mar 10, 2020 9:57 am
by sozotech
scottwilkerson wrote:
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
Do all of your hosts have a contact_group assigned?
Yes, here is an example.

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
}

Re: Notifications into MS Teams

Posted: Tue Mar 10, 2020 2:11 pm
by scottwilkerson
Can you submit a custom notification for xxxx.yyyy.com and see it in the logs?