Install Nagios on Linux

Install Nagios on Linux

Install Nagios on CentOS

Nagios Core logo at the start of the Nagios install guide

Nagios has worked hard to secure it’s seat as one of the world’s best enterprise monitoring systems. Nagios alerts about critical business processes such as certificate expiration, as well as supports multiple platforms including Windows and Linux.

Let’s get started, login, and su to root

Nagios Core logo (same image repeated at the login and su to root step)

first let’s install some pre-requisites

yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp prerequisites

we also need to install the development tools:

Running yum -y groupinstall development tools on the Nagios server

modify your hosts file as appropriate

Opening /etc/hosts with vi on the Nagios server

obviously modify this part

/etc/hosts entry mapping the server IP to nagios.domain.local nagios

configure apache to start on startup, and start the service now

useradd nagios and passwd nagios output on the Nagios server

setup the nagios user account

Creating the nagios user with useradd and setting its password with passwd

configure group permissions

useradd nagios and passwd output shown again at the group permissions step

CONTINUE HERE FOR BETTER DIRECTIONS

** DO NOT USE THIS PROCEDURE, INSTALLING FROM SOURCE MAKES UPGRADES REALLY DIFFICULT, COMPILE THE SOURCE INTO AN RPM PACKAGE!!! **

Install Nagios:

It’s important to understand that Nagios must be installed from source, rather than with Yum, or a RPM/DEB package.

cd to the /opt directory (note that this is where ALL 3rd party software is supposed to be installed)

Changing to the /opt directory for third-party source builds

wget the latest stable source from the nagios website

http://www.nagios.org/download/core

wget downloading nagios-4.0.8.tar.gz from prdownloads.sourceforge.net

now we’re going to extract the source tar ball from it’s compressed zip state

nagios-4.0.8.tar.gz downloaded to /opt and extracted with tar -xvf

change to the nagios directory once extracted

Running ./configure --with-command-group=nagcmd in the nagios-4.0.8 directory

star the compiling process by configuring the make files

./configure --with-command-group=nagcmd starting the Nagios 4.0.8 build

you should see lots of this:

Nagios configure script output with checking for snprintf, setenv and socket lines

issue the make all command

Running make all in the nagios-4.0.8 source directory

now issue a make install

Running make install in the nagios-4.0.8 source directory

now do a make install-init to install a startup script

Running make install-init to install the Nagios init script

now a make install-config to install nagios config files

Running make install-config to install sample Nagios config files

now do a make install with command mode

Running make install-webconf in the nagios-4.0.8 source directory

now we need to tell nagios to use apache

make install-webconf installing the Apache config for the Nagios web interface

now we need to configure apache authentication

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin for web login

great, now our nagiosadmin account can login via apache authentication

htpasswd output: Adding password for user nagiosadmin

restart apache, as with any web change

service httpd restart stopping and starting Apache after the Nagios web config

now we need to install and configure nagios plugins (from source, wahoo!)

Extracting nagios-plugins-2.0.3.tar.gz with tar -xvf in /opt

extract the nagios plugins from the compressed tar file

tar -xvf nagios-plugins-2.0.3.tar.gz extracting the Nagios plugins source

change to the nagios plugin directory

Changing into the nagios-plugins-2.0.3 directory

configure the plugins

./configure --with-nagios-user=nagios --with-nagios-group=nagios for the plugins

issue the make command

Configuring nagios-plugins-2.0.3 with the nagios user and group options

now install with make install

Running make install in the nagios-plugins-2.0.3 directory

now all we need to do is start nagios, pretty simple right?

Nagios pre-flight check: Total Warnings 0, Total Errors 0, things look okay

verify that there are no warnings/errors

Nagios config verification showing 0 warnings and 0 errors

now start the service

service nagios start output: Starting nagios: done

also remember to set it to start on startup

Browser Nagios Access login prompt for the nagiosadmin user

now go to your browser, and enter

http://ipaddress/nagios

Nagios Access authentication prompt at http://ipaddress/nagios

you will be prompted for a username/password, this is the nagiosadmin password from earlier

Bam, you are now logged into Nagios!

Nagios Core 4.0.8 home page showing daemon running after login

That’s it! You have successfully installed Nagios!

Related guides: Install Nagios 4 on CentOS/RHEL6 | Configure SNMP on CentOS

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *