{"id":13752983,"url":"https://github.com/sadsfae/ansible-nagios","last_synced_at":"2026-01-24T10:29:04.670Z","repository":{"id":9526712,"uuid":"61825751","full_name":"sadsfae/ansible-nagios","owner":"sadsfae","description":":white_check_mark: Ansible playbook for setting up the Nagios monitoring system and clients.","archived":false,"fork":false,"pushed_at":"2025-10-20T12:44:34.000Z","size":846,"stargazers_count":104,"open_issues_count":2,"forks_count":107,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-10-20T14:12:32.210Z","etag":null,"topics":["ansible","centos","idrac","monitoring","nagios","playbook","rhel"],"latest_commit_sha":null,"homepage":"https://hobo.house/2016/06/24/automate-nagios-deployment-with-ansible/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sadsfae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-23T17:57:56.000Z","updated_at":"2025-10-20T12:44:39.000Z","dependencies_parsed_at":"2024-07-29T09:45:38.324Z","dependency_job_id":null,"html_url":"https://github.com/sadsfae/ansible-nagios","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sadsfae/ansible-nagios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadsfae%2Fansible-nagios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadsfae%2Fansible-nagios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadsfae%2Fansible-nagios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadsfae%2Fansible-nagios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sadsfae","download_url":"https://codeload.github.com/sadsfae/ansible-nagios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadsfae%2Fansible-nagios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28725083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","centos","idrac","monitoring","nagios","playbook","rhel"],"created_at":"2024-08-03T09:01:13.998Z","updated_at":"2026-01-24T10:29:04.665Z","avatar_url":"https://github.com/sadsfae.png","language":"Shell","funding_links":[],"categories":["rhel"],"sub_categories":[],"readme":"ansible-nagios\n==============\nPlaybook for setting up the Nagios monitoring server and clients (CentOS/Rocky/RHEL/Fedora/FreeBSD)\n\n![Nagios](/image/ansible-nagios.png?raw=true)\n\n[![GA](https://github.com/sadsfae/ansible-nagios/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/sadsfae/ansible-nagios/actions)\n\n## What does it do?\n   - Automated deployment of Nagios Server on CentOS7, Rocky 8/9 or RHEL 7/8/9\n   - Automated deployment of Nagios client on CentOS6/7/8, RHEL6/7/8/9 or Rocky, Fedora and FreeBSD\n     * Generates service checks and monitored hosts from Ansible inventory\n     * Generates comprehensive checks for the Nagios server itself\n     * Generates comprehensive checks for all hosts/services via NRPE\n     * Generates most of the other configs based on jinja2 templates\n     * Wraps Nagios in SSL via Apache\n     * Sets up proper firewall rules (firewalld or iptables-services)\n     * Support sending alerts via email and outgoing webhooks.\n     * This is also available via [Ansible Galaxy](https://galaxy.ansible.com/sadsfae/ansible-nagios/)\n\n## How do I use it?\n   - Add your nagios server under `[nagios]` in `hosts` inventory\n   - Add respective services/hosts under their inventory group, **hosts can only belong under one group.**\n   - Take a look at `install/group_vars/all.yml` to change anything like email address, nagios user, guest user etc.\n   - Run the playbook.  Read below for more details if needed.\n\n## Requirements\n   - CentOS7 or RHEL7/8/9 or Rocky 8/9 for Nagios server only (for now).\n   - RHEL6/7/8/9, CentOS6/7/8/9, Fedora or FreeBSD for the NRPE Nagios client\n   - If you require SuperMicro server monitoring via IPMI (optional) then do the following\n     - Install```perl-IPC-Run``` and ```perl-IO-Tty``` RPMs for RHEL7 for optional IPMI sensor monitoring on SuperMicro.\n       - I've placed them [here](https://funcamp.net/w/rpm/el7/) if you can't find them, CentOS7 has them however.\n     - Modify ```install/group_vars/all.yml``` to include ```supermicro_enable_checks: true```\n   - Please note I'll likely remove IPMI sensor monitoring support because it's a real pain and not that reliable, SNMP with MiB is better.\n\n## Notes\n   - Sets the ```nagiosadmin``` password to ```changeme```, you'll want to change this.\n   - Creates a read-only user, set ```nagios_create_guest_user: false``` to disable this in ```install/group_vars/all.yml```\n   - You can turn off creation/management of firewall rules via ```install/group_vars/all.yml```\n   - Adding new hosts to inventory file will just regenerate the Nagios configs\n\n## Supported Service Checks\n   - Implementation is very simple, with the following resource/service checks generated:\n     - Generic out-of-band interfaces *(ping, ssh, http)*\n     - Generic Linux servers *(ping, ssh, load, users, procs, uptime, disk space, swap, zombie procs)*\n     - Generic Linux servers with MDADM RAID (same as above)\n     - [ELK servers](https://github.com/sadsfae/ansible-elk) *(same as servers plus elasticsearch and Kibana)*\n     - Elasticsearch *(same as servers plus TCP/9200 for elasticsearch)*\n     - Webservers *(same as servers plus 80/TCP for webserver)*\n     - Webservers with SSL certificate checking *(same as webservers plus checks SSL certificate validity/expiration)*\n     - DNS Servers *(same as servers plus UDP/53 for DNS)*\n     - DNS Servers with MDADM RAID (same as above)\n     - DNS Service Only (DNS and ICMP check)\n     - Jenkins CI *(same as servers plus TCP/8080 for Jenkins and optional nginx reverse proxy with auth)*\n     - FreeNAS Appliances *(ping, ssh, volume status, alerts, disk health)*\n     - Network switches *(ping, ssh)*\n     - IoT and ping-only devices *(ping)*\n     - Dell iDRAC server checks via @dangmocrang [check_idrac](https://github.com/dangmocrang/check_idrac)\n       - You can select which checks you want in ```install/group_vars/all.yml```\n         - CPU, DISK, VDISK, PS, POWER, TEMP, MEM, FAN\n     - SuperMicro server checks via the IPMI interface.\n       - CPU, DISK, PS, TEMP, MEM: or anything supported via ```freeipmi``` sensors.\n       - *Note: This is **not** the best way to monitor things, SNMP checks are WIP once we purchase licenses for them for our systems\n     - [QUADS](https://quads.dev/about-quads) Servers *(same as server plus alerting on active assignments that are not validated after a time threshold)*\n   - ```contacts.cfg``` notification settings are in ```install/group_vars/all.yml``` and templated for easy modification.\n\n## Nagios Server Instructions\n   - Clone repo and setup your Ansible inventory (hosts) file\n```\ngit clone https://github.com/sadsfae/ansible-nagios\ncd ansible-nagios\nsed -i 's/host-01/yournagioshost/' hosts\n```\n   - Add any hosts for checks in the ```hosts``` inventory\n   - The same host can only belong to **one** host inventory category\n   - Note that you need to add ```ansible_host``` entries __only__ for IP addresses for idrac, switches, out-of-band interfaces and anything that typically doesn't support Python and Ansible fact discovery.\n   - Anything __not__ an ```idrac```, ```switch``` or ```oobserver``` should use the FQDN (or an /etc/hosts entry) for the inventory hostname or you may see this error:\n     - ```AnsibleUndefinedVariable: 'dict object' has no attribute 'ansible_default_ipv4'}```\n\n```\n[webservers]\nwebserver01\n\n[switches]\nswitch01 ansible_host=192.168.0.100\nswitch02 ansible_host=192.168.0.102\n\n[oobservers]\nwebserver01-ilo ansible_host=192.168.0.105\n\n[servers]\nserver01\n\n[servers_with_mdadm_raid]\n\n[jenkins]\njenkins01\n\n[dns]\n\n[dns_with_mdadm_raid]\n\n[idrac]\ndatabase01-idrac ansible_host=192.168.0.106\n\n[supermicro-6048r]\nweb01-supermicro-ipmi ansible_host=192.168.0.108\n\n[supermicro-6018r]\n\n[supermicro-1028r]\n\n```\n   - Run the playbook\n```\nansible-playbook -i hosts install/nagios.yml\n```\n   - Navigate to the server at https://yourhost/nagios\n   - Default login is ```nagiosadmin / changeme``` unless you changed it in ```install/group_vars/all.yml```\n\n## Known Issues\n\n* If you're using a non-root Ansible user you will want to edit ```install/group_vars/all.yml``` setting, e.g. AWS EC2:\n\n```\nansible_system_user: ec2-user\n```\n\n* SELinux doesn't always play well with Nagios, or the policies may be out of date as shipped with CentOS/RHEL.\n```\navc: denied { create } for pid=8800 comm=\"nagios\" name=\"nagios.qh\n```\n   - If you see this (or nagios doesn't start) you'll need to create an SELinux policy module.\n```\n# cat /var/log/audit/audit.log | audit2allow -M mynagios\n# semodule -i mynagios.pp\n```\nNow restart Nagios and Apache and you should be good to go.\n```\nsystemctl restart nagios\nsystemctl restart httpd\n```\nIf all else fails set SELinux to permissive until it's running then run the above command again.\n```\nsetenforce 1\n```\n\n* If you have errors on RHEL7 you may need a few [Perl packages](https://funcamp.net/w/rpm/el7/) if you opted to include SuperMicro monitoring via:\n\n```\nsupermicro_enable_checks: true\n```\n\n## Mass-generating Ansible Inventory\nIf you're using something like [QUADS](https://quads.dev/about-quads) to manage your infrastructure automation scheduling you can do the following to generate all of your out-of-band or iDRAC interfaces.\n\n```\nquads-cli --ls-hosts | sed -e 's/^/mgmt-/g' \u003e /tmp/all_ipmi_2019-10-23\nfor ipmi in $(cat all_ipmi_2019-10-23); do printf $ipmi ; echo \" ansible_host=$(host $ipmi | awk '{print $NF}')\"; done \u003e /tmp/add_oobserver\n```\n\nNow you can paste `/tmp/add_oobserver` under the `[oobservers]` or `[idrac]` Ansible inventory group respectively.\n\n\n## Demonstration\n   - You can view a video of the Ansible deployment here:\n\n[![Ansible Nagios](http://img.youtube.com/vi/6vfhflwC_Wg/0.jpg)](http://www.youtube.com/watch?v=6vfhflwC_Wg \"Deploying Nagios with Ansible\")\n\n## iDRAC Server Health Details\n   - The iDRAC health checks are all optional, you can pick which ones you want to monitor.\n\n![CHECK](/image/idrac-check.jpg?raw=true)\n\n   - The iDRAC health check will provide exhaustive health information and alert upon it.\n\n![iDRAC](/image/nagios-idrac.png?raw=true)\n\n## Files\n\n```\n.\n├── hosts\n├── install\n│   ├── group_vars\n│   │   └── all.yml\n│   ├── nagios.yml\n│   └── roles\n│       ├── firewall\n│       │   └── tasks\n│       │       └── main.yml\n│       ├── firewall_client\n│       │   └── tasks\n│       │       └── main.yml\n│       ├── instructions\n│       │   └── tasks\n│       │       └── main.yml\n│       ├── nagios\n│       │   ├── files\n│       │   │   ├── check_ipmi_sensor\n│       │   │   ├── idrac_2.2rc4\n│       │   │   ├── idrac-smiv2.mib\n│       │   │   ├── nagios.cfg\n│       │   │   └── nagios.conf\n│       │   ├── handlers\n│       │   │   └── main.yml\n│       │   ├── tasks\n│       │   │   └── main.yml\n│       │   └── templates\n│       │       ├── cgi.cfg.j2\n│       │       ├── check_freenas.py.j2\n│       │       ├── commands.cfg.j2\n│       │       ├── contacts.cfg.j2\n│       │       ├── devices.cfg.j2\n│       │       ├── dns.cfg.j2\n│       │       ├── dns_with_mdadm_raid.cfg.j2\n│       │       ├── elasticsearch.cfg.j2\n│       │       ├── elkservers.cfg.j2\n│       │       ├── freenas.cfg.j2\n│       │       ├── idrac.cfg.j2\n│       │       ├── ipmi.cfg.j2\n│       │       ├── jenkins.cfg.j2\n│       │       ├── localhost.cfg.j2\n│       │       ├── oobservers.cfg.j2\n│       │       ├── servers.cfg.j2\n│       │       ├── servers_with_mdadm_raid.cfg.j2\n│       │       ├── services.cfg.j2\n│       │       ├── supermicro_1028r.cfg.j2\n│       │       ├── supermicro_6018r.cfg.j2\n│       │       ├── supermicro_6048r.cfg.j2\n│       │       ├── switches.cfg.j2\n│       │       └── webservers.cfg.j2\n│       └── nagios_client\n│           ├── files\n│           │   ├── bsd_check_uptime.sh\n│           │   └── check_raid\n│           ├── handlers\n│           │   └── main.yml\n│           ├── tasks\n│           │   └── main.yml\n│           └── templates\n│               └── nrpe.cfg.j2\n├── meta\n│   └── main.yml\n└── tests\n    └── test-requirements.txt\n\n21 directories, 43 files\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsadsfae%2Fansible-nagios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsadsfae%2Fansible-nagios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsadsfae%2Fansible-nagios/lists"}