0 Comments

Email Alerts

  1. Menu: Alert > Media types
  2. Configure email settings: Type -> Email, Provider -> Generic smtp
  3. Test email
  4. Menu: Alerts > Actions > Trigger actions
  5. Enable Report problems to Zabbix administrators
  6. Menu: Users > Users
  7. Select Admin
  8. Tab: Media
  9. Button: Add
  10. Type: <mail profile from step 2>
  11. Choose: Use if severity
  12. Save, update, close, … etc

On the host i have to choose for specific items triggers with the severity i choose in step 11

Telegram

Configure telegram
  1. Install telegram
  2. Search for bot father
  3. Start chat and type /newbot
  4. Add name and username (username ends with _bot)
  5. Copy API id
  6. Open file scripts for zabbix (see below) and paste Bot API token
  7. Create a telegram group and add the bot to the group
  8. Find the group chat ID (https://neliosoftware.com/content/help/how-do-i-get-the-channel-id-in-telegram/)
  9. Paste it to the scipt (see below)
Telegram scipt for zabbix
#!/bin/bash

# Telegram Bot API Token and Chat ID
BOT_TOKEN="Bot API token"
CHAT_ID="Chat ID"

# Message from Zabbix
MESSAGE=$1

# Send message via Telegram API
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -d chat_id="${CHAT_ID}" \
  -d text="${MESSAGE}" \
  -d parse_mode="Markdown"
    Add telegram script to Zabbix
    1. SSH to the Server (zabbix server)
    2. Create a new file to the following location: pico /usr/lib/zabbix/alertscripts/tele.sh
    3. Paste the above script to the created file
    4. Make the script executable

    Configure Zabbix

    1. Log on to the zabbix
    2. Menu: Alerts > Media Types >Create Media Type
    3. Add Name: Chris Telegram
    4. Media type: Script
    5. Script name: tele.sh (the above script name)
    6. Scipt parameters: {ALERT.MESSAGE}
    7. Go to message templates
    8. Add Problem:
      • Problem started at {EVENT.TIME} on {EVENT.DATE}
      • Problem name: {EVENT.NAME}
      • Host: {HOST.NAME}
      • Severity: {EVENT.SEVERITY}
      • Operational data: {EVENT.OPDATA}
      • Original problem ID: {EVENT.ID}
      • {TRIGGER.URL}
    9. Add Problem Recovery:
      • Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}
      • Problem name: {EVENT.NAME}
      • Problem duration: {EVENT.DURATION}
      • Host: {HOST.NAME}
      • Severity: {EVENT.SEVERITY}
      • Original problem ID: {EVENT.ID}
      • {TRIGGER.URL}
    10. Save Media Type and test it
    Assign Media type to User
    1. Menu: Users > User
    2. Media > Add
    3. Media type: Chris Telegram
    4. On the Send to, add the Telegram goup id you created
    5. Select the severity you like
    6. Save and close
    7. Go to menu: User settings > Profile
    8. Click on Frontend Notifications
    9. Enable: Frontend notification
    10. Click Update
    Add trigger
    1. Add a trigger to the host
    2. Menu Actions > Trigger actions
    3. Click on: Report problems to Zabbix administrators
    4. Conditions > Add
    5. Type: Trigger
    6. Selecte the trigger name you created before from the selected host
    7. Add button and select Operations tab
    8. Add operation and Recovery operation for the user Admin. Use media type Chris Telegram (you created in the previous phases)
    9. Click update
    Links

    Related Posts