bundles/icinga2: set some notification options for checks

This commit is contained in:
Franzi 2020-11-22 08:24:44 +01:00
parent b114ba3ff8
commit 4a57926577
Signed by: kunsi
GPG key ID: 12E3D2136B818350
10 changed files with 27 additions and 9 deletions

View file

@ -13,3 +13,15 @@ object ServiceGroup "bundle-${bundle}" {
assign where service.vars.bundle == "${bundle}"
}
% endfor
object ServiceGroup "checks_with_mail" {
display_name = "Checks which send E-Mails"
assign where service.vars.notification.mail == true
}
object ServiceGroup "checks_with_sms" {
display_name = "Checks which send SMS"
assign where service.vars.notification.sms == true
}

View file

@ -9,6 +9,8 @@ object Host "${monitored_node.name}" {
vars.period = "${sla_info[monitored_node.metadata.get('sla', '24x7')]}"
vars.location = "${monitored_node.metadata.get('location', 'unknown')}"
vars.bw_groups = [ "${'", "'.join(sorted({group.name for group in monitored_node.groups}))}" ]
vars.notification.sms = ${str(monitored_node.metadata.get('icinga_options', {}).get('vars.notification.sms', True)).lower()}
vars.notification.mail = true
}
% endfor

View file

@ -7,9 +7,6 @@ template Host "generic-host" {
enable_event_handler = true
enable_flapping = false
enable_perfdata = false
vars.notification.sms = true
vars.notification_type = "sms"
}
template Host "host-active" {
@ -36,7 +33,6 @@ template Service "generic-service" {
max_check_attempts = 4
check_interval = 5m
retry_interval = 2m
vars.notification.sms = true
enable_notifications = true
enable_event_handler = true
enable_flapping = false
@ -63,8 +59,6 @@ template Notification "host-notification" {
types = [ Problem, Recovery, Custom ]
user_groups = [ "on-call_sms" ]
period = host.vars.period
vars.notification_type = "sms"
}
template Notification "service-notification" {
@ -73,8 +67,6 @@ template Notification "service-notification" {
types = [ Problem, Recovery, Custom ]
user_groups = [ "on-call_sms" ]
vars.notification_type = "sms"
if(service.vars.period) {
period = service.vars.period
} else {

View file

@ -106,12 +106,14 @@ def monitoring(metadata):
'check_command': 'check_http_wget',
'vars.http_wget_contains': vconfig['website_check_string'],
'vars.http_wget_url': '{}://{}{}'.format(scheme, domain, vconfig['website_check_path']),
'vars.notification.sms': True,
}
if vconfig.get('check_ssl', False):
services['NGINX VHOST {} CERTIFICATE'.format(vname)] = {
'check_command': 'check_vhost_https_cert_at_url',
'vars.domain': domain,
'vars.notification.mail': True,
}
max_connections = metadata.get('nginx/worker_connections') * metadata.get('nginx/worker_processes')

View file

@ -28,6 +28,7 @@ if node.has_bundle('postfixadmin'):
defaults['icinga2_api']['postfix']['services'].update({
'SMTP CONNECT': {
'check_command': 'check_smtp',
'vars.notification.sms': True,
},
'SMTP SUBMISSION CONNECT': {
'check_command': 'check_smtp',

View file

@ -14,6 +14,7 @@ defaults = {
'services': {
'POWERDNS PROCESS': {
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C pdns_server -c 1:',
'vars.notification.mail': True,
},
},
},

View file

@ -96,6 +96,7 @@ def default_checks(metadata):
'-A -I "^/dev$" -I "^/run" -I "^/sys" -i "/sys/kernel/debug/tracing" '
f'{disk_space_ignore_patterns_string}',
),
'vars.notification.mail': True,
},
'MOUNTS': {
'command_on_monitored_host': f'sudo /usr/local/share/icinga/plugins/check_mounts {mounts_options}',

View file

@ -12,6 +12,7 @@ defaults = {
'services': {
'QEMU VM STATUS': {
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_vm_status',
'vars.notification.mail': True,
},
},
},

View file

@ -76,6 +76,7 @@ if node.has_bundle('sshmon'):
},
'ZFS MOUNTED VOLUMES': {
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zfs_volumes',
'vars.notification.mail': True,
},
'ZFS OLD SNAPSHOTS': {
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zfs_old_snapshots',
@ -147,10 +148,12 @@ def monitoring(metadata):
for poolname, pool_options in metadata.get('zfs/pools').items():
services['ZFS ZPOOL ONLINE {}'.format(poolname)] = {
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zpool_online {}'.format(poolname),
'vars.notification.mail': True,
}
services['ZFS ZPOOL SPACE ' + poolname] = {
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zpool_space {} 90'.format(poolname)
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zpool_space {} 90'.format(poolname),
'vars.notification.mail': True,
}
return {

View file

@ -10,6 +10,9 @@ nodes['htz-cloud.sewfile'] = {
'webserver',
},
'metadata': {
'icinga_options': {
'vars.notification.sms': False,
},
'interfaces': {
'eth0': {
'ips': {