Guides‎ > ‎Installing Nagios‎ > ‎3.5.x‎ > ‎

CentOS 6.5

Install CentOS

These steps were performed using CentOS-6.5-x86_64-bin-DVD1.iso

  • Boot the CentOS installer ISO
  • Select Install or upgrade an existing system
  • You can skip the media test
  • The GUI installer appears
  • Click Next
  • Select your language and click Next
  • Select your keyboard and click Next
  • Storage - For the purposes of this guide I am:
    • Selecting Basic Storage Device and click Next
    • Storage Device Warning
      • Tick the box Apply my choice to all devices with undetected partitions or filesystems
      • Click Yes, discard any data
  • Hostname
    • I am using the hostname core40x.box293.local
    • Click Configure Network
      • Select System eth0
      • Click Edit
      • Tick the box Connect automatically
      • IPv4 Setting tab
        • A static IP Address is preferred for a Nagios core host
        • Provide the static IP Address parameters
      • Click Apply
    • Click Close
  • Click Next
  • Select your Timezone
  • Click Next
  • Provide a root password for this host
  • Click Next
  • Which type of install would you like - For the purposes of this guide I am:
    • Replace Existing Linux System(s)
    • Click Next
    • Click Write changes to disk
  • Select Minimal and click Next
  • Wait while the installation is performed
  • When the installation is complete click Reboot


Confirm Network Configuration

After the system has booted:

  • Login to the console as root
  • Type ifconfig and press Enter
  • Your IP settings will be shown
  • If they do not appear it's likely eth0 was not put in an up state. Do the following to correct:
    • Type ifup eth0 and press Enter
    • Wait while eth0 is brought up
    • Type ifconfig and press Enter
    • Confirm the network settings are correct
    • You should also make sure that the interface is set to be in an up state on bootup
    • Type sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-eth0 and press Enter
    • We'll reboot the server to ensure the interface comes up on boot
    • Type reboot and press Enter
    • After the host has booted up confirm the interface is up as per the steps above


SSH To Host

All steps from now on can be done via an ssh session to the host, the added benefit is that commands here can be copied and pasted into the ssh session (saves typing mistakes). Login as root.


Install Prerequisites And Other Items

The following commands will install all the prerequisites for Nagios core along with some other tools that you may use later.

  • Type yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp nano system-config-network-tui and press Enter
  • Wait while all of these components are installed


Install Net-SNMP

The following is optional, only required if you want the SNMP plugins installed.


Disable SELinux

Security-Enhanced Linux (SELinux) will cause a few headaches so it's simpler to disable it now.

  • Type sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config and press Enter
  • Type setenforce 0 and press Enter


Configure Timezone

The following commands will install ntp, configure the timezone in CentOS and in PHP.

  • For the purposes of this guide I will be using America/Chicago as the timezone source
  • Type rm -f /etc/localtime and press Enter
  • Type ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime and press Enter
  • Type yum install -y ntp and press Enter
  • Wait while ntp is installed
  • Type ntpdate pool.ntp.org and press Enter
  • You'll get a message like:
    • 16 Sep 20:54:54 ntpdate[1376]: step time server 198.110.48.12 offset 17975.735304 sec
  • Type service ntpd start and press Enter
  • You can now confirm the data and time are correct
  • Type date and press Enter
  • You'll get a message like:
    • Tue Sep 16 20:56:54 CDT 2014
  • We'll also configure PHP
  • Type nano /etc/php.ini and press Enter
    • This opens the nano editor
    • Press CTRL + W
    • Type ;date.timezone and press Enter
    • This will take you the location in the ini file for the timezone setting
    • Remove the semicolon (;) and set the relevant value, for example:
    • date.timezone = America/Chicago
    • A list can be seen on the php website: http://php.net/manual/en/timezones.php
    • Press CTRL + X
    • Type Y to save the changes
    • Press Enter to accept the php.ini file


Download Nagios Core

  • Type cd /tmp and press Enter
  • Type wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.1.tar.gz and press Enter
  • Wait while the file is downloaded
  • Type wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz and press Enter
  • Wait while the file is downloaded


Install Nagios Core

The following steps will install Nagios Core 3.5.1 and Nagios Plugins 2.0.3.

  • Type useradd nagios and press Enter
  • Type groupadd nagcmd and press Enter
  • Type usermod -a -G nagcmd nagios and press Enter
  • Type usermod -a -G nagcmd apache and press Enter
  • Type usermod -a -G nagios apache and press Enter
  • Type tar zxf nagios-3.5.1.tar.gz and press Enter
  • Type tar zxf nagios-plugins-2.0.3.tar.gz and press Enter
  • Type cd nagios and press Enter
  • Type ./configure --with-command-group=nagcmd and press Enter
  • Wait for the configure command to complete
  • Type make all and press Enter
  • Wait for the make all command to complete
  • Type make install and press Enter
  • Wait for the make install command to complete
  • Type make install-init and press Enter
  • Wait for the make install-init command to complete
  • Type make install-config and press Enter
  • Wait for the make install-config command to complete
  • Type make install-commandmode and press Enter
  • Wait for the make install-commandmode command to complete
  • Type make install-webconf and press Enter
  • Wait for the make install-webconf command to complete
  • Type cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ and press Enter
  • Type chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers and press Enter
  • Type /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg and press Enter
  • The last command ran the nagios pre-flight check
  • Type /etc/init.d/nagios start and press Enter
  • The last command started nagios
  • Type htpasswd -c -b /usr/local/nagios/etc/htpasswd.users nagiosadmin nagiosadminpassword and press Enter
  • The last command added the user nagiosadmin with the password nagiosadminpassword
  • Type cd /tmp/nagios-plugins-2.0.3 and press Enter
  • Type ./configure --with-nagios-user=nagios --with-nagios-group=nagios and press Enter
  • Wait for the configure command to complete
  • Type make and press Enter
  • Wait for the make command to complete
  • Type make install and press Enter
  • Wait for the make install command to complete
  • Type chkconfig --add nagios and press Enter
  • Type chkconfig --level 35 nagios on and press Enter
  • Type chkconfig --add httpd and press Enter
  • Type chkconfig --level 35 httpd on and press Enter
  • Type iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT and press Enter
  • Type service iptables save and press Enter
  • Type service httpd start and press Enter

This completes the Nagios Core and Nagios Plugins installation.


Login To Nagios Core Web Interface

  • Open a web browser to http://core40x.box293.local/nagios
  • You will be prompted for credentials, I will use the ones I defined earlier:
    • Username: nagiosadmin
    • Password:  nagiosadminpassword
  • You are now on the main web interface of Nagios Core