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
|
# 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) %}
|
{% for tag in query('netbox.netbox.nb_lookup', 'tags', api_endpoint='https://netbox.desu.ltd', token=netbox_token) %}
|
||||||
define hostgroup {
|
define hostgroup {
|
||||||
hostgroup_name {{ tag.value.slug }}
|
hostgroup_name tag-{{ tag.value.slug }}
|
||||||
alias {{ tag.value.display }}
|
alias {{ tag.value.display }}
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -95,7 +95,7 @@ define host {
|
|||||||
host_name {{ host.value.name }}
|
host_name {{ host.value.name }}
|
||||||
alias {{ host.value.display }}
|
alias {{ host.value.display }}
|
||||||
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.slug }}{% endfor %}
|
hostgroups ansible{% for tag in host.value.tags %},tag-{{ tag.slug }}{% endfor %}
|
||||||
|
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
# Agentless checks
|
# Agentless checks
|
||||||
- name: HTTP
|
- name: HTTP
|
||||||
command: check_http
|
command: check_http
|
||||||
hostgroup: nagios-checkhttp
|
hostgroup: tag-nagios-checkhttp
|
||||||
- name: HTTPS
|
- name: HTTPS
|
||||||
command: check_http!--ssl
|
command: check_http!--ssl
|
||||||
hostgroup: nagios-checkhttp
|
hostgroup: tag-nagios-checkhttp
|
||||||
- name: SSH
|
- name: SSH
|
||||||
command: check_ssh
|
command: check_ssh
|
||||||
# check_by_ssh checks
|
# check_by_ssh checks
|
||||||
@ -50,31 +50,31 @@
|
|||||||
# ansible-pull
|
# ansible-pull
|
||||||
- name: Unit ansible-pull.service
|
- name: Unit ansible-pull.service
|
||||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_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
|
- name: Unit ansible-pull.timer
|
||||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_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
|
# docker
|
||||||
# Strictly speaking not a tag, but it's best to keep it separated
|
# Strictly speaking not a tag, but it's best to keep it separated
|
||||||
# TODO: Figure out how I'm going to implement Docker checks
|
# TODO: Figure out how I'm going to implement Docker checks
|
||||||
# nagios-checkpgsql
|
# nagios-checkpgsql
|
||||||
- name: PSQL
|
- 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"
|
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
|
- 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"
|
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
|
- name: Unit postgresql.service
|
||||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_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
|
# nagios-checkswap
|
||||||
- name: Swap Usage
|
- name: Swap Usage
|
||||||
command: check_by_ssh!/usr/lib/nagios/plugins/check_swap -w 20% -c 10%
|
command: check_by_ssh!/usr/lib/nagios/plugins/check_swap -w 20% -c 10%
|
||||||
hostgroup: nagios-checkswap
|
hostgroup: tag-nagios-checkswap
|
||||||
# zerotier
|
# zerotier
|
||||||
- name: Unit zerotier-one.service
|
- name: Unit zerotier-one.service
|
||||||
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_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
|
register: config
|
||||||
tags: [ nagios, template ]
|
tags: [ nagios, template ]
|
||||||
- name: assure config file is loaded
|
- name: assure config file is loaded
|
||||||
|
Loading…
Reference in New Issue
Block a user