Share, , Google Plus, Pinterest,

Print

Posted in:

Install Nagios on CentOS 7

So CentOS 7 is out and there are quite some differences from it’s predecessor CentOS 6. This is why i decided to write a new how to installing Nagios Core 4.0.8 on the latest fully updated CentOS 7 minimal installation – Install Nagios on CentOS 7. The Firewalld and SELinux are both enabled and running in this how to so you should not have any problems with it. If you are not familiar with using Systemd and Firewalld there are couple of commands to get you in the right direction and maybe slowly get used to it – i sure need/want to too.

Install Nagios on CentOS 7
Install Nagios on CentOS 7

Let’s Install Nagios on CentOS 7!

1. Install “deltarpm” package

The first step to install nagios on CentOS7 is to install “deltarpm”. This package creates deltas between RPMs. It is required in future RPM installations.

[root@geekpeek ~]# yum install deltarpm -y

2. Install Required Dependencies

These are the packages we need to install to satisfy Nagios dependency resolution, when compiling it.

[root@geekpeek ~]# yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp -y

3. Download the Latest Version of Nagios Core

The latest version of Nagios Core is available for free download at THIS link.

[root@geekpeek ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz

4. Create “nagios” User and add “apache” User to Nagios Group

Before compiling Nagios Core we need to create “nagios” user and group. When “nagios” user and group is created, add “apache” user to this group – this needs to be done due to some file permissions which enable us to do actions via Nagios web interface.

[root@geekpeek ~]# useradd nagios
[root@geekpeek ~]# usermod -G nagios apache

5. Extract Nagios Tarball

[root@geekpeek ~]# tar -xvzf nagios-4.0.8.tar.gz

6. Run Configure and Make Nagios

To install Nagios on CentOS 7 we need to configure and make Nagios.

[root@geekpeek ~]# cd nagios-4.0.8
[root@geekpeek nagios-4.0.8]# ./configure
...
...
Creating sample config files in sample-config/ ...


*** Configuration summary for nagios 4.0.8 08-12-2014 ***:

 General Options:
 -------------------------
 Nagios executable: nagios
 Nagios user/group: nagios,nagios
 Command user/group: nagios,nagios
 Event Broker: yes
 Install ${prefix}: /usr/local/nagios
 Install ${includedir}: /usr/local/nagios/include/nagios
 Lock file: ${prefix}/var/nagios.lock
 Check result directory: ${prefix}/var/spool/checkresults
 Init directory: /etc/rc.d/init.d
 Apache conf.d directory: /etc/httpd/conf.d
 Mail program: /bin/mail
 Host OS: linux-gnu
 IOBroker Method: epoll

 Web Interface Options:
 ------------------------
 HTML URL: http://localhost/nagios/
 CGI URL: http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP): 


Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.

[root@geekpeek nagios-4.0.8]# make all
[root@geekpeek nagios-4.0.8]# make install
[root@geekpeek nagios-4.0.8]# make install-init
[root@geekpeek nagios-4.0.8]# make install-commandmode
[root@geekpeek nagios-4.0.8]# make install-config
[root@geekpeek nagios-4.0.8]# make install-webconf
[root@geekpeek nagios-4.0.8]# make install-exfoliation

7. Run Nagios Configuration Check

You can do this anytime after changing the Nagios configuration to make sure service restart will be OK.

[root@geekpeek nagios-4.0.8]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.0.8
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2014
License: GPL

Website: http://www.nagios.org
Reading configuration data...
 Read main config file okay...
 Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
 Checked 8 services.
 Checked 1 hosts.
 Checked 1 host groups.
 Checked 0 service groups.
 Checked 1 contacts.
 Checked 1 contact groups.
 Checked 24 commands.
 Checked 5 time periods.
 Checked 0 host escalations.
 Checked 0 service escalations.
Checking for circular paths...
 Checked 1 hosts
 Checked 0 service dependencies
 Checked 0 host dependencies
 Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

8. Create Nagios Web Interface User

Beware, we are creating htpasswd.users file with this name on exact location since this location is default in Nagios configuration file – if you change the file name or location you must edit Nagios configiuration also!

[root@geekpeek nagios-4.0.8]# htpasswd -c -B /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: 
Re-type new password: 
Adding password for user admin

9. Install EPEL Repository and “nagios-plugins-all”

We need to install EPEL Repository for CentOS 7 to be able to download “nagios-plugins-all” package. These are all Nagios plugins you might ever need to monitor your Nagios clients. After installing “nagios-plugins-all” we must play around with some links, so Nagios can find the and use plugins – just follow the guide.

[root@geekpeek nagios-4.0.8]# rpm -ivh https://ftp.fau.de/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
[root@geekpeek nagios-4.0.8]# yum install nagios-plugins-all -y
[root@geekpeek nagios-4.0.8]# rm -rf /usr/local/nagios/libexec
[root@geekpeek nagios-4.0.8]# ln -s /usr/lib64/nagios/plugins/ /usr/local/nagios/libexec
[root@geekpeek nagios-4.0.8]# chown -R nagios:nagios /usr/local/nagios/libexec/

10. Start Apache and Nagios Service

Note that Apache (httpd) service is native and is manipulated by “Systemd” (systemctl) but Nagios is not native and therefore still manipulated by “SysV” (chkconfig). We must start both services and make sure they start at boot.

[root@geekpeek nagios-4.0.8]# systemctl enable httpd
[root@geekpeek nagios-4.0.8]# systemctl start httpd
[root@geekpeek nagios-4.0.8]# chkconfig nagios on
[root@geekpeek nagios-4.0.8]# /etc/init.d/nagios start

11. Disable Blocking of Port 80

We need to add port 80 (TCP) to “firewalld” permanent exceptions so we can access Nagios web interface.

[root@geekpeek nagios-4.0.8]# firewall-cmd --add-port=80/tcp
 [root@geekpeek nagios-4.0.8]# firewall-cmd --permanent --add-port=80/tcp

12. Access Nagios Web Interface

This is the last step in install Nagios on CentOS 7 how to. We must confirm that Nagios Web Interface is reachable by accessing http://ip_addr_or_hostname/nagios. Nagios Web Interface should open up.

 

Install Nagios on CentOS 7
Install Nagios on CentOS 7

 

This is the end of my Install Nagios on CentOS 7 guide. I decided to write a new Nagios Configuration how to so stay tuned!