In this tutorial, We are going to perform How to download and Install Nagios on Ubuntu 18.04/16.04 LTS or any Cloud Instance like Amazon EC2, Azure VM, Google Compute Engine,etc. with preinstalled Ubuntu 18.04/16.04 LTS Step by Step.
Introduction
Nagios Core is free and open source monitoring tools which is used to monitor the System resources, applications ,Services, Databases and network devices such asRouters,switches,..etc.
Using Nagios Core we can monitor below resources and Network Ports.
Resources
- CPU utilization
- Memory utilization
- Disk utilization
- Logged in users
- Running processes
- System Uptime
- Service states
- Swap utilization
Network Ports
- HTTP
- FTP
- SSH
- SMTP
- Ping
- Bandwidth Latency
- Mysql
- IMAP
- POP3
- Tomcat
- PHP wrapper
- MySQL
Prerequisites
- Ubuntu Server with 18.04/16.04 LTS
- Preinstalled Apache2
- 1 CPU and 2 GB RAM
- Firewall Ports 5666,80,443
Before installing Nagios, Install the below per-requisite packages .
Ubuntu 16.04 LTS
$ 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.04 LTS
$ sudo apt-get update $ sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev
Step 1: Create Nagios User and Group
Enter below command to create Nagios user and group and add www-data user to nagios group.
$ sudo useradd nagios $ sudo groupadd nagios $ sudo make install-groups-users $ sudo usermod -a -G nagios www-data
Step 2: Download and Install Nagios on Ubuntu
Here We are downloading Nagios Core 4.4.5 setup, To download latest version visit Officical Nagios Site
Navigate to /tmp directory
$ cd /tmp
Download and Extract the Nagios Core Setup
$ sudo wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.5.tar.gz $ tar xzf nagioscore.tar.gz $ cd /tmp/nagioscore-nagios-4.4.5/
Compile the Nagios Core and Install
$ sudo ./configure --with-nagios-group=nagios --with-command-group=nagios --with-httpd_conf=/etc/apache2/sites-enabled/ $ sudo make all $ sudo make install $ sudo make install-daemoninit $ sudo make install-commandmode $ sudo make install-config
Step 3: Install and Configure Apache Files
Install and configure apache files using below commands,
$ sudo make install-webconf $ sudo a2enmod rewrite $ sudo a2enmod cgi
Restart an Apache to take effect
$ sudo systemctl restart apache2
Step 4: Create User Account to Access Nagios Web Interface
We have to create user in apache and set password. Enter below command for same.
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Output:
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin
Step 5: Download and Install Nagios Plugins
Navigate to /tmp directory, Download the nagios core plugin and extract it as shown below
$ cd /tmp $ sudo wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz $ tar zxf nagios-plugins.tar.gz
Compile and install nagios core plugins,
$ cd /tmp/nagios-plugins-release-2.2.1/ $ sudo ./tools/setup $ sudo ./configure $ sudo make $ sudo make install
Step 6: Verify Nagios Configuration, Start Nagios and Enable
Verify the Nagios core configuration using below command,
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Output:
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.4.5 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2019-08-20 License: GPL Website: https://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
To start Nagios Service
$ sudo systemctl start nagios
To enable nagios service at system startup
$ sudo systemctl enable nagios
Step 7: Accessing Nagios Web Interface
To access nagios web interface, Open your favorite browser and type your server name or IP followed by nagios/
http://Server_IP/nagios
OR
http://Domain_Name/nagios
Once you hit above URL, Enter the credentials of “nagiosadmin” user and you will be redirected to nagios default page.
To Monitor the services. go to Current status -> Services at left pane as shown below
Conclusion
In this article, we have performed Creating nagios user and group, downloading Nagios Core, compiling and installing nagios, Installing apache configuration files, Downloading and installing Nagios core plugins, verify,start and enable Nagios service, Accessing nagios web interface.
How to Install Nagios Core on CentOS 7
How to Install Netdata On Ubuntu
How to Install ELK Stack on Ubuntu
How to Install Splunk on Ubuntu 18.04/16.04 LTS
How to Install Splunk Enterprise on CentOS 7
https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html