Install Nagios 4.1.1 on Ubuntu 16.04

Install Nagios 4.1.1 on Ubuntu 16.04
Install Nagios 4.1.1 on Ubuntu 16.04

Nagios is one of the most widely used open source monitoring tool; it helps you to monitor the services and application that run’s on Windows and Linux. Nagios also has the capability to monitor routers and other network devices.

With the help of Nagios, you can monitor basic services and attributes. We can access the Nagios using web interface coming with the bundle and configuration need to be done on the file level.

What’s New:

  • Core Workers are a lightweight process whose job is to perform checks, due to this they do checks much more quickly than the old process.
  • Nagios Core process using in-memory techniques, eliminating the disk I/O latencies that could previously slow things down in a large installation.
  • Configuration verification has been improved so that each configuration item is verified only once
  • The host address attribute is now optional.
  • Bothe hosts and services now support an hourly value attribute.

Find more on What’s new in this version.

Services List:

Nagios can monitor your “private” services and attributes of Linux/UNIX servers, such as:


  • CPU load
  • Memory usage
  • Disk usage
  • Logged in users
  • Running processes
  • etc.

Private Services:

  • HTTP
  • FTP
  • SSH
  • SMTP
  • etc

Install Nagios 4.1.1 on Ubuntu 16.04:


Nagios 4.1.1 is the latest version at the time of writing,  before compiling the Nagios from the source; you need to install dependent packages for Nagios to work.

PS: Get the Latest version of Nagios from the official page.

Let’s switch to root user.

sudo su

Update the repository cache and install the dependencies for Nagios 4.

apt-get update
apt-get install build-essential apache2 php7.0 openssl perl make php7.0-gd libgd2-xpm-dev libapache2-mod-php7.0 libperl-dev libssl-dev daemon wget apache2-utils unzip

Create nagios user and nagcmd group (allowing the external commands to be executed through the web interface), add the nagios and apache user to the part of the nagcmd group.

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data
cd /tmp
tar -zxvf /tmp/nagios-4.1.1.tar.gz
cd /tmp/nagios-4.1.1/

Compile and Install Nagios:

Perform below steps to compile the Nagios from the source code.

./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

Configure Nagios:

Configuration files have now been placed by the installer in the /usr/local/nagios/etc directory. These default configuration files should work fine for now to start Nagios.  All you need to make just one change before you proceed…

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

vi /usr/local/nagios/etc/objects/contacts.cfg

Change the email address field to receive the notification.

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           [email protected]      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Configure Web Interface:

Create a user account (nagiosadmin) for logging into the Nagios web interface. Remember the password you assign to this account – you’ll need it later.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Run the following command.

a2enmod cgi

Restart Apache to make the new settings take effect.

service apache2 restart

Download and Install Nagios Plugins:

Now, it’s time to download Nagios plugins for monitoring the services. Place it into /tmp directory.

cd /tmp
tar -zxvf /tmp/nagios-plugins-2.1.1.tar.gz
cd /tmp/nagios-plugins-2.1.1/

Compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install

Starting Nagios:

Verify the sample Nagios configuration files.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Ubuntu 16.04 uses systemd for starting / stopping all the services, so, we need to create nagios.service file.

vi /etc/systemd/system/nagios.service

Add below content into above file.



ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

Enable Nagios to start automatically at system startup.

systemctl enable /etc/systemd/system/nagios.service

Now, start Nagios service.

systemctl start nagios

Access Web Interface:

Now access the Nagios web interface using the following URL. You’ll be prompted for the username (nagiosadmin) and password you specified earlier.

Install Nagios 4.1.1 on Ubuntu 16.04 – Nagios Host Status
Install Nagios 4.1.1 on Ubuntu 16.04 – Nagios Host Status

That’s All. Hope this helped you, please post your valuable comments below.


Share This Post

  • Fabio Hack Moretto

    Great guide! Thanks a lot!