Eyes for Zabbix

Push Notifications


You need to find the zabbix config and look at the path to alertscripts.

                        [root@zabbix ~]# find / -name "zabbix_server.conf"
/etc/zabbix/zabbix_server.conf
[root@zabbix ~]#
                    

Find path to alertscripts folder.

                        [root@zabbix ~]# grep AlertScriptsPath= /etc/zabbix/zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts
[root@zabbix ~]#
                    

Go to the alertscripts directory, create a file and give execute permissions.

                        [root@zabbix ~]# cd /usr/lib/zabbix/alertscripts && touch ./efz.sh
[root@zabbix alertscripts]# chmod +x efz.sh
[root@zabbix alertscripts]# nano efz.sh
                    

Open the file with a text editor (nano in my case) and paste the code below


#!/bin/sh

export url=https://efz.vvapp.online/api/send
export tokens="$1"
export subject="$2"
export body="$3"

IFS=',' read -r -a prepareToArray <<< "$tokens"
trimBody=$(sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' <<< "$body")

stringToArray() {
  echo -n '['
  while [ $# -gt 0 ]; do
    prepareToArray=${1//\\/\\\\}
    echo -n \"${prepareToArray//\"/\\\"}\"
    [ $# -gt 1 ] && echo -n ', '
    shift
  done
  echo ']'
}

arrayData=$(stringToArray "${prepareToArray[@]}")

generatePostData()
{
  cat <<EOF
{
 "tokens": $arrayData,
 "title": "$subject",
 "body": "$trimBody"
}
EOF
}

curl -X POST $url -H \
'Content-Type: application/json' -d \
"$(generatePostData)"

Go to Zabbix->Admisistartion->Media types->Create media type



Test Script



Copy token from you device



Insert token to "Send to". If you need to send a message to multiple devices, then you must specify the tokens separated by a comma without spaces.


IMPORTANT! We do not read or store your messages. We only deliver them via "Google Cloud Messaging" like Telegram or any other app downloaded from the Play Store.