bundles/nginx: add monitoring
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
65a8efc97f
commit
8cb997133a
5 changed files with 528 additions and 1 deletions
|
@ -11,6 +11,18 @@ defaults = {
|
|||
'nginx': {},
|
||||
},
|
||||
},
|
||||
'icinga2_api': {
|
||||
'nginx': {
|
||||
'services': {
|
||||
'NGINX PROCESS': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit nginx',
|
||||
},
|
||||
'NGINX STATUS': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_nginx_status',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'nginx': {
|
||||
'worker_connections': 768,
|
||||
'use_ssl_for_all_connections': True,
|
||||
|
@ -70,3 +82,40 @@ def index_files(metadata):
|
|||
'vhosts': vhosts,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
def monitoring(metadata):
|
||||
services = {}
|
||||
|
||||
for vname, vconfig in metadata.get('nginx/vhosts', {}).items():
|
||||
domain = vconfig.get('domain', vname)
|
||||
|
||||
if 'website_check_path' in vconfig and 'website_check_string' in vconfig:
|
||||
services['NGINX VHOST {} CONTENT'.format(vname)] = {
|
||||
'check_command': 'check_http_wget',
|
||||
'vars.http_wget_contains': vconfig['website_check_string'],
|
||||
'vars.http_wget_url': '{}{}'.format(domain, vconfig['website_check_path']),
|
||||
}
|
||||
|
||||
if vconfig.get('check_ssl', False):
|
||||
services['NGINX VHOST {} CERTIFICATE'.format(vname)] = {
|
||||
'check_command': 'check_vhost_https_cert_at_url',
|
||||
'vars.domain': domain,
|
||||
}
|
||||
|
||||
max_connections = metadata.get('nginx/worker_connections') * metadata.get('nginx/worker_processes')
|
||||
connections_warn = int(max_connections * 0.8)
|
||||
connections_crit = int(max_connections * 0.9)
|
||||
|
||||
services['NGINX STATUS'] = {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_nginx_status --warn={},-1,-1 --critical={},-1,-1 -H 127.0.0.1:22999'.format(connections_warn, connections_crit),
|
||||
}
|
||||
|
||||
return {
|
||||
'icinga2_api': {
|
||||
'nginx': {
|
||||
'services': services,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue