skip to Main Content

I have problems with notifications on zabbix to telegram messenger.
So, I specified different guides for that. But not successful.

For example I use this guides

This solutions works for bash. But I can send this from zabbix.

export to=$1;
export subject=$2;
export body=$3;


tgpath=/usr/src/tg/zabbix
cd ${tgpath}
(sleep 5; echo "msg $to $subject $body"; echo "safe_quit") | 
${tgpath}/telegram-cli -k /etc/telegram-cli/mykey.pub -W 

Key telegram-cli -e does not work correctly with a login name and with format user#XXXXXX;

I dont want to use some API to send message.

Thank you for any help.

2

Answers


  1. Your script is not equal to the blog post.

    The steps are:

    0 – Compile

    cd /usr/src
    git clone --recursive https://github.com/vysheng/tg.git
    cd tg
    ./configure
    make
    mkdir viacron
    cp bin/telegram-cli viacron/
    cp tg-server.pub viacron/
    cd viacron
    

    1 – Create a file /usr/src/tg/viacron/telegram.config an put this:

    default_profile = "viacron";  
    viacron = {  
    config_directory = "/usr/src/tg/viacron/";  
    };      
    

    2 – Create a file /usr/src/tg/viacron/telegram.config an put this:

    #!/bin/bash
    MAIN_DIRECTORY="/usr/src/tg/viacron/"
    USER=$1
    SUBJECT=$2
    TEXT=$3
    cd $MAIN_DIRECTORY
    if [[ $? -ne 0 ]]; then
            echo "Error to enter in the main directory"
            exit 1
    fi
    ./telegram-cli -k tg-server.pub -c telegram.config -WR -e "msg $USER $SUBJECT" || exit 1
    exit 0
    

    3 – Change permissions:

    chmod +x /usr/src/tg/viacron/telegram_standalone.sh
    chown -R yourUser: /usr/src/tg/
    

    4 – Test:

    /usr/src/tg/viacron/telegram_standalone.sh user#12345 "GNU is not unix"
    

    5 – Put AlertScriptsPath=/usr/src/tg/viacron/ in zabbix_server.conf and restart the server

    6 – In zabbix, add new media type with name telegram_standalone.sh

    More information in https://gist.github.com/gnumoksha/a95f237d82733ce1f748 and http://tobias.ws/blog/zabbix-com-notificacoes-pelo-telegram/

    Login or Signup to reply.
  2. Now Telegram supported by default
    check:

    https://www.zabbix.com/integrations/telegram

    and there is extra settings check:

    https://youtu.be/TpP6NpS9jjg?t=143

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search