Thursday, June 7, 2012

Nagios server and client on CentOS 6

Install Centos 6 and configure as needed

Nagios Server install

  • Install epel
Get the epel release rpm installed it can be found here.
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

  • Disable selinux
Edit /etc/sysconfig/selinux. Change enforcing to disabled. The reboot


  • Install Nagios packages
Install nagios, nagios-plugins-all, nagios-plugins-nrpe, php-pear, mod_ssl, net-snmp-utils, sendmail

yum install nagios nagios-plugins-all nagios-plugins-nrpe php-pear mod_ssl net-snmp-utils sendmail


  • Create nagios user and password or web interface
htpasswd /etc/nagios/passwd nagiosadmin


  • Iptables
Allow port 443 in iptables


  • Add apache to nagios group
usermod -a -G nagios apache


  • configure services
chkconfig nagios on
chkconfig httpd on
chkconfig sendmail on
service sendmail restart


  • Edit httpd.conf and enable SSL in nagios.conf
Make changes to /etc/httpd/conf/httpd.conf if needed.
uncomment SSLRequireSSL in /etc/httpd/conf.d/nagios.conf
restart httpd


  • Configure for nrpe
Uncomment cfg_dir=/etc/nagios/servers in /etc/nagios/nagios.cfg
Add check nrpe command.
Add the following to /etc/nagios/objects/commands.cfg.

define command{
command_name check_nrpe
command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

make the servers directory
mkdir /etc/nagios/servers
chown root:nagios /etc/nagios/servers
service nagios restart

(a reboot might be necessary)
The Nagios server should working and accessible from the web interface.


On a separate machine install Centos 6 with minimal packages. Configure the system as needed.

Client nrpe install

  • Install epel
Get the epel release rpm installed it can be found here.
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

  • Disable selinux
Edit /etc/sysconfig/selinux. Change enforcing to disabled. The reboot



  • Install Nagios nrpe packages
Install nagios-plugins-nrpe, nagios-plugins-al,l nagios-nrpe, openssl
yum install nagios-plugins-nrpe nagios-plugins-all nagios-nrpe openssl


  • Add allowed hosts
Edit allowed hosts in /etc/nagios/nrpe.cfg add the IP of the nrpe and the nagios server
allowed_hosts=127.0.0.1,x.x.x.x
Also change the server_address to the nrpe client IP
chown nrpe:nrpe /etc/nagios/nrpe.cfg


  • nrpe services
Add nrpe 5666/tcp to /etc/services
chkconfig nrpe on
service nrpe restart
Allow port 5666 in iptables
Check connections from both nrpe and nagios server
/usr/lib64/nagios/plugins/check_nrpe -H (IP of nrpe)


  • Add the nrpe client to the nagios server
Create a server config file in /etc/nagios/servers on the nagios server and insert the following

define host{
        use linux-server
        host_name (nrpe client name)
        alias CentOS 6
        address (nrpe client)
}


service nagios restart
There should now be two hosts on in the web interface.

No comments:

Post a Comment