Update README.md
This commit is contained in:
parent
d7cdc5c0a1
commit
483af2368b
1 changed files with 121 additions and 24 deletions
145
README.md
145
README.md
|
@ -43,28 +43,54 @@ If you do not want to notify a group i.e. just **a direct user notification**:
|
||||||
|
|
||||||
Sending a test notification – replace the token, botname and chat id obviously.
|
Sending a test notification – replace the token, botname and chat id obviously.
|
||||||
|
|
||||||
`sudo -u nagios ./service-by-telegram.sh -4 127.0.0.1 -l myhostname -o testingTGnotifiy -p <myBotname> -q <myGroupChatId> -r "<1234134325:blafasel>" -s CRITICAL -c mycomment -b mycommentuser -i https://myicingaserver/icingaweb2 -n maaaaaaaaaaa -d"$(date +%F-%T)" -e serviceshort -u fullservicename -D`
|
```
|
||||||
|
sudo -u nagios ./service-by-telegram.sh -4 127.0.0.1 \
|
||||||
|
-l myhostname \
|
||||||
### Icinga2 objects
|
-o testingTGnotifiy \
|
||||||
#### Example Notification Object
|
-p <myBotname> \
|
||||||
|
-q <myGroupChatId> \
|
||||||
```ini
|
-r "<1234134325:blafasel>" \
|
||||||
apply Notification "Host by Telegram" to Host {
|
-s CRITICAL \
|
||||||
command = "Notify Host By Telegram"
|
-c mycomment \
|
||||||
interval = 1h
|
-b mycommentuser \
|
||||||
assign where host.vars.notification_type == "Telegram"
|
-i https://myicingaserver/icingaweb2 \
|
||||||
users = [ "telegram_unixe" ]
|
-n maaaaaaaaaaa \
|
||||||
vars.notification_logtosyslog = true
|
-d"$(date +%F-%T)" \
|
||||||
vars.telegram_bot = "<YOUR_TELEGRAM_BOT_NAME>"
|
-e serviceshort \
|
||||||
vars.telegram_chatid = "<YOUR_TELEGRAM_CHAT_ID>"
|
-u fullservicename \
|
||||||
vars.telegram_bottoken = "<YOUR_TELEGRAM_BOT_TOKEN>"
|
-D
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example Command Definitions
|
### Icinga2 objects
|
||||||
|
#### Example user templates
|
||||||
<details>
|
<details>
|
||||||
<summary>object NotificationCommand "Notify Host By Telegram"</summary>
|
<summary>Generic user template</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
template User "Generic User Template" {
|
||||||
|
enable_notifications = true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>User "telegram_bot"</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
object User "telegram_bot" {
|
||||||
|
import "Generic User Template"
|
||||||
|
|
||||||
|
display_name = "Bot via Telegram"
|
||||||
|
email = "you@yourdomain.tld"
|
||||||
|
states = [ Critical, Down, OK, Unknown, Up, Warning ]
|
||||||
|
types = [ Custom, Problem, Recovery ]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
#### Example command definitions
|
||||||
|
<details>
|
||||||
|
<summary>Notification Command: Hosts by Telegram</summary>
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
object NotificationCommand "Notify Host By Telegram" {
|
object NotificationCommand "Notify Host By Telegram" {
|
||||||
|
@ -116,11 +142,10 @@ object NotificationCommand "Notify Host By Telegram" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>object NotificationCommand "Notify Service By Telegram"</summary>
|
<summary>Notification Command: Services by Telegram</summary>
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
object NotificationCommand "Notify Service By Telegram" {
|
object NotificationCommand "Notify Service By Telegram" {
|
||||||
|
@ -180,9 +205,81 @@ object NotificationCommand "Notify Service By Telegram" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
#### Example Director config
|
|
||||||
|
|
||||||
|
#### Example notification objects
|
||||||
|
<!-- NOTIFICATION TEMPLATE TELEGRAM GENERIC -->
|
||||||
|
<details>
|
||||||
|
<summary>Notification Template: Telegram Generic</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
template Notification "Template: Telegram (Generic)" {
|
||||||
|
vars.telegram_bot = "<YOUR_TELEGRAM_BOT_NAME>"
|
||||||
|
vars.telegram_bottoken = "<YOUR_TELEGRAM_BOT_TOKEN>"
|
||||||
|
vars.telegram_chatid = "<YOUR_TELEGRAM_CHAT_ID>"
|
||||||
|
vars.telegram_notification_logtosyslog = true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Notification Template: Host Notifications</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
template Notification "Template: Host Notifications via Telegram" {
|
||||||
|
import "Template: Telegram (Generic)"
|
||||||
|
|
||||||
|
command = "Notify Host By Telegram"
|
||||||
|
interval = 1h
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Notification Template: Service Notifications</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
template Notification "Template: Service Notifications via Telegram" {
|
||||||
|
import "Template: Telegram (Generic)"
|
||||||
|
|
||||||
|
command = "Notify Service By Telegram"
|
||||||
|
interval = 4h
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
#### Example notification apply rules
|
||||||
|
<details>
|
||||||
|
<summary>Apply rule for host notifications</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
apply Notification "Host Alert via @telegram_bot" to Host {
|
||||||
|
import "Template: Host Notifications via Telegram"
|
||||||
|
|
||||||
|
interval = 1h
|
||||||
|
assign where host.vars.notification_type == "Telegram"
|
||||||
|
states = [ Down, Up ]
|
||||||
|
types = [ Custom, Problem, Recovery ]
|
||||||
|
users = [ "telegram_bot" ]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Apply rule for service notifications</summary>
|
||||||
|
|
||||||
|
```ini
|
||||||
|
apply Notification "Service Alerts via @telegram_bot" to Service {
|
||||||
|
import "Template: Service Notifications via Telegram"
|
||||||
|
|
||||||
|
interval = 12h
|
||||||
|
assign where host.vars.notification_type == "Telegram"
|
||||||
|
users = [ "telegram_bot" ]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
#### Example Director screenshot
|
||||||
![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg)
|
![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg)
|
||||||
|
|
Loading…
Reference in a new issue