Compare commits

..

3 Commits

Author SHA1 Message Date
8e845b5f4e Modularize out all our service checks
I want them in DATA STRUCTURES God dammit. Get them out of the config file.
2021-09-06 19:43:54 -05:00
d3e51301bb Remove deprecated SNMP service checks 2021-09-06 19:23:54 -05:00
fc2b3cb7b3 Rename Nagios config to more appropriately reflect its role 2021-09-06 19:13:15 -05:00
2 changed files with 62 additions and 99 deletions

View File

@ -50,113 +50,29 @@ define service {
}
# Commands
define command {
# This command was manually added and should be present in all backups
command_name check_snmp_storage_v3
command_line /opt/Custom-Nagios-Plugins/check_snmp_storage.pl -H $HOSTADDRESS$ -l {{ secret_snmp_rouser_username }} -x {{ secret_snmp_rouser_password }} -X {{ secret_snmp_rouser_privacy_passphrase }} -L sha,aes -t 20 -m $ARG1$ -w $ARG2$ -c $ARG3$
}
define command {
# This command is included in the container image
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
# Services for all hosts
# Services
# Everything here is defined in nagios_services
{% if nagios_services is defined %}
{% for service in nagios_services %}
define service {
use ansible-generic-service
service_description HTTP
check_command check_http
hostgroup_name nagios-checkhttp
}
define service {
use ansible-generic-service
service_description HTTPS
check_command check_http!--ssl
hostgroup_name nagios-checkhttp
}
# Services for SNMP-capable hosts
define service {
use ansible-generic-service
service_description Hostname
check_command check_snmp!-P 3 -a SHA -x AES -o 1.3.6.1.2.1.1.1.0 -U {{ secret_snmp_rouser_username }} -A {{ secret_snmp_rouser_password }} -X {{ secret_snmp_rouser_privacy_passphrase }} -r $HOSTNAME$ -L authPriv
hostgroup_name snmp
}
define service {
use ansible-generic-service
service_description Disk Usage
check_command check_snmp_storage_v3!^/$!85!90
hostgroup_name snmp
}
# Services for NRPE-capable hosts
define service {
use ansible-generic-service
service_description Disk Usage
check_command check_nrpe!check_disk_all
hostgroup_name nagios-nrpe
}
define service {
use ansible-generic-service
service_description Users
check_command check_nrpe!check_users
hostgroup_name nagios-nrpe
}
define service {
use ansible-generic-service
service_description CPU Load
check_command check_nrpe!check_load
hostgroup_name nagios-nrpe
}
define service {
use ansible-generic-service
service_description Reboot Required
check_command check_nrpe!check_reboot_required
hostgroup_name nagios-nrpe
}
# Systemd unit checks
define service {
use ansible-generic-service
service_description Unit backup.service
check_command check_nrpe!check_systemd_backup_service
hostgroup_name nagios-nrpe
}
define service {
use ansible-generic-service
service_description Unit backup.timer
check_command check_nrpe!check_systemd_backup_timer
hostgroup_name nagios-nrpe
}
define service {
use ansible-generic-service
service_description Unit ansible-pull.service
check_command check_nrpe!check_systemd_ansiblepull_service
hostgroup_name ansible-pull
}
define service {
use ansible-generic-service
service_description Unit ansible-pull.timer
check_command check_nrpe!check_systemd_ansiblepull_timer
hostgroup_name ansible-pull
}
define service {
use ansible-generic-service
service_description Unit docker.service
check_command check_nrpe!check_systemd_docker_service
hostgroup_name nagios-nrpe
}
define service {
use ansible-generic-service
service_description Swap Usage
check_command check_nrpe!check_swap
hostgroup_name nagios-nrpeswap
}
define service {
use ansible-generic-service
service_description PostgreSQL
check_command check_nrpe!check_pgsql
hostgroup_name nagios-checkpgsql
service_description {{ service.name }}
check_command {{ service.command }}
hostgroup_name {{ service.hostgroup }}
{% if service.extra is defined %}
{% for kvp in service.extra %}
{{ kvp.key }} {{ kvp.value }}
{% endfor %}
{% endif %}
}
{% endfor %}
{% endif %}
# Hostgroups
# Everything here is dynamically-generated based on tags from Netbox

View File

@ -3,7 +3,54 @@
file: path=/data/nagios state=directory mode=0755
tags: [ nagios ]
- name: template out config for nagios
template: src=nagios-hosts.cfg.j2 dest=/data/nagios/etc/objects/ansible.cfg owner=root group=root mode=0644
template: src=nagios-ansible.cfg.j2 dest=/data/nagios/etc/objects/ansible.cfg owner=root group=root mode=0644
vars:
nagios_services:
# Agentless checks
- name: HTTP
command: check_http
hostgroup: nagios-checkhttp
- name: HTTPS
command: check_http!--ssl
hostgroup: nagios-checkhttp
# Agented checks
- name: CPU Load
command: check_nrpe!check_load
hostgroup: nagios-nrpe
- name: Disk Usage
command: check_nrpe!check_disk_all
hostgroup: nagios-nrpe
- name: Reboot Required
command: check_nrpe!check_reboot_required
hostgroup: nagios-nrpe
- name: Unit backup.service
command: check_nrpe!check_systemd_backup_service
hostgroup: nagios-nrpe
- name: Unit backup.timer
command: check_nrpe!check_systemd_backup_timer
hostgroup: nagios-nrpe
- name: Unit docker.service
command: check_nrpe!check_systemd_docker_service
hostgroup: nagios-nrpe
- name: Users
command: check_nrpe!check_users
hostgroup: nagios-nrpe
# Tag-specific checks
# ansible-pull
- name: Unit ansible-pull.service
command: check_nrpe!check_systemd_ansiblepull_service
hostgroup: ansible-pull
- name: Unit ansible-pull.timer
command: check_nrpe!check_systemd_ansiblepull_timer
hostgroup: ansible-pull
# nagios-checkpgsql
- name: PostgreSQL
command: check_nrpe!check_pgsql
hostgroup: nagios-checkpgsql
# nagios-nrpeswap
- name: Swap Usage
command: check_nrpe!check_swap
hostgroup: nagios-nrpeswap
register: config
tags: [ nagios, template ]
- name: assure config file is loaded