Zabbix

Zabbix Telegram Entegrasyonu / Zabbix Telegram Integration

Zabbix, güçlü bir izleme ve uyarı sistemidir. Telegram entegrasyonu sayesinde, sistemde meydana gelen hataları ve kritik olayları anlık olarak Telegram gruplarına bildirebilirsiniz. Bu makalede, Zabbix ile Telegram entegrasyonu nasıl yapılır? sorusunun cevabını adım adım anlatacağız.

Öncelikle Zabbix portalına giriş yapıyoruz;

portalgiris

📌 Adım 1: Telegram Bot’u Oluştur

  1. Telegram’da @BotFather‘ı arayın ve sohbeti başlatın.
  2. /newbot komutunu yazın.
  3. Bot için bir isim belirleyin (Örneğin: ZabbixATKBot).
  4. Bot kullanıcı adını belirleyin (Örneğin: ZabbixATK_Bot).
  5. BotFather, size bir Bot Token verecek (Örnek: 123456789:ABCDEFGH-IKLMNOPQRSTUVWXYZ).

📌 Adım 2: Kullanıcı ID’sini Al

  1. Telegram’da @userinfobot botunu arayın ve başlatın.
  2. Bot, size kullanıcı ID’nizi gösterecektir. (Örnek: 123456789).

📌 Adım 3: Zabbix Media Type Ayarlarını Yapılandır

  1. Zabbix arayüzüne giriş yapın.
  2. Alerts > Media Types > Create Media Type menüsüne gidin.
  3. Name: Telegram
  4. Type: Script
  5. Script name: telegram.sh
  6. Script parameters:
    • {ALERT.SENDTO} (Kullanıcı ID)
    • {ALERT.SUBJECT} (Başlık)
    • {ALERT.MESSAGE} (Mesaj içeriği)

media

📌 Adım 4: Telegram Script’i Zabbix Sunucusunda Oluştur

  1. Terminalde şu dizine gidin:
    cd /usr/lib/zabbix/alertscripts/
  2. telegram.sh dosyasını oluşturun:
    sudo nano telegram.sh
  3. Aşağıdaki kodu ekleyin:
    #!/bin/bash
    BOT_TOKEN="123456789:ABCDEFGH-IKLMNOPQRSTUVWXYZ"
    CHAT_ID="$1"
    MESSAGE="$3"
    
    curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
    -d chat_id="${CHAT_ID}" \
    -d text="${MESSAGE}"
  4. Kaydedip çıkın (CTRL + X, Y, Enter).
  5. Script’e çalıştırma izni verin:    sudo chmod +x telegram.sh

📌 Adım 5: Kullanıcıya Telegram’ı Atama

  1. Administration > Users > Kullanıcı Seç > Media > Add adımlarını takip edin.
  2. Type: Telegram
  3. Send To: 123456789 (Kullanıcı ID’sini yazın.)
  4. When Active: Always
  5. Status: Enabled

telegram zabbix settings

📌 Adım 6: Test Et

  1. Configuration > Actions > Trigger Actions menüsüne gidin.
  2. Yeni bir tetikleyici oluşturun (Örneğin: Host Down).
  3. Eğer her şey doğruysa, Telegram’a anında bildirim alacaksınız ✅

 

 


 

 

Zabbix is a powerful monitoring and alert system. With Telegram integration, you can instantly receive alerts about errors and critical events in the system. In this guide, we will explain how to integrate Zabbix with Telegram step-by-step.

Firstly we login to Zabbix portal;

portalgiris

📌 Step 1: Create a Telegram Bot

  1. Search for @BotFather on Telegram and start the chat.
  2. Type the command /newbot.
  3. Choose a name for your bot (e.g., ZabbixATKBot).
  4. Set a username for your bot (e.g., ZabbixATK_Bot).
  5. BotFather will provide you with a Bot Token (e.g., 123456789:ABCDEFGH-IKLMNOPQRSTUVWXYZ).

📌 Step 2: Get Your User ID

  1. Search for @userinfobot on Telegram and start the chat.
  2. The bot will display your user ID (e.g., 123456789).

📌 Step 3: Configure Zabbix Media Type

  1. Log in to the Zabbix interface.
  2. Navigate to Reports > Media Types > Create Media Type.
  3. Name: Telegram
  4. Type: Script
  5. Script name: telegram.sh
  6. Script parameters:
    • {ALERT.SENDTO} (User ID)
    • {ALERT.SUBJECT} (Subject)
    • {ALERT.MESSAGE} (Message content)

media

📌 Step 4: Create the Telegram Script on the Zabbix Server

  1. Open the terminal and navigate to the following directory:
    cd /usr/lib/zabbix/alertscripts/
  2. Create the telegram.sh file:
    sudo nano telegram.sh
  3. Add the following code:
    #!/bin/bash
    BOT_TOKEN="123456789:ABCDEFGH-IKLMNOPQRSTUVWXYZ"
    CHAT_ID="$1"
    MESSAGE="$3"
    
    curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
    -d chat_id="${CHAT_ID}" \
    -d text="${MESSAGE}"
  4. Save and exit (CTRL + X, Y, Enter).
  5. Grant execution permission to the script:
    sudo chmod +x telegram.sh

📌 Step 5: Assign Telegram to a User

  1. Go to Administration > Users > Select User > Media > Add.
  2. Type: Telegram
  3. Send To: 123456789 (Enter your User ID)
  4. When Active: Always
  5. Status: Enabled

telegram zabbix settings

📌 Step 6: Test the Integration

  1. Navigate to Configuration > Actions > Trigger Actions.
  2. Create a new trigger (e.g., Host Down).
  3. If everything is set up correctly, you will receive an instant notification on Telegram ✅

Zabbix Download Link

Benzer yazılar

Aramak istediğinizi üstte yazmaya başlayın ve aramak için enter tuşuna basın. İptal için ESC tuşuna basın.

Üste dön