Create an Ansible contactgroup in Nagios and tie it to all alerts, enroll our Matrix user in that group
This commit is contained in:
parent
1791c40465
commit
8612eec85e
@ -149,6 +149,9 @@
|
|||||||
- name: matrix
|
- name: matrix
|
||||||
host_notification_commands: notify-host-by-matrix
|
host_notification_commands: notify-host-by-matrix
|
||||||
service_notification_commands: notify-service-by-matrix
|
service_notification_commands: notify-service-by-matrix
|
||||||
|
extra:
|
||||||
|
- key: contactgroups
|
||||||
|
value: ansible
|
||||||
- name: salt
|
- name: salt
|
||||||
host_notification_commands: notify-host-by-email
|
host_notification_commands: notify-host-by-email
|
||||||
service_notification_commands: notify-service-by-email
|
service_notification_commands: notify-service-by-email
|
||||||
|
@ -54,6 +54,13 @@ define contact {
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
# And a contactgroup
|
||||||
|
define contactgroup {
|
||||||
|
contactgroup_name ansible
|
||||||
|
alias Ansible notification contacts
|
||||||
|
members nagiosadmin
|
||||||
|
}
|
||||||
|
|
||||||
{% if nagios_commands is defined %}
|
{% if nagios_commands is defined %}
|
||||||
# Commands
|
# Commands
|
||||||
# Everything here is defined in nagios_commands
|
# Everything here is defined in nagios_commands
|
||||||
@ -79,6 +86,7 @@ define service {
|
|||||||
service_description {{ service.name }}
|
service_description {{ service.name }}
|
||||||
check_command {{ service.command }}
|
check_command {{ service.command }}
|
||||||
hostgroup_name {{ service.hostgroup | default('ansible', true) }}
|
hostgroup_name {{ service.hostgroup | default('ansible', true) }}
|
||||||
|
contact_groups ansible
|
||||||
{% if service.extra is defined %}
|
{% if service.extra is defined %}
|
||||||
{% for kvp in service.extra %}
|
{% for kvp in service.extra %}
|
||||||
{{ kvp.key }} {{ kvp.value }}
|
{{ kvp.key }} {{ kvp.value }}
|
||||||
@ -121,6 +129,7 @@ define host {
|
|||||||
address {{ host.value.primary_ip.address.split('/',1)[0] }}
|
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 %}
|
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 %}
|
{% if host.value.config_context.extra_checks is defined %}
|
||||||
{% for check in host.value.config_context.extra_checks %}
|
{% for check in host.value.config_context.extra_checks %}
|
||||||
@ -130,6 +139,7 @@ define host {
|
|||||||
service_description {{ check.description }}
|
service_description {{ check.description }}
|
||||||
check_command {{ check.command }}
|
check_command {{ check.command }}
|
||||||
host_name {{ host.value.name }}
|
host_name {{ host.value.name }}
|
||||||
|
contact_groups ansible
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -159,6 +169,7 @@ define service {
|
|||||||
service_description Minecraft - {{ service.value.name }} - {{ port }}
|
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
|
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 }}
|
host_name {{ host_name }}
|
||||||
|
contact_groups ansible
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -170,6 +181,7 @@ define service {
|
|||||||
service_description HTTP - {{ service.value.name }} - {{ port }}
|
service_description HTTP - {{ service.value.name }} - {{ port }}
|
||||||
check_command check_http!-H {{ service.value.name }} -p {{ port }} -f sticky
|
check_command check_http!-H {{ service.value.name }} -p {{ port }} -f sticky
|
||||||
host_name {{ host_name }}
|
host_name {{ host_name }}
|
||||||
|
contact_groups ansible
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -181,6 +193,7 @@ define service {
|
|||||||
service_description HTTPS - {{ service.value.name }} - {{ port }}
|
service_description HTTPS - {{ service.value.name }} - {{ port }}
|
||||||
check_command check_http!--ssl -H {{ service.value.name }} -p {{ port }} -f sticky
|
check_command check_http!--ssl -H {{ service.value.name }} -p {{ port }} -f sticky
|
||||||
host_name {{ host_name }}
|
host_name {{ host_name }}
|
||||||
|
contact_groups ansible
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -192,6 +205,7 @@ define service {
|
|||||||
service_description TCP {{ service.value.name }} - {{ port }}
|
service_description TCP {{ service.value.name }} - {{ port }}
|
||||||
check_command check_tcp!{{ port }}
|
check_command check_tcp!{{ port }}
|
||||||
host_name {{ host_name }}
|
host_name {{ host_name }}
|
||||||
|
contact_groups ansible
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user