commit
						b450298c28
					
				
					 1 changed files with 166 additions and 21 deletions
				
			
		
							
								
								
									
										187
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										187
									
								
								README.md
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -43,26 +43,89 @@ 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.
 | 
			
		||||
 | 
			
		||||
`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`
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Icinga2 objects
 | 
			
		||||
#### Example Notification Object
 | 
			
		||||
 | 
			
		||||
```ini
 | 
			
		||||
apply Notification "Host by Telegram" to Host {
 | 
			
		||||
    command = "Notify Host By Telegram"
 | 
			
		||||
    interval = 1h
 | 
			
		||||
    assign where host.vars.notification_type == "Telegram"
 | 
			
		||||
    users = [ "telegram_unixe" ]
 | 
			
		||||
    vars.notification_logtosyslog = true
 | 
			
		||||
    vars.telegram_bot = "<YOUR_TELEGRAM_BOT_NAME>"
 | 
			
		||||
    vars.telegram_chatid = "<YOUR_TELEGRAM_CHAT_ID>"
 | 
			
		||||
    vars.telegram_bottoken = "<YOUR_TELEGRAM_BOT_TOKEN>"
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
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
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
#### Example Command Definitions
 | 
			
		||||
### Icinga2 objects
 | 
			
		||||
#### Example host objects
 | 
			
		||||
<details>
 | 
			
		||||
   <summary>Example host template</summary>
 | 
			
		||||
 | 
			
		||||
```ini
 | 
			
		||||
template Host "Generic Host Template" {
 | 
			
		||||
  check_command = "hostalive"
 | 
			
		||||
  max_check_attempts = "3"
 | 
			
		||||
  check_interval = 1m
 | 
			
		||||
  retry_interval = 1m
 | 
			
		||||
  check_timeout = 30s
 | 
			
		||||
  enable_notifications = true
 | 
			
		||||
  enable_active_checks = true
 | 
			
		||||
  enable_passive_checks = true
 | 
			
		||||
  enable_event_handler = true
 | 
			
		||||
  enable_flapping = true
 | 
			
		||||
  enable_perfdata = true
 | 
			
		||||
  volatile = false
 | 
			
		||||
  vars.notification_type = "Telegram"
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
<details>
 | 
			
		||||
   <summary>Example host object</summary>
 | 
			
		||||
      
 | 
			
		||||
```ini
 | 
			
		||||
object Host "icinga2-master" {
 | 
			
		||||
    import "Generic Host Template"
 | 
			
		||||
    address = "127.0.0.1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
#### Example user templates
 | 
			
		||||
<details>
 | 
			
		||||
   <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
 | 
			
		||||
object NotificationCommand "Notify Host By Telegram" {
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +177,10 @@ object NotificationCommand "Notify Host By Telegram" {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
<details>
 | 
			
		||||
   <summary>Notification Command: Services by Telegram</summary>
 | 
			
		||||
 | 
			
		||||
```ini
 | 
			
		||||
object NotificationCommand "Notify Service By Telegram" {
 | 
			
		||||
| 
						 | 
				
			
			@ -173,12 +240,90 @@ object NotificationCommand "Notify Service By Telegram" {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
#### Example Director config
 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
#### 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
 | 
			
		||||
<details>
 | 
			
		||||
   <summary>Notifications by Telegram via Icinga Director</summary>
 | 
			
		||||
   
 | 
			
		||||

 | 
			
		||||
</details>
 | 
			
		||||
 | 
			
		||||
#### Related Director Baskets
 | 
			
		||||
 | 
			
		||||
* [Just the Commands](contrib/Director-Basket_Telegram_Commands.json)
 | 
			
		||||
* [Commands and Notification Templates with fields](contrib/Director-Basket_Telegram_Notifications.json)
 | 
			
		||||
  (requires Director v1.8.0 or a master newer than [80f9ea2](https://github.com/Icinga/icingaweb2-module-director/commit/80f9ea2)
 | 
			
		||||
  (requires Director v1.8.0 or a master newer than [80f9ea2])(https://github.com/Icinga/icingaweb2-module-director/commit/80f9ea2)
 | 
			
		||||
		Loading…
	
		Reference in a new issue