Skip to content

Seamless collaboration: Send Centreon notifications in Microsoft Teams rooms

Blog Seamless collaboration: Send Centreon notifications in Microsoft Teams rooms

Over the last few months, Microsoft Teams has become one of the leading collaborative platforms, with a range of services from video conferencing to instant messaging and many other features that facilitate the daily work of ITOps (the focus for this blog), as it does for other users in many other industries. 

In particular, Microsoft Teams lets you set up teams and channels. Team members thus access the content and tools they need to collaborate, including Slack-like discussion threads, a familiar platform for ITOps. In this blog post, we’ll see how you can send and display Centreon alerts using Microsoft Teams messaging functionalities. 

What’s a notification Plugin? 

A notification Plugin is a piece of code connecting prominent Centreon features (Contact, Notification rules, Escalations, etc.) and third-party technologies, communication, or alerting software. Centreon offers a range of possibilities in that area, for example, you can send SMS notifications through  OVH, Slack, or Telegram. 

Here, we will show you how to use the Teams notification Plugin. 

How Centreon notifications work  – A refresher

The integration is based on the mail notification system, natively included within Centreon and follows the same principles: 

  • The scheduler ( a.k.a. the Centreon engine) triggers a notification Command when an event or a metric reaches a certain threshold. 
  • IMPORTANT: A notification Command needs to be first configured within Centreon for the scheduler to run it using the right parameters (binary path, information to be included in the notification, etc.).
  • Notification commands are associated with a Centreon user whom you choose to notify explicitly using plugin, in this instance, the Teams notification Plugin. You need to define a Centreon Contact for this specific Command definition. 
  • This Centreon Contact must be linked to the monitoring assets to receive notifications (Hosts, Services, Business Activities).

Configure Microsoft Teams

To allow Centreon to send an alert in a Teams channel, you must configure an Incoming Webhook in your workspace. 

You can achieve this by clicking on the (…) in your Team workspace and search for the ‘Incoming Webhook’ application: 

Note: You can also configure this at the channel level using the same (…) shortcut.

Associate your application with a Team:

Pick the team and get to the next step to set up the connector: 

Give a name to your application and personalize the look and feel if you want to: 

Once finished, click on ‘Create’. You will obtain a URL that you can easily copy/paste thanks to the dedicated icon:

Keep the webhook URL preciously. You’ll need it later. Validate with the ‘Done’ button. 

If everything’s OK, you will probably get a Teams notification confirming the configuration of the connector: 

Configure Centreon 

1. Notification Plugin setup

Install the Microsoft Teams notification Plugin with the Yum package manager on each Poller expected to send notifications to a Teams Channel:

yum install centreon-plugin-Notification-Teams

Manager on each Poller expected to send notifications to a Teams Channel.

2. Use CLAPI to set up your configuration objects quickly.

To get the full benefits from Plugin capabilities, you have to create the following Centreon objects:

  • A Notification Command corresponding to all possible kinds of resources (Hosts, Services, Business Activities). 
  • A Centreon Contact, corresponding to a channel within Teams. It means that you’ll need several Contacts if you need to notify several channels.  

To speed things up things and make it easier, we’ve created an almost ready-to-import CLAPI file. 

Copy the content below and drop it within a file on your Central server /tmp directory. As an example /tmp/clapi-teams.import:

CMD;ADD;bam-notify-by-microsoft-teams;1;$CENTREONPLUGINS$/ --plugin=notification::microsoft::office365::teams::plugin --mode=alert --custommode=webhookapi --teams-webhook='$CONTACTPAGER$' --bam --service-description='$SERVICEDISPLAYNAME$' --service-state='$SERVICESTATE$' --service-output='$SERVICEOUTPUT$' --date='$DATE$ $TIME$' --centreon-url='$CONTACTADDRESS1$'
CMD;ADD;host-notify-by-microsoft-teams;1;$CENTREONPLUGINS$/ --plugin=notification::microsoft::office365::teams::plugin --mode=alert --custommode=webhookapi --teams-webhook='$CONTACTPAGER$' --notification-type='$NOTIFICATIONTYPE$' --host-name='$HOSTNAME$' --host-state='$HOSTSTATE$' --host-output='$HOSTOUTPUT$' --date='$DATE$ $TIME$' --action-links --centreon-url='$CONTACTADDRESS1$' --extra-info='$NOTIFICATIONAUTHOR$//$NOTIFICATIONCOMMENT$'CMD;setparam;host-notify-by-microsoft-teams;enable_shell;0
CMD;ADD;host-notify-by-microsoft-teams;1; &
CMD;ADD;service-notify-by-microsoft-teams;1;$CENTREONPLUGINS$/ --plugin=notification::microsoft::office365::teams::plugin --mode=alert --custommode=webhookapi --teams-webhook='$CONTACTPAGER$' --notification-type='$NOTIFICATIONTYPE$' --host-name='$HOSTNAME$' --service-description='$SERVICEDESC$' --service-state='$SERVICESTATE$' --service-output='$SERVICEOUTPUT$' --date='$DATE$ $TIME$' --action-links --centreon-url='$CONTACTADDRESS1$' --extra-info='$NOTIFICATIONAUTHOR$//$NOTIFICATIONCOMMENT$'CMD;setparam;service-notify-by-microsoft-teams;enable_shell;0
CONTACT;ADD;Microsoft-Teams-Consulting-Channel;notify_teams_consulting_channel;node@deadend;md5__2995c b0650c5f107230ed569a8c4d6e5;0;0;browser;local

Before loading the file, substitute these values with yours: 

  • ‘<SET_CENTREON_URL>’, the URL you use to access Centreon web UI.
  • ‘<SET_TEAMSWEBHOOK_URL>’, the Teams Webhook URL obtained previously. 

Sometimes, the Teams webhook URL can be longer than 200 characters. If this is your case, extend the size of the contact_pager row in the centreon configuration database. You can use this query: ALTER TABLE MODIFY contact_pager VARCHAR(255);

Use Centreon credentials and CLAPI to load the file: 

centreon -u ‘<adminuser>’ -p ‘<password>’ -i /tmp/clapi-teams.import

If the import is successful, you will obtain something similar to the definition below confirming that’s everything is OK: 

Depending on what you want to do, you can assign this Contact to a Group or link it with one or several resources and get notifications in your channel! 

You can also easily reach the performance graph and details of the asset using links and buttons included in the post. Convenient, isn’t it?

Diving deeper

Centreon Notifications allow advanced notification rules to fit your needs. You can find an advanced description of this concept in our official documentation.

One more important thing: When using a proxy, make sure to add these options to your notification commands: –proxy-url=’protocol://your.proxy.domain:port’ –http-backend=curl (change the value with yours!)

For any other question or matter, reach us through the centreon-plugin notification channel on Slack!


Facebook picto Twitter picto Twitter picto

Similar posts

Ready to see how Centreon can transform your business?

Keep informed on our latest news