Nagios is an open source network monitoring software which was released under the GPL license. It has more than 1 million users worldwide. It provides full access of source code so that anyone can make improvements to enhance its features. It has active community which provides free support. Nagios has hundreds of addons developed by this community.
Nagios has ability to monitor services, network protocols, applications, operating systems, system metrics and infrastructure components. It allows easy monitoring of systems, services and applications using its powerful script APIs.
Nagios provides a centralized view of the whole IT infrastructure. It provides detailed information via web interface. It supports fast detection of infrastructure outages. Nagios allows to send alerts to technical staff via SMS and email. It has escalation capabilities which ensure that alert notifications have reached to right people.
Nagios has event handlers which allows automatic restart of failed applications and services. It has alert acknowledgement which provides communication on known issues and problem response. During infrastructure upgrades, scheduled downtime allows for alert suppression. Capacity planning and trending addons help to ensure that you are aware of aging infrastructure. To ensure that SLAs are met, availability reports are available. You can check historical reports to provide you record of alerts, outages, alert response and notifications.
Nagios provides many third party addons to extend reporting capabilities. It supports multiple users. A client only sees his restricted and bounded view of infrastructure components. Multi-user access to web interface allows stake holders to view infrastructure components. It provides easy integration with third party and in-house applications by using multiple APIs. There are hundreds of addons developed by community which extend Nagios functionality.
Nagios was written in C-language. It involves over 10 years of active development. Nagios got a number of awards, media coverage and recognition which prove its value. It has failover capabilities that ensure non-stop monitoring of critical IT infrastructure components. It can be scaled to monitor thousands of nodes.
As a developer, I prefer the services of Alibaba Cloud ECS. Alibaba Elastic Compute (ECS) is highly scalable and flexible. You can upgrade the hardware resources anytime when required. Alibaba Cloud can also provide you technical support and assistance in order to launch any kind of system.
In this tutorial, I will be using Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 installed on it. I will install and setup Nagios.
Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges. After execution of this command, you will be prompted to Is this ok? Type ‘y’ and hit Enter key.
# sudo apt update && sudo apt upgrade
You will need to install unzip on your server. To install and configure unzip, follow the steps below.
To install unzip execute the command.
# sudo apt-get install unzip
You will need to install libssl-dev on your server. To install and configure libssl-dev, follow the steps below.
To install libssl-dev execute the command.
# sudo apt-get install libssl-dev
You will need to install build-essential on your server. To install and configure build-essential, follow the steps below.
To install build-essential execute the command.
# sudo apt-get install build-essential
You will need to install libgd2-xpm-dev on your server. To install and configure libgd2-xpm-dev, follow the steps below.
To install libgd2-xpm-dev execute the command.
# sudo apt-get install libgd2-xpm-dev
You will need to install openssl on your server. To install and configure openssl, follow the steps below.
To install openssl execute the command.
# sudo apt-get install openssl
Nagios requires installation of PHP 5.3 or newer version of PHP. In this tutorial, you will install PHP 7.2. To install PHP 7.2, execute the following steps.
In the first step, you will need to install python software properties and software properties common. To do so, execute the command below.
# sudo apt-get install software-properties-common python-software-properties
You will need to add repository for newer versions of PHP. To do so, execute the commands below.
# sudo add-apt-repository ppa:ondrej/php
Update the system to refresh the available repositories. To do so, execute the command for updating Ubuntu system.
# sudo apt update
Now let’s install PHP 7.2. To install PHP 7.2, execute the following command.
# sudo apt install -y php7.2
Nagios requires the following PHP extensions:
To install the above extensions of PHP, execute the following command.
# sudo apt install -y php7.2-mysql php7.2-curl php7.2-mbstring libapache2-mod-php
When you have done installation of the above extensions, apache2 will be installed automatically. Hence, you don’t need to install apache explicitly.
To check PHP installation, you can execute the following command to check the installed PHP version.
# php --version
To install Nagios, you will need to follow the steps below.
In the first step, you will create a user group and add a user.
# sudo adduser nagios
# sudo groupadd nagcmd
Add user to nagcmd group.
# sudo adduser nagios nagcmd
Download Nagios by executing the command below.
# curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
In the second step, you will need to extract files from archived folder by using the command below.
# tar zxf nagios-4.3.4.tar.gz
In the third step, rename the extracted folder.
# mv nagios-4.3.4 nagios
Remove the downloaded archived directory.
# sudo rm nagios-4.3.4.tar.gz
Navigate to nagios using the command below.
# cd nagios
Before building Nagios, you will need to run configure where you will specify username and group you want Nagios to use.
# ./configure --with-nagios-group=nagios --with-command-group=nagcmd
Now execute the following command to compile Nagios.
# make all
Now execute the following commands to install Nagios, default configuration and init scripts.
# sudo make install
# sudo make install-commandmode
# sudo make install-init
# sudo make install-config
Nagios monitors remote hosts using Nagios Remote Plugin Extractor. To install it, follow the steps below.
Navigate to home directory.
# cd ~
Download archived folder by using the command below.
# curl -L -O https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
Extract archived directory using the command below.
# tar zxf nrpe-*.tar.gz
Navigate to nrpe-* extracted directory.
# cd nrpe-*
Execute the following commands to configure, compile and install nrpe.
# ./configure
# make check_nrpe
# sudo make install-plugin
Now you will need to use Apache for serving web interface of Nagios. Execute the following command to copy apache configurations for Nagios to sites-available directory.
# sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
To entertain external commands via web interface to Nagios, you will need to add www-data user to nagcmd group.
# sudo usermod -G nagcmd www-data
Open Nagio configuration file using command below.
# sudo nano /usr/local/nagios/etc/nagios.cfg
Find the line shown below and remove # to uncomment it and then save the file.
Now you will need to create a directory to store configuration file for each server that you will monitor by executing the command below.
# sudo mkdir /usr/local/nagios/etc/servers
Execute the following command to open contacts configuration file and replace email with your own email.
# sudo nano /usr/local/nagios/etc/objects/contacts.cfg
Open the file by executing command below.
# sudo nano /usr/local/nagios/etc/objects/commands.cfg
Add the following text to the end of opened file and save it.
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Now you will need to enable rewrite mod. You can do so by editing configuration file in apache2 directory or you can simply execute the command below.
# sudo a2enmod rewrite
Now you will need to enable cgi mod. You can do so by editing configuration file in apache2 directory or you can simply execute the command below.
# sudo a2enmod cgi
To set the password for accesssing admin panel using username nagiosadmin execute the following command.
# sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Execute the command below to disable default site.
# sudo a2dissite 000-default.conf
Now you will need to enable the virtual host for Nagios. To do so, execute the command below.
# sudo a2ensite nagios
Now you will have to restart apache server to apply the changes and load the settings by executing command below.
# sudo service apache2 restart
Execute the following command to open a file for setting up Nagios service.
# sudo nano /etc/systemd/system/nagios.service
Now copy and paste the following text in opened file.
[Unit]
Description=Nagios
BindTo=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=nagios
Group=nagios
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
Now execute the following command to start Nagios service.
# sudo systemctl start Nagios
Now you can access your Nagios server via IP address or domain name.
After entering username and password for admin, you will be redirected to Nagios dashboard.
Here you go…you have successfully installed and configured Nagios server monitoring.
You may be interested in making your server ready for Minecraft.
If you are living in a digital world you must know how to protect your…
Software Development Life Cycle Model, also known as SDLC or Software Development Process, is base…
Go, often referred to as golang is a modern open-source programming language created by Google…
Torque published an article on October 18, 2016, about WordPress statistics. According to this article,…
PostgreSQL, often known simply as Postgres, is an open-source general-purpose object-relational database management system. In…
SEO is free as well as paid. To achieve SE ranking, money is not enough.…