Nagios Logo

Install Nagios 4.0.4 on CentOS 6.5

Assumptions: This build document assumes you are on a local domain with a local DNS server. You need to identify the DNS server an add this server as a host if you’d like to browse to it in your address bar. For instance, we just go to http://nagios..com instead of the ip address.

Virtual Machine Resources
4Core, 8GB
100GB HDD
Local dns nagios.<yourdomain>.com
Minimal Install CentOS 6.5
Hostname: nagios
Local Domain: <yourdomain>.com
IP Address: <nagiosip>
Local DNS IP: <localdnsip>

Install nano
yum install nano

Add Hosts Entries
nano /etc/hosts

By default, this is what’s present:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

Add the following:
<nagiosip> nagios.yourdomain.com nagios
<localdnsip> nagios.yourdomain.com

Add Nameserver
nano /etc/resolv.conf

Change default “nameserver ” to “nameserver <localdnsip>”
Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

Disable other services and firewall
service iptables stop
chkconfig iptables off

Disable SELINUX
change selinux=enforcing to selinux=disabled
nano /etc/selinux/config
Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

Install Prerequisites
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

Download Nagios Core and Nagios Plugins Tarballs
For all systems, run the following commands in your terminal:
cd /tmp
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.4.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz

Adding the Nagios User and Group
Next add the appropriate user and group for the Nagios process to run:
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios

Install Nagios Core
tar zxvf nagios-4.0.4.tar.gz
tar zxvf nagios-plugins-2.0.tar.gz
Change to the new Nagios directory and install the packages:
cd nagios-4.0.4
./configure –with-command-group=nagcmd

make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start/etc/init.d/httpd start
Create a Default User for Web Access. (may have to do this last)
Add a default user for Web Interface Access:
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Monitoring Infrastructure Switch
htpasswd /usr/local/nagios/etc/htpasswd.users

For perl modules, need to install perl
yum install perl-LDAP

Dependencies
less /var/log/messages | grep perl
Aug 19 15:25:39 nagios yum[2062]: Installed: perl-DBI-1.609-4.el6.x86_64
Aug 19 15:25:39 nagios yum[2062]: Installed: perl-DBD-MySQL-4.013-3.el6.x86_64
Aug 19 15:25:39 nagios yum[2062]: Installed: mysql-5.1.73-3.el6_5.x86_64
Aug 19 15:25:41 nagios yum[2062]: Installed: mysql-server-5.1.73-3.el6_5.x86_64
Aug 19 15:46:41 nagios yum[21836]: Installed: perl-XML-NamespaceSupport-1.10-3.el6.noarch
Aug 19 15:46:42 nagios yum[21836]: Installed: perl-XML-SAX-0.96-7.el6.noarch
Aug 19 15:46:42 nagios yum[21836]: Installed: 1:perl-XML-LibXML-1.70-5.el6.x86_64
Aug 19 15:46:42 nagios yum[21836]: Installed: perl-XML-Filter-BufferText-1.01-8.el6.noarch
Aug 19 15:46:42 nagios yum[21836]: Installed: perl-Digest-SHA1-2.12-2.el6.x86_64
Aug 19 15:46:42 nagios yum[21836]: Installed: perl-Digest-HMAC-1.01-22.el6.noarch
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-Convert-ASN1-0.22-1.el6.noarch
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-Net-SSLeay-1.35-9.el6.x86_64
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-GSSAPI-0.26-6.el6.x86_64
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-Authen-SASL-2.13-2.el6.noarch
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-Net-LibIDN-0.12-3.el6.x86_64
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-IO-Socket-SSL-1.31-2.el6.noarch
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-Text-Iconv-1.7-6.el6.x86_64
Aug 19 15:46:43 nagios yum[21836]: Installed: perl-XML-SAX-Writer-0.50-8.el6.noarch
Aug 19 15:46:43 nagios yum[21836]: Installed: 1:perl-LDAP-0.40-1.el6.noarch

Nagios Config File (tells nagios what config files to look at)
cd /usr/local/nagios/etc/nagios.cfg

Configuration files
cd /usr/local/nagios/etc/objects

If making changes to configuration files, restart service when finished
service nagios restart

We monitor multiple locations. Each location has its own config file in objects. Each location config file specifies its own host group, hosts, and services.

Posted in Linux Applications, Linux SysAdmin and tagged , , , .