2021-08-08 00:28:18 -05:00
|
|
|
# vim:ft=ansible:
|
|
|
|
- name: assure data directory for nagios
|
|
|
|
file: path=/data/nagios state=directory mode=0755
|
|
|
|
tags: [ nagios ]
|
2021-08-08 01:20:48 -05:00
|
|
|
- name: template out config for nagios
|
2021-09-06 19:13:15 -05:00
|
|
|
template: src=nagios-ansible.cfg.j2 dest=/data/nagios/etc/objects/ansible.cfg owner=root group=root mode=0644
|
2021-09-06 19:43:54 -05:00
|
|
|
vars:
|
2021-09-07 13:31:04 -05:00
|
|
|
nagios_commands:
|
|
|
|
# This command is included in the container image
|
|
|
|
- name: check_nrpe
|
|
|
|
command: "$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$"
|
2021-09-07 14:27:23 -05:00
|
|
|
- name: check_by_ssh
|
|
|
|
command: "$USER1$/check_by_ssh -H $HOSTADDRESS$ -F /opt/nagios/etc/ssh_config -q -i /opt/nagios/etc/id_ed25519 -l nagios-checker -C \"$ARG1$\""
|
2021-09-06 19:43:54 -05:00
|
|
|
nagios_services:
|
|
|
|
# Agentless checks
|
|
|
|
- name: HTTP
|
|
|
|
command: check_http
|
|
|
|
hostgroup: nagios-checkhttp
|
|
|
|
- name: HTTPS
|
|
|
|
command: check_http!--ssl
|
|
|
|
hostgroup: nagios-checkhttp
|
2021-09-07 13:29:19 -05:00
|
|
|
- name: SSH
|
|
|
|
command: check_ssh
|
2021-09-07 14:27:23 -05:00
|
|
|
# check_by_ssh checks
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: CPU Load
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/lib/nagios/plugins/check_load -r -w 0.8,0.8,0.8 -c 1.0,0.9,0.9
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: Disk Usage
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/lib/nagios/plugins/check_disk -M -u GB -X nfs -X tracefs -X cgroup -X tmpfs -X overlay -X shm -w 15% -c 10% -W 15% -K 10% -A -I '^/run/' -I '^udev$' -I '^/var/lib/kubelet/'
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: Reboot Required
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_reboot_required
|
2021-09-07 14:54:58 -05:00
|
|
|
- name: Unit atd.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit atd.service
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: Unit backup.service
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit backup.service
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: Unit backup.timer
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit backup.timer
|
2021-09-07 15:00:43 -05:00
|
|
|
- name: Unit cron.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit cron.service
|
|
|
|
- name: Unit dbus.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit dbus.service
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: Unit docker.service
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit docker.service
|
2021-09-07 15:00:43 -05:00
|
|
|
- name: Unit polkit.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit polkit.service
|
|
|
|
- name: Unit ssh.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit ssh.service
|
|
|
|
- name: Unit systemd-resolved.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit systemd-resolved.service
|
2021-09-06 19:43:54 -05:00
|
|
|
- name: Users
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/lib/nagios/plugins/check_users -w 3 -c 5
|
2021-09-06 19:43:54 -05:00
|
|
|
# Tag-specific checks
|
|
|
|
# ansible-pull
|
|
|
|
- name: Unit ansible-pull.service
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit ansible-pull.service
|
2021-09-06 19:43:54 -05:00
|
|
|
hostgroup: ansible-pull
|
|
|
|
- name: Unit ansible-pull.timer
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit ansible-pull.timer
|
2021-09-06 19:43:54 -05:00
|
|
|
hostgroup: ansible-pull
|
2021-09-07 15:00:43 -05:00
|
|
|
# zerotier
|
|
|
|
- name: Unit zerotier-one.service
|
|
|
|
command: check_by_ssh!/usr/local/bin/monitoring-scripts/check_systemd_unit zerotier-one.service
|
|
|
|
hostgroup: zerotier
|
2021-09-06 19:43:54 -05:00
|
|
|
# nagios-checkpgsql
|
|
|
|
- name: PostgreSQL
|
2021-09-07 14:27:23 -05:00
|
|
|
command: "check_by_ssh!/usr/lib/nagios/plugins/check_pgsql -H localhost -l nagios -p {{ secret_postgresql_monitoring_password }} -w 2 -c 5"
|
2021-09-06 19:43:54 -05:00
|
|
|
hostgroup: nagios-checkpgsql
|
2021-09-07 15:29:26 -05:00
|
|
|
- name: Unit postgresql.service
|
|
|
|
command: check_by_postgresql!/usr/local/bin/monitoring-scripts/check_systemd_unit postgresql.service
|
|
|
|
hostgroup: nagios-checkpgsql
|
2021-09-06 19:43:54 -05:00
|
|
|
# nagios-nrpeswap
|
|
|
|
- name: Swap Usage
|
2021-09-07 14:27:23 -05:00
|
|
|
command: check_by_ssh!/usr/lib/nagios/plugins/check_swap -w 20% -c 10%
|
2021-09-06 19:43:54 -05:00
|
|
|
hostgroup: nagios-nrpeswap
|
2021-08-08 12:15:10 -05:00
|
|
|
register: config
|
2021-08-08 01:20:48 -05:00
|
|
|
tags: [ nagios, template ]
|
|
|
|
- name: assure config file is loaded
|
|
|
|
lineinfile: path=/data/nagios/etc/nagios.cfg line='cfg_file=/opt/nagios/etc/objects/ansible.cfg'
|
2021-08-08 00:28:18 -05:00
|
|
|
tags: [ nagios, template ]
|
|
|
|
- name: docker deploy nagios
|
|
|
|
docker_container:
|
|
|
|
name: nagios
|
2021-08-08 14:46:58 -05:00
|
|
|
image: jasonrivers/nagios
|
2021-08-08 00:28:18 -05:00
|
|
|
env:
|
|
|
|
NAGIOSADMIN_USER: admin
|
|
|
|
NAGIOSADMIN_PASS: "{{ secret_nagios_admin_pass }}"
|
2021-08-08 14:46:58 -05:00
|
|
|
NAGIOS_TIMEZONE: "America/Chicago"
|
2021-08-08 00:28:18 -05:00
|
|
|
networks:
|
|
|
|
- name: web
|
|
|
|
aliases: [ "nagios" ]
|
|
|
|
volumes:
|
|
|
|
- /data/nagios/etc:/opt/nagios/etc
|
|
|
|
- /data/nagios/var:/opt/nagios/var
|
|
|
|
- /data/nagios/plugins:/opt/Custom-Nagios-Plugins
|
2021-08-08 14:46:58 -05:00
|
|
|
- /data/nagios/nagiosgraph/var:/opt/nagiosgraph/var
|
|
|
|
- /data/nagios/nagiosgraph/etc:/opt/nagiosgraph/etc
|
2021-08-08 00:28:18 -05:00
|
|
|
tags: [ docker, nagios ]
|
2021-08-08 12:15:10 -05:00
|
|
|
- name: restart nagios
|
|
|
|
docker_container: name=nagios state=started restart=yes
|
|
|
|
when: config and config is changed
|
|
|
|
tags: [ docker, nagios ]
|