How to install and configure nagios on Ubuntu

How to install and configure nagios core on Ubuntu:

Today we will see in this articles that how to install open source monitoring tool nogios core on Ubuntu.  It's more important tool which help us to identify that our ISP connection is up and not even we can add also server, computer and printer. Please follow all below step to install nagios core from open source.



Perform these steps to install nagios core from open source:-

===== Ubuntu 14.x / 15.x =====


sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 apache2-utils php5 libgd2-xpm-dev


===== Ubuntu 16.x / 17.x =====

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev


===== Ubuntu 18.x =====

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev


To Download the Source

cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.1.tar.gz
tar xzf nagioscore.tar.gz


Compile
cd /tmp/nagioscore-nagios-4.4.1/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all


Create User And Group

This creates the nagios user and group. The nagiosusr user is also added to the nagios group.

sudo make install-groups-users
sudo usermod -a -G nagios nagiosusr




Install Binaries
This step installs the binary files, CGIs, and HTML files.


sudo make install


Install Service / Daemon
This installs the service or daemon files and also configures them to start on boot.


sudo make install-daemoninit


Information on starting and stopping services will be explained further on.

Install Command Mode - This installs and configures the external command file.

sudo make install-commandmode


Install Configuration Files
This installs the *SAMPLE* configuration files. These are required as Nagios needs some configuration files to allow it to start.


sudo make install-config


Install Apache Config Files
This installs the Apache web server configuration files and configures Apache settings.


sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi


To Configure Firewall - You need to allow port 80 inbound traffic on the local firewall so you can reach the Nagios Core web interface.

sudo ufw allow Apache
sudo ufw reload


Create nagiosadmin User Account

You'll need to create an Apache user account to be able to log into Nagios.

The following command will create a user account called nagiosadmin and you will be prompted to provide a password for the account.


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




When adding additional users in the future, you need to remove -c from the above command otherwise it will replace the existing nagiosadmin user (and any other users you may have added).

Start Apache Web Server

===== Ubuntu 14.x =====


Need to restart it because it is already running.

sudo service apache2 restart


===== Ubuntu 15.x / 16.x / 17.x /18.x =====

Need to restart it because it is already running.


sudo systemctl restart apache2.service

Start Service / Daemon

This command starts Nagios Core.


===== Ubuntu 14.x =====

sudo start nagios


===== Ubuntu 15.x / 16.x / 17.x / 18.x =====


sudo systemctl start nagios.service


Test Nagios

Nagios is now running, to confirm this you need to log into the Nagios Web Interface.

Point your web browser to the ip address or FQDN of your Nagios Core server, for example:

http://192.168.1.111/nagios

http://nagios.domain.local/nagios

You will be prompted for a username and password. The username is nagiosadmin (you created it in a previous step) and the password is what you provided earlier.

Once you have logged in you are presented with the Nagios interface. Congratulations you have installed Nagios Core.


Share:

0 comments

Please leave your comments...... Thanks