Sending Bacula notifications using Telegram

To send notifications using Telegram is it possible with an API written in C, called “Telegram Messenger CLI”, that is a command line interface that interacts with Telegram servers. One advantage of the telegram-cli instead yowsup, is possible receive notifications in many device in the same time.

Required dependencies to install using apt-get

Download source and compile

Configure directories for telegram-cli

Copy public keys and telegram-cli binary

Create default config /etc/telegram.conf

Execute telegram-cli and request authorization. If you have problems to register the Telegram, access, because the codes are send to web interface also.

If all goes well you are already able to send messages using the telegram-cli. Realize that you are in a terminal, if you type “help”, will show all available commands. You can send messages using the user name, but it is better to use user ID. To find the user ID, at telegram-cli terminal type “get_self” and get the code inside the parentheses after the # on the first line. The user ID is the number 123456789, for example.

To check if the telegram-cli is ready to send messages, use the following command:

If occurs an error like “FAIL: 71: RPC_CALL_FAIL 400: PEER_ID_INVALID”, is necessary add the contact to contact list.

To send messages for a group, is necessary creates a new group or use an existing one and add to the group the number will be used to send the messages. I suggest create a group name or change name to monosyllabic word. Example: Bacula.

To find the group ID, at telegram-cli terminal type “chat_info Bacula” and write the code inside the parentheses. The group ID number is 123456789, for example.

To check if the telegram-cli is ready to send messages for a group, use the following command:

Send using command line

Create an script file /etc/bacula/scripts/ and give permission a+x. (For the Emoji works properly it is necessary that the file is in UTF8 encoding) (The script is pretty similar with only with some modifications)

Change Bacula Config You can set in a few some Jobs, but how I wanted in all, I set up in JobDefs. It should include the RunScript, as indicated below, save and do reload in bconsole:

Example of message:



Leave a Reply

Your email address will not be published. Required fields are marked *