diff --git a/playbooks/prod_web.yml b/playbooks/prod_web.yml index 60e02c3..546684e 100755 --- a/playbooks/prod_web.yml +++ b/playbooks/prod_web.yml @@ -227,8 +227,10 @@ # R720 - name: CPU0 Temperature command: check_by_ssh!/usr/bin/sudo /usr/local/bin/monitoring-scripts/check_temp -w 65 -c 75 --sensor coretemp-isa-0000 + hostgroup: device-type-r720 - name: CPU1 Temperature command: check_by_ssh!/usr/bin/sudo /usr/local/bin/monitoring-scripts/check_temp -w 65 -c 75 --sensor coretemp-isa-0001 + hostgroup: device-type-r720 # Device role checks # hypervisor (which is assumed to be Proxmox) - name: PVE Unit pve-firewall.service diff --git a/roles/nagios/templates/nagios-ansible.cfg.j2 b/roles/nagios/templates/nagios-ansible.cfg.j2 index d7055b5..8c8690d 100644 --- a/roles/nagios/templates/nagios-ansible.cfg.j2 +++ b/roles/nagios/templates/nagios-ansible.cfg.j2 @@ -128,6 +128,13 @@ define hostgroup { alias {{ tag.value.display }} } {% endfor %} +{% for type in query('netbox.netbox.nb_lookup', 'device-types', api_endpoint='https://netbox.desu.ltd', token=netbox_token) %} +# Type: {{ type.value.display }} +define hostgroup { + hostgroup_name device-type-{{ type.value.slug }} + alias {{ type.value.display }} +} +{% endfor %} # Hosts {% for host in query('netbox.netbox.nb_lookup', 'devices', api_endpoint='https://netbox.desu.ltd', token=netbox_token) + query('netbox.netbox.nb_lookup', 'virtual-machines', api_endpoint='https://netbox.desu.ltd', token=netbox_token)%} @@ -140,7 +147,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-{{ 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 %}{% if host.value.device_type is defined %},device-type-{{ host.value.device_type.slug }}{% endif %} contact_groups ansible }