19 Ocak 2020 Pazar

Tabbix Pro Push Notification Setup

To use push notification in Tabbix Pro,

1. Copy your device token from Tabbix Pro. To do that, go to Settings in Tabbix Pro. You will see the device token in here. We will use this token. You can copy and email it to yourself.


2. You need to create zabbix script to send notification to your device. Create a file named tabbix.sh with code as below.

#!/bin/sh
export posturl=https://tabbix.azurewebsites.net/api/tabbixpro/send
export posttoken="$1"
export postsubject="$2"
export postbody="$3"

curl --data "token=$posttoken&subject=$postsubject&body=$postbody" $posturl

PS: The endpoint works only with POST method. When you use --data option with curl, it automatically make POST request.

3. Save this file in alertscripts folder in Zabbix server. My alertscripts folder is in this path /usr/lib/zabbix/alertscripts. You can find your path in zabbix_server.conf file.

4. Make tabbix.sh file executable with this command.
chmod +x tabbix.sh

5. Yo need to create new Media Type in Zabbix. Go to Administration > Media types in Zabbix Web user interface and click "Create media type" and fill fields as below


Name: Tabbix
Type : Script
Script name : tabbix.sh
Script Parameters:
1. {ALERT.SENDTO}
2. {ALERT.SUBJECT}
3. {ALERT.MESSAGE}

Enabled : checked
Click Add.

6. Use this media in user. Go to Administration > Users. Click a user who want to use this meda. Click Media type tab and click Add to add Tabbix Media to that user. Fill fields as below



Type : Tabbix
Send to : Your device token that copied in first item.
When Active : You can chose day and times. You can leave as is if you don't need any limitation
Use if severity : You can choose severity. Leave as is if you don't need any limitation
Enabled : checked

Click Add.

Now you can use Tabbix media in your Actions whatever you want as your other actions.

Important
Be careful when using push notification service. It use https service, but it is not E2E (end-to-end encryption).

General Help : https://tech.tirgil.com/2013/04/tabbix-help-tabbix-manual.html




10 yorum:

  1. I'm running Zabbix 4.4.1 on Ubuntu Server 18.04. Followed the instructions above - didn't work.

    After reviewing the logs i saw the error "Cannot execute command /etc/zabbix/alert.d/tabbix.sh". [2] No such file or directory.

    I moved the tabbix.sh script from /usr/lib/zabbix/alertscripts to /etc/zabbix/alert.d/ and this fixed the problem.

    Please note, the alerts.d folder did not exist, i had to create it.

    YanıtlaSil
  2. Hi Clint, you can find the right path in zabbix_server.conf file. Probably your configuration for alertscript is "/etc/zabbix/alert.d/". You already did it and fixed the problem.

    YanıtlaSil

  3. I did everything as instructed, but it still doesn't work. He uses the curl service and previously I had this same problem with the telegram, because I need a version for the php to run another service. Can anyone tell me if the version can compromise and which is necessary. I tried switching but it didn't work anyway.

    YanıtlaSil
    Yanıtlar
    1. You can use any service instead of curl, but you need to be careful about sending data by POST method, not GET method.

      Sil
    2. I get the error message:
      curl: (3) URL using bad/illegal format or missing URL

      Any solutions for this problem?

      Sil
    3. Hi Andreas, could you please contact me via tirgil@gmail.com. btw do your parameters have special characters? Please test it with simple words.

      Sil
  4. Hi, I can't get this to work, using Debian 12 and Zabbix 7.0 LTS. Gett error: sh: 1: /usr/lib/zabbix/alertscripts/tabbix.sh: not found
    But I have the script in: /usr/lib/zabbix/alertscripts

    YanıtlaSil
    Yanıtlar
    1. Hi, could you please put your script here "/usr/local/share/zabbix/alertscripts"? It is the Zabbix 7 default custom script folder.

      Sil
  5. Is there any way for me to see push attempts in the logs? I had Tabbix working a while back and it stopped. I've recently updated to ZabbixV7 and reconfigured but still not working. Email alerts are working fine and I have Tabbix configured in the same actions

    YanıtlaSil
    Yanıtlar
    1. Hi, Tabbix doesn't support pust notifications anymore. You have to use TabbixPro.

      Sil