Skip to content

Instantly share code, notes, and snippets.

@lokesh-webonise
Last active July 3, 2017 20:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lokesh-webonise/5848201 to your computer and use it in GitHub Desktop.
Save lokesh-webonise/5848201 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://kaz.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

wget http://pkgs.fedoraproject.org/repo/pkgs/nrpe/nrpe-2.14.tar.gz/105857720e21674083a6d6be99e102c7/nrpe-2.14.tar.gz

#####2. Create nagios account

useradd nagios
passwd nagios

#####3. Install nagios-plugin

#cd /home/downloads
#tar xvfz nagios-plugins-1.4.11.tar.gz
#cd nagios-plugins-1.4.11
#./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 #tar xvfz nrpe-2.14.tar.gz #cd nrpe-2.12 #./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/nagios3 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment