bundles/icinga2: introduce new notification period 'daytime'

This commit is contained in:
Franzi 2022-03-05 08:29:10 +01:00
parent 2a57eec1e3
commit 65ba43525f
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 19 additions and 15 deletions

View file

@ -11,8 +11,7 @@ object Host "${rnode.name}" {
# used for status page
vars.pretty_name = "${rnode.metadata.get('icinga_options/pretty_name', rnode.name)}"
vars.period = "${sla_info[rnode.metadata.get('sla', '24x7')]}"
vars.sla = "${rnode.metadata.get('sla', '24x7')}"
vars.period = "${rnode.metadata.get('icinga_options/period', '24x7')}"
vars.notification.sms = ${str(rnode.metadata.get('icinga_options/vars.notification.sms', True)).lower()}
vars.notification.mail = true

View file

@ -6,6 +6,8 @@ apply Notification "notify_host-notification" to Host {
begin = 0m
}
period = host.vars.period
assign where host.vars.notification.sms == true
}
@ -17,6 +19,8 @@ apply Notification "notify_service-notification" to Service {
begin = 0m
}
period = host.vars.period
assign where service.vars.notification.sms == true
ignore where host.vars.notification.sms == false
}
@ -25,6 +29,8 @@ apply Notification "notify_service-notification-mail" to Service {
import "service-notification"
interval = 0
period = host.vars.period
assign where service.vars.notification.mail == true
ignore where service.vars.notification.sms == true
ignore where host.vars.notification.mail == false

View file

@ -13,16 +13,21 @@ object TimePeriod "24x7" {
}
}
object TimePeriod "weekdays_9to6" {
object TimePeriod "daytime" {
import "legacy-timeperiod"
display_name = "9to6 (UTC)"
# 5AM UTC to 8PM UTC
# 6AM MEZ to 9PM MEZ
# 7AM MESZ to 10PM MESZ
display_name = "5AM to 8PM (UTC)"
ranges = {
"monday" = "09:00-18:00"
"tuesday" = "09:00-18:00"
"wednesday" = "09:00-18:00"
"thursday" = "09:00-18:00"
"friday" = "09:00-18:00"
"monday" = "06:00-20:00"
"tuesday" = "06:00-20:00"
"wednesday" = "06:00-20:00"
"thursday" = "06:00-20:00"
"friday" = "06:00-20:00"
"saturday" = "07:00-20:00"
"sunday" = "07:00-20:00"
}
}

View file

@ -11,11 +11,6 @@ ENABLED_FEATURES = {
'notification',
}
SLA_INFO = {
'24x7': '24x7',
'never': 'never',
}
DAYS_TO_STRING = [
'sunday',
'monday',
@ -340,7 +335,6 @@ for rnode in repo.nodes:
'content_type': 'mako',
'context': {
'rnode': rnode,
'sla_info': SLA_INFO,
},
'owner': 'nagios',
'group': 'nagios',