Microsoft Teams Notifications
Posted: Wed Jul 22, 2020 10:37 am
Hello,
I'm trying to get Teams notifications working. I've been following the script instructions here: https://github.com/isaac-galvan/nagios-teams-notify
With a couple of changes. Here is what I have for a setup:
notify_teams.py is in /usr/local/nagios/etc and has been CHMOD +x'ed. The script itself is unchanged from the one in github
I decided to edit the notify-host-by-email and notify-service-by-email entries rather than making new ones, because it just seems like less changes and I have no interest in notifying by email at this time. My /usr/local/nagios/etc/objects/commands.cfg has the following entries:
In both instances, <WEBHOOKURL> is the actual web hook URL, not a variable.
contacts.cfg is unchanged other than having my email in it.
templates.cfg is unchanged.
If I go to the command line and run /usr/local/nagios/etc/notify-teams.py "Test Message" "Test Body" <WEBHOOKURL> it works perfectly and I get the message in teams, so at its core, notify-teams.py and the web hook URL are OK. Forcing a notification to go out about a host also works, but comes across a bit weird in that the message shows some of the variable $ characters and none of the data on hosts or services:
However, when hosts go down, I get no notifications at all. My guess is it isnt parsing the variables correctly? But I dont know how to troubleshoot that, nor do I know how to find any logs on what might have gone wrong.
Any thoughts?
I'm trying to get Teams notifications working. I've been following the script instructions here: https://github.com/isaac-galvan/nagios-teams-notify
With a couple of changes. Here is what I have for a setup:
notify_teams.py is in /usr/local/nagios/etc and has been CHMOD +x'ed. The script itself is unchanged from the one in github
I decided to edit the notify-host-by-email and notify-service-by-email entries rather than making new ones, because it just seems like less changes and I have no interest in notifying by email at this time. My /usr/local/nagios/etc/objects/commands.cfg has the following entries:
Code: Select all
define command {
command_name notify-host-by-email
command_line /usr/local/nagios/etc/notify-teams.py "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$" "$NOTIFICATIONTYPE$ Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$" <WEBHOOKURL>
}Code: Select all
define command {
command_name notify-service-by-email
command_line /usr/local/nagios/etc/notify-teams.py "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" "Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$" <WEBHOOKURL>
}contacts.cfg is unchanged other than having my email in it.
templates.cfg is unchanged.
If I go to the command line and run /usr/local/nagios/etc/notify-teams.py "Test Message" "Test Body" <WEBHOOKURL> it works perfectly and I get the message in teams, so at its core, notify-teams.py and the web hook URL are OK. Forcing a notification to go out about a host also works, but comes across a bit weird in that the message shows some of the variable $ characters and none of the data on hosts or services:
Code: Select all
CUSTOM: ESXi-01/$ is $
$
$Any thoughts?