This simple script makes use of the 'incoming webhook' connector in MS Teams. It will simply send a message stating that the server has either gone offline or online based on the last hard state of the host.
Internet access, Python 3, and the requests package are required.
-
Clone git repo:
git clone https://github.com/ajaffie/teams_connector.git cd teams_connector git tag -l git checkout
-
Create webhook(s) in desired MS Teams channels and add the urls to the
urls
list inconfig.json
. -
For each webhook in
config.json
, either put a "*" to include all notifications for that channel, or list the servers you want notifications to be sent to that channel for. Optional: You can specify custom names for servers to use instead of "Server " in the messages. This is most useful for cases where the script executed automatically by a system such as Icinga or Nagios where the name specified is the internal name/FQDN and you want a more user-friendly message printed. -
Add
NotificationCommand
definition andNotification
apply rules to your Icinga2/Nagios/etc. configurations. -
Stop cluttering your inbox and instead annoy everyone in MS Teams!
(A NotificationCommand
definition is included, but you MUST change the path, as it uses a custom defined constant.)