Create an Ansible contactgroup in Nagios and tie it to all alerts, enroll our Matrix user in that group

This commit is contained in:
Salt 2021-12-24 16:56:06 -06:00
parent 1791c40465
commit 8612eec85e
2 changed files with 17 additions and 0 deletions

View File

@ -149,6 +149,9 @@
- name: matrix
host_notification_commands: notify-host-by-matrix
service_notification_commands: notify-service-by-matrix
extra:
- key: contactgroups
value: ansible
- name: salt
host_notification_commands: notify-host-by-email
service_notification_commands: notify-service-by-email

View File

@ -54,6 +54,13 @@ define contact {
{% endfor %}
{% endif %}
# And a contactgroup
define contactgroup {
contactgroup_name ansible
alias Ansible notification contacts
members nagiosadmin
}
{% if nagios_commands is defined %}
# Commands
# Everything here is defined in nagios_commands
@ -79,6 +86,7 @@ define service {
service_description {{ service.name }}
check_command {{ service.command }}
hostgroup_name {{ service.hostgroup | default('ansible', true) }}
contact_groups ansible
{% if service.extra is defined %}
{% for kvp in service.extra %}
{{ kvp.key }} {{ kvp.value }}
@ -121,6 +129,7 @@ define host {
address {{ host.value.primary_ip.address.split('/',1)[0] }}
hostgroups ansible{% for tag in host.value.tags %},tag-{{ tag.slug }}{% endfor %}{% if host.value.device_role is defined -%},role-{{ host.value.device_role.slug }}{% endif %}{% if host.value.role is defined %},role-{{ host.value.role.slug }}{% endif %}
contact_groups ansible
}
{% if host.value.config_context.extra_checks is defined %}
{% for check in host.value.config_context.extra_checks %}
@ -130,6 +139,7 @@ define host {
service_description {{ check.description }}
check_command {{ check.command }}
host_name {{ host.value.name }}
contact_groups ansible
}
{% endfor %}
{% endif %}
@ -159,6 +169,7 @@ define service {
service_description Minecraft - {{ service.value.name }} - {{ port }}
check_command check_by_ssh!/usr/local/bin/monitoring-scripts/check_minecraft -H {{ host_name }} -p {{ port }} -m "{{ service.value.description }}" -f -w 3 -c 5
host_name {{ host_name }}
contact_groups ansible
}
{% endfor %}
{% endif %}
@ -170,6 +181,7 @@ define service {
service_description HTTP - {{ service.value.name }} - {{ port }}
check_command check_http!-H {{ service.value.name }} -p {{ port }} -f sticky
host_name {{ host_name }}
contact_groups ansible
}
{% endfor %}
{% endif %}
@ -181,6 +193,7 @@ define service {
service_description HTTPS - {{ service.value.name }} - {{ port }}
check_command check_http!--ssl -H {{ service.value.name }} -p {{ port }} -f sticky
host_name {{ host_name }}
contact_groups ansible
}
{% endfor %}
{% endif %}
@ -192,6 +205,7 @@ define service {
service_description TCP {{ service.value.name }} - {{ port }}
check_command check_tcp!{{ port }}
host_name {{ host_name }}
contact_groups ansible
}
{% endfor %}
{% endif %}