Skip to content

jaredbrogan/Zabbix-Teams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Zabbix - Teams

ℹ️ Disclaimer: This was developed on Zabbix 4.0, but I see no reason it shouldn't work on newer versions as well. ℹ️

Introduction

This page will show you how to setup and configure the zabbix-teams.sh script to be implemented so that you will receive Zabbix problem alerts in the desired Microsoft Teams channel of your choosing.

Prerequisites

  • If a copy of zabbix-teams.sh isn't yet located on the Zabbix server being utilized, please perform the following:
    1. cd /usr/lib/zabbix/alertscrips
    2. curl -O https://raw.githubusercontent.com/jaredbrogan/Zabbix-Teams/main/zabbix-teams.sh
    3. chown root:zabbix zabbix-teams.sh ; chmod a+x zabbix-teams.sh
  • Once the script has been downloaded and permissions have been corrected, you will now need to perform the frontend setup:
    1. On the Zabbix Frontend, navigate to AdministrationMedia Types
    2. Click Create media type on the top right of the page
    3. Enter the following:
      • Name: Microsoft Teams
      • Type: Script
      • Script name: zabbix-teams.sh
      • Script parameters:
        • {ALERT.SENDTO}
        • {ALERT.SUBJECT}
        • {ALERT.MESSAGE}
    4. Leave everything else as default.
    5. Be sure the Enabled checkbox remains checked
    6. Should look like this:

  • The next step is to create a new macro to be used in our new alerts. Please perform the following:
    1. On the Zabbix Frontend, navigate to AdministrationMacros
    2. Click the small Add button
    3. In the Macro column, enter {$ZABBIX_URL}
    4. In the Value column, enter your specific Zabbix web URL
    5. Click the Update button to apply this change.
    6. The new macro should look something like this:

Now that we have the new media type created, we can move forward with the next section! 🙂

Teams Channel Configuration

With the new media type created, our next step will be to determine where we'll be sending our alerts to.

Assuming you have the ability to either create a new channel in the desired team of your choice --
Please perform the following:

  1. Navigate to the channel where alerts will be sent to.
  2. Click on the ellipsis (…) located to the right of the channel's name
  3. Select the Connectors option
  4. Locate the Incoming Webhook item and select Configure
  5. Give a name for this incoming webhook, maybe "Zabbix"
  6. Now upload an image for it
    • Feel free to use the image to the right ⟶
    • Now select Create
  7. Now that the incoming webhook has been created, you should now see a generated webhook URL that can be referenced specifically for this channel

Now would be a good time to copy this URL for the next section 😁

Zabbix User Configuration

With the Teams setup completed, we will finish our setup on the Zabbix Frontend section.
First, we will create a new user to be used specifically for this functionality.

Please perform the following:

  1. On the Zabbix Frontend, navigate to AdministrationUsers
  2. Click Create media type on the top right of the page
  3. Enter the following:
    • Alias: MS Teams - [Channel Name]
    • Name: [MS Team Name]
    • Surname: [Channel Name]
    • Groups: 'No access to the frontend' & 'Microsoft Teams'
    • Password: zabbix
      • Note: This account will not actually be able to login.
  4. Click the Media tab above
  5. Perform the following:
    • Click the tiny Add button underneath Type
    • Select Microsoft Teams from the drop-down menu
    • Copy/paste the previously generated incoming webhook URL into the Send to field
    • Leave When active and Use if severity as default
    • Be sure the Enabled checkbox remains checked
    • Click the Add button
    • Click the Add button again
  6. Click the Permissions tab above
  7. Select Zabbix Super Admin from the User type drop-down menu

With the user now created, we can move on to the final step! 😃

Zabbix Action Configuration

Now for the final step, we will create a new action in Zabbix.
Please perform the following:

  1. On the Zabbix Frontend, navigate to ConfigurationActions
  2. Click Create action on the top right of the page
  3. Enter the following:
    • Name: [HOST GROUP] - Teams Channel
    • Conditions
      • Create the following conditions:
        1. Problem is not suppressed
        2. Trigger severity is greater than or equals Average
        3. Host group equals [group(s) that apply]
    • Leave everything else on this tab as default
    • Be sure the Enabled checkbox remains checked
  4. Click the Operations tab above
    • Enter the following:
      1. Default subject: [HOST GROUP]: {TRIGGER.STATUS} - {TRIGGER.NAME}
      2. Default message:
      Solution: <i>__[HOST GROUP]__</i><br>
      Host: __{HOST.HOST}__ <br>
      <ul>
      <li> Trigger: {TRIGGER.NAME} </li>
      <li> Trigger status: {TRIGGER.STATUS}  </li>
      <li> Trigger severity: {TRIGGER.SEVERITY} </li>
      <li> Trigger URL: <a href={TRIGGER.URL}>{TRIGGER.URL}</a> </li>
      <li> Trigger Description: {TRIGGER.DESCRIPTION}  </li>
      <li> Item value: {ITEM.LASTVALUE}  </li>
      </ul>
      Original event ID: {EVENT.ID} <br>
      Action: <i>{ACTION.NAME}</i> <br>
      PROB_URL: {$ZABBIX_URL}/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}  <br>
      ACK_URL: {$ZABBIX_URL}/zabbix/zabbix.php?action=acknowledge.edit&eventids%5B0%5D={EVENT.ID}&backurl=tr_events.php%3Ftriggerid%3D{TRIGGER.ID}%26eventid%3D{EVENT.ID}
      
      1. Leave Pause operations for suppressed problems checked
      2. Click New located under the Operations area below
        • Click Add located within the Send to Users section
        • Select the previously created user
        • Select Microsoft Teams from the drop-down menu for the Send only to field
        • Leave Default message checked
        • Under Conditions, click New
          • There should be a default condition labeled as Event acknowledged equals Not Ack
          • Click the small Add button
        • Click the other small Add button
      3. Click the Recovery operations tab above
        • Enter the following:
          1. Default subject: [HOST GROUP]: {TRIGGER.STATUS} - {TRIGGER.NAME}
          2. Default message:
        Solution: <i>__[HOST GROUP]__</i><br>
        Host: __{HOST.HOST}__ <br>
        <ul>
        <li> Trigger: {TRIGGER.NAME} </li>
        <li> Trigger status: {TRIGGER.STATUS}  </li>
        <li> Trigger severity: {TRIGGER.SEVERITY} </li>
        <li> Trigger URL: <a href={TRIGGER.URL}>{TRIGGER.URL}</a> </li>
        <li> Trigger Description: {TRIGGER.DESCRIPTION}  </li>
        <li> Item value: {ITEM.LASTVALUE}  </li>
        </ul>
        Original event ID: {EVENT.ID} <br>
        Action: <i>{ACTION.NAME}</i> <br>
        PROB_URL: {$ZABBIX_URL}/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}  <br>
        ACK_URL: {$ZABBIX_URL}/zabbix/zabbix.php?action=acknowledge.edit&eventids%5B0%5D={EVENT.ID}&backurl=tr_events.php%3Ftriggerid%3D{TRIGGER.ID}%26eventid%3D{EVENT.ID}
        
        1. Click New located under the Operations details area below
          • Perform the following:
            1. Under Operation type, select Notify all involved
            2. Leave Default message checked
            3. Click the small Add button
    1. Click the Update operations tab above
    • Enter the following:
      1. Default subject: [HOST GROUP]: Acknowledged - {TRIGGER.NAME}
      2. Default message:
      The alarm for __{TRIGGER.NAME}__ has been acknowledged.
      <ul>
      <li> User: {USER.FULLNAME} </li>
      <li> Host: {HOST.HOST} </li>
      <li> Time: {ACK.DATE} at {ACK.TIME} </li>
      <li>  Message: {ACK.MESSAGE} </li>
      </ul>
      
      Current problem status is __{EVENT.STATUS}__.
      
      1. Click New located under the Operations area below
        • Perform the following:
          1. Under Operation type, select Notify all involved
          2. Under Default media type, select Microsoft Teams
          3. Leave Default message checked
          4. Click the small Add button
    1. Now click the BIG Add button
    2. Once created, it should resemble this:

And there you go! Everything is finally setup!

Please enjoy the additional notifications! 😎👍


Author

About

Zabbix integration into Microsoft Teams

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages