2020-11-25 15:47:41 +01:00
# notify-by-telegram
2020-11-26 08:28:40 +01:00
Send Nagios notifications to a [Telegram Messenger ](https://telegram.org/ ) channel.
2020-11-25 17:13:16 +01:00
## Telegram bot
2020-11-26 08:28:40 +01:00
This [tutorial ](https://takersplace.de/2019/12/19/telegram-notifications-with-nagios/ ) explains how to create a Telegram bot. You'll need the `chat_id` and `auth_key` for the next section.
2020-11-25 17:13:16 +01:00
## Installation
_This guide has been written for [Debian ](https://www.debian.org/ ). Some commands might slightly change depending on your distribution._
Clone the repository:
```
2020-11-26 08:28:40 +01:00
git clone https://github.com/jouir/notify-by-telegram.git /opt/notify-by-telegram
2020-11-25 17:13:16 +01:00
```
Install dependencies using the package manager:
```
sudo apt install python3-jinja2 python3-requests
```
## Configuration
Copy and update the configuration file example:
```
2020-11-26 08:28:40 +01:00
cp -p config.json.example telegram.json
vim telegram.json
sudo mv telegram.json /etc/nagios4/telegram.json
sudo chmod 640 root:nagios /etc/nagios4/telegram.json
2020-11-25 17:13:16 +01:00
```
Ensure Nagios reads the configuration file:
```
2020-11-26 08:28:40 +01:00
echo "cfg_file=/opt/notify-by-telegram/nagios.cfg" >> /etc/nagios4/nagios.cfg
2020-11-25 17:13:16 +01:00
```
Then reload service:
```
systemctl reload nagios4
```
## Logs
Errors logs can be set with the `--logfile` argument.
Example:
```
tail -f /var/log/nagios4/telegram.log
```
Log level can be raised using `--verbose` or even more with `--debug` arguments.