Sanitize tag hostgroups in nagios with the tag- prefix
Stumbled across an issue where I can't have a Netbox tag that's just 'ansible'
This commit is contained in:
parent
0c8aa0a90f
commit
427014f2ae
@ -80,7 +80,7 @@ define service {
|
||||
# Everything here is dynamically-generated based on tags from Netbox
|
||||
{% for tag in query('netbox.netbox.nb_lookup', 'tags', api_endpoint='https://netbox.desu.ltd', token=netbox_token) %}
|
||||
define hostgroup {
|
||||
hostgroup_name {{ tag.value.slug }}
|
||||
hostgroup_name tag-{{ tag.value.slug }}
|
||||
alias {{ tag.value.display }}
|
||||
}
|
||||
{% endfor %}
|
||||
@ -95,7 +95,7 @@ define host {
|
||||
host_name {{ host.value.name }}
|
||||
alias {{ host.value.display }}
|
||||
address {{ host.value.primary_ip.address.split('/',1)[0] }}
|
||||
hostgroups ansible{% for tag in host.value.tags %},{{ tag.slug }}{% endfor %}
|
||||
hostgroups ansible{% for tag in host.value.tags %},tag-{{ tag.slug }}{% endfor %}
|
||||
|
||||
}
|
||||
{% endif %}
|
||||
|
@ -15,10 +15,10 @@
|
||||
# Agentless checks
|
||||
- name: HTTP
|
||||
command: check_http
|
||||
hostgroup: nagios-checkhttp
|
||||
hostgroup: tag-nagios-checkhttp
|
||||
- name: HTTPS
|
||||
command: check_http!--ssl
|
||||
hostgroup: nagios-checkhttp
|
||||
hostgroup: tag-nagios-checkhttp
|
||||
- name: SSH
|
||||
command: check_ssh
|
||||
# check_by_ssh checks
|
||||
@ -50,31 +50,31 @@
|
||||
# ansible-pull
|
||||
- name: Unit ansible-pull.service
|
||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit ansible-pull.service
|
||||
hostgroup: ansible-pull
|
||||
hostgroup: tag-ansible-pull
|
||||
- name: Unit ansible-pull.timer
|
||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit ansible-pull.timer
|
||||
hostgroup: ansible-pull
|
||||
hostgroup: tag-ansible-pull
|
||||
# docker
|
||||
# Strictly speaking not a tag, but it's best to keep it separated
|
||||
# TODO: Figure out how I'm going to implement Docker checks
|
||||
# nagios-checkpgsql
|
||||
- name: PSQL
|
||||
command: "check_by_ssh!/usr/lib/nagios/plugins/check_pgsql -H localhost -l nagios -p {{ secret_postgresql_monitoring_password }} -w 2 -c 5"
|
||||
hostgroup: nagios-checkpgsql
|
||||
hostgroup: tag-nagios-checkpgsql
|
||||
- name: PSQL Connections
|
||||
command: "check_by_ssh!/usr/lib/nagios/plugins/check_pgsql -H localhost -l nagios -p {{ secret_postgresql_monitoring_password }} -w 2 -c 5 -q 'select (select count(*)::float used from pg_stat_activity) / (select setting::int max_conn from pg_settings where name=\\$\\$max_connections\\$\\$)' -W 0.5-0.7 -C 0.7-1.0"
|
||||
hostgroup: nagios-checkpgsql
|
||||
hostgroup: tag-nagios-checkpgsql
|
||||
- name: Unit postgresql.service
|
||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit postgresql.service
|
||||
hostgroup: nagios-checkpgsql
|
||||
hostgroup: tag-nagios-checkpgsql
|
||||
# nagios-checkswap
|
||||
- name: Swap Usage
|
||||
command: check_by_ssh!/usr/lib/nagios/plugins/check_swap -w 20% -c 10%
|
||||
hostgroup: nagios-checkswap
|
||||
hostgroup: tag-nagios-checkswap
|
||||
# zerotier
|
||||
- name: Unit zerotier-one.service
|
||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit zerotier-one.service
|
||||
hostgroup: zerotier
|
||||
hostgroup: tag-zerotier
|
||||
register: config
|
||||
tags: [ nagios, template ]
|
||||
- name: assure config file is loaded
|
||||
|
Loading…
Reference in New Issue
Block a user