Add templating, catch Exceptions and lowercase arguments

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2020-11-26 12:57:32 +01:00
commit cbf5132b69
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
3 changed files with 77 additions and 45 deletions

View file

@ -50,3 +50,23 @@ tail -f /var/log/nagios4/telegram.log
```
Log level can be raised using `--verbose` or even more with `--debug` arguments.
## Message format
`notify-by-telegram` script uses the `MarkdownV2` format to generate Telegram messages.
[Jinja](https://jinja.palletsprojects.com) is used for templating (eg. replace `{{host_name}}` placeholders by the value submitted by Nagios).
Default **host** and **service** templates can be found in the [templates](templates) directory.
They can be overriden in the configuration file:
```json
{
"host_template": "/etc/nagios4/host.md.j2",
"service_template": "/etc/nagios4/service.md.j2"
}
```
Both options are optional.