Skip to content

Instantly share code, notes, and snippets.

@nu11secur1ty
Last active March 29, 2016 15:47
Show Gist options
  • Save nu11secur1ty/65debf5da2353261ff14 to your computer and use it in GitHub Desktop.
Save nu11secur1ty/65debf5da2353261ff14 to your computer and use it in GitHub Desktop.
Add remote host to nagios server

##Add remote host to Nagios server

###On Remote Host ####Pre-requisite #####Below listed package should be installed i.gcc ii. xinetd iii.openssl

#####Step 1 #####1. Download Nagios Plugins and NRPE Add-on wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz >>in /Download

wget https://github.com/NagiosEnterprises/nrpe/archive/master.zip  >>in /Download 

#####2. Create nagios account

useradd nagios
passwd nagios

#####3. Install nagios-plugin

#cd /home/downloads
#tar xvfz nagios-plugins-2.1.1.tar.gz
#cd nagios-plugins-2.1.1
#./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
#make
#make install

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec/

#####4. Install NRPE #cd /home/downloads #unzip master.zip #cd nrpe-master #./configure #make all #make install-plugin #make install-daemon #make install-daemon-config #make install-xinetd

#####5. Setup NRPE to run as daemon (i.e as part of xinetd)

  • Modify the /etc/xinetd.d/nrpe to add the ip-address of the Nagios monitoring server to the only_from directive. Note that there is a space after the 127.0.0.1 and the nagios monitoring server ip-address (in this example, nagios monitoring server ip-address is: ...)

      only_from       = 127.0.0.1 192.168.1.2
    
  • Modify the /etc/services and add the following at the end of the file.

       nrpe 5666/tcp # NRPE
    
  • Start the service

  •   service xinetd restart
    
  • Verify whether NRPE is listening

      netstat -at | grep nrpe
      tcp 0      0 *:nrpe *:*                         LISTEN
    
  • Verify to make sure the NRPE is functioning properly

      /usr/local/nagios/libexec/check_nrpe -H localhost
      NRPE v2.12
    

###On Nagios server

####1. Add remote host to nagios server

vim /etc/nagios3/conf.d/hosts.cfg
.
.
.
define host{
    use                     linux-server
    host_name               rails_prod
    alias                   Rails Production
    address                 174.143.24.9
}
:wq!

#####2. Add remote host to hostgroup

vim /etc/nagios3/conf.d/hostgroups_nagios2.cfg
.
.
.
define hostgroup {
    hostgroup_name          http-servers
            alias           Debian GNU/Linux Servers
            members         localhost
    }

#####3. Restart the server

/etc/init.d/nagios.x.x restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment