Deploying Nagios NRPE via Ansible

Discuss new project and feature ideas here.
See labs.nagios.com for new projects under development.

Deploying Nagios NRPE via Ansible

Postby florius » Fri Jun 15, 2018 9:46 am

Hi,

I was wondering, I currently have about 10 VM's, and I want to deploy Nagios NRPE via Ansible.
But what is the best way to have this configured on my Nagios Server?

I currently have 2 hosts as I'm setting it up:
Code: Select all
.
.
|-- cgi.cfg
|-- htpasswd.users
|-- nagios.cfg
|-- nrpe.cfg
|-- objects
|   |-- commands.cfg
|   |-- contacts.cfg
|   |-- printer.cfg
|   |-- switch.cfg
|   |-- templates.cfg
|   |-- timeperiods.cfg
|   `-- windows.cfg
|-- resource.cfg
`-- servers
    |-- monitoring-01.hostname.cfg
    `-- tempdebian.hostname.cfg


In
Code: Select all
tempdebian.hostname.cfg
I then have every service defined like:
Code: Select all
define host{
        use                     linux-server
        host_name               tempdebian.hostname.com
        alias                   tempdebian.hostname.com
   max_check_attempts   4
        address                 1.1.1.1
        }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             PING
        check_command                check_ping!100.0,20%!500.0,60%
        }

define service{
        use                             local-service,ssh
        host_name                  tempdebian.hostname.com
        }

define service{
        use            local-service
   host_name      tempdebian.hostname.com
   service_description   Current Load
   check_command   check_nrpe!check_load
   }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Current users
        check_command                   check_nrpe!check_users
   }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Total Zombie Processes
        check_command                   check_nrpe!check_zombie_procs
        }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Total Processes
        check_command                   check_nrpe!check_total_procs
        }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Root Partition
        check_command                   check_nrpe!check_disk
        }

define service{
   use            local-service
   host_name         tempdebian.hostname.com
   service_description      Apt Packages Check
   check_command         check_nrpe!check_apt
   }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Swap Usage
        check_command                   check_nrpe!check_swap
        }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Total logged in users
        check_command                   check_nrpe!check_users
        }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Check SSH Daemon
        check_command                   check_nrpe!check_ssh_daemon
        }

define service{
        use                             local-service
        host_name                       tempdebian.hostname.com
        service_description             Check Munin-node Daemon
        check_command                   check_nrpe!check_munin_node_daemon
        }


Would this be the most efficient way to deploy Nagios?
This is just a simple host, but I will be monitoring MySQL, HTTPD etc. as well.

Any help, examples and advice is much appreciated!
florius
 
Posts: 2
Joined: Fri Jun 15, 2018 9:38 am

Re: Deploying Nagios NRPE via Ansible

Postby npolovenko » Fri Jun 15, 2018 1:56 pm

@florius, If it's just 10 servers may not be worth writing a playbook, but still very doable I believe.

Take a look at this documentation on how to install the nrpe agent.
https://assets.nagios.com/downloads/nagiosxi/docs/Installing_The_XI_Linux_Agent.pdf

Basically, you'd have ansible ssh into a linux server and run:
Code: Select all
cd /tmp
wget https://assets.nagios.com/downloads/nagiosxi/agents/linux-nrpe-agent.tar.gz
tar xzf linux-nrpe-agent.tar.gz
cd linux-nrpe-agent
./fullinstall


This will install the nrpe.
Then you need to add the nagiosXI server ip under allowed hosts in /etc/xinetd.d/nrpe
Code: Select all
only_from = 127.0.0.1 192.168.4.172

Replace 192.168.4.172 with the actaul XI ip address.


Then you need to open the /usr/local/nagios/etc/nrpe.cfg file and add service check definitions.

In the end, please restart the xinetd service with:
Code: Select all
service xinetd restart


So this is how you deploy nrpe agents.

On the nagios server, you can create one set of nrpe checks and clone then for all existing hosts.

Let me know if this helps and whether you have other questions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
npolovenko
Support Tech
 
Posts: 2018
Joined: Mon May 15, 2017 5:00 pm

Re: Deploying Nagios NRPE via Ansible

Postby florius » Sat Jun 16, 2018 12:29 pm

@@npolovenko, the playbook itself I already have. My question was actually, what would be the most efficient way to 'build' the Nagios server itself? Is what I currently have the most efficient way?
florius
 
Posts: 2
Joined: Fri Jun 15, 2018 9:38 am

Re: Deploying Nagios NRPE via Ansible

Postby npolovenko » Tue Jun 19, 2018 2:15 pm

@florius, Sorry. Are you asking whether these configs look good if you deploy them to nagios servers? Are you trying to build Nagios Core/Nagios XI servers with Ansible and asking whether the list of configs looks ok?

As far as the NPRE service definitions. They look ok but you're adding these checks for 1 host -> tempdebian.hostname.com with the IP address 1.1.1.1. Why would you want to deploy the same checks for the same host to all Nagios servers? Or are you asking if the format of configs looks ok? If so, the answer is yes. As long as you include file paths in nagios.cfg file.

So, Please let me know if I got your question right. And also, whether you want to deploy these configs to Nagios Core or a Nagios XI servers? Also, what is the final goal, is it having all those new servers monitor some other server via nrpe?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
npolovenko
Support Tech
 
Posts: 2018
Joined: Mon May 15, 2017 5:00 pm


Return to Nagios Ideas

Who is online

Users browsing this forum: No registered users and 1 guest