NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). Deploying NRPE is easy through your favourite package manager (
apt-get install nagios-nrpe-server or
yum install nrpe), configuring your Nagios server’s IP, adding your checks on NRPE’s end and letting Nagios know its there.
But if you’re deploying this often (Or not), why not automate it? I created an Ansible role which installs and configures NRPE from scratch on both Debian and CentOS based servers. All you need to do now is configure it in Nagios and you’re rolling.
It uses Ansible for deployment and configuration (If you aren’t familiar with Ansible, I highly recommend you watch their video introduction here). The first play installs NRPE and any dependences (NRPE doesn’t come with any plugins on RedHat, wtf?), the second play then configures
nrpe.cfg from a Jinja2 template (Ansible’s standard template language of choice). The third play installs
nrpe_ansible.cfg where you can place all your custom checks (Again from a Jinja2 template) and finally the final play ensures its running and configured to start at boot.
As you can see above, its mostly through Jinja2 templates and OS variables. I’ve tested it on CentOS 6, Debian 7 and Ubuntu 14.x. On all systems it worked without a hitch.
The role allows a few configuration options (see below) although most are either OS Specific and are likely not going to be changed.
And some OS Specific Variables
You can of course override the OS Specific variables I set above through either a hostgroup var or on a per host variable, if your plugins live in a different directory other then
/usr/lib/nagios/plugins for example.
Thats my role, its lightweight and gets the job done. If you’ve got any questions or feel its missing a feature, feel free to ask it below or open an issue on GitHub. Like the role? Don't forget to rate it on Ansible Galaxy!