Guide to Deploying Nagios Core on Ubuntu
Table of contents
- Checking SELinux Status:
- Prerequisites:
- Downloading the Source:
- Compile and Install:
- Create User and Group:
- Install Binaries:
- Install Service / Daemon:
- Install Command Mode:
- Install Configuration Files:
- Install Apache Config Files:
- Configure Firewall:
- Create Nagiosadmin User Account:
- Start Apache Web Server:
- Start Nagios Core:
- Test Nagios:
- Installing The Nagios Plugins:
- Test Plugins:
- Nagios Service / Daemon Commands:
- Reference :-
Introduction:
In the dynamic landscape of IT infrastructure, proactive monitoring is paramount. Nagios Core, an open-source monitoring system, provides a robust solution for overseeing hosts, services, and network devices. This comprehensive guide walks you through the process of deploying Nagios Core on Ubuntu, ensuring you have a vigilant eye on your IT environment. Let's dive into the step-by-step setup, including commands and configurations.
Checking SELinux Status:
Before diving into Nagios Core installation, it's crucial to check the SELinux status, especially if you are running Ubuntu in permissive mode or with SELinux disabled.
sudo dpkg -l selinux*
Prerequisites:
Install the necessary packages based on your Ubuntu version:
Ubuntu 20.x:
sudo apt-get update sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev sudo apt-get install openssl libssl-dev
Downloading the Source:
Download Nagios Core source code and extract it:
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.14.tar.gz
tar xzf nagioscore.tar.gz
Compile and Install:
Navigate to the Nagios Core directory and compile the source code:
cd /tmp/nagioscore-nagios-4.4.14/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
Create User and Group:
Create the necessary Nagios user and group:
sudo make install-groups-users
sudo usermod -a -G nagios www-dat
Install Binaries:
Install Nagios Core binaries, CGIs, and HTML files:
sudo make install
Install Service / Daemon:
Install Nagios service or daemon files and configure them to start on boot:
sudo make install-daemoninit
Install Command Mode:
Install and configure the external command file:
sudo make install-commandmode
Install Configuration Files:
Install sample configuration files required for Nagios to start:
sudo make install-config
Install Apache Config Files:
Install Apache web server configuration files and configure Apache settings:
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi
Configure Firewall:
Allow inbound traffic on port 80 for Apache:
sudo ufw allow Apache
sudo ufw reload
Create Nagiosadmin User Account:
Create an Apache user account for logging into Nagios:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Start Apache Web Server:
Restart Apache based on your Ubuntu version:
Ubuntu 14.x:
sudo service apache2 restart
Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x:
sudo systemctl restart apache2.service
Start Nagios Core:
Start Nagios Core service based on your Ubuntu version:
Ubuntu 14.x:
sudo start nagios
Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x:
sudo systemctl start nagios.service
Test Nagios:
Access the Nagios Web Interface in your browser using your server's IP or FQDN:
http://your-server-ip/nagios
Log in with the credentials created earlier (username: nagiosadmin, password: provided during user creation). Congratulations! Nagios Core is successfully installed.
Installing The Nagios Plugins:
Nagios Core needs plugins to operate. Follow these steps to install Nagios Plugins:
sudo apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
Downloading The Source:
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.4.6.tar.gz
tar zxf nagios-plugins.tar.gz
Compile and Install:
cd /tmp/nagios-plugins-release-2.4.6/
sudo ./tools/setup
sudo ./configure
sudo make
sudo make install
Test Plugins:
Point your browser to your Nagios Core server and go to a host or service object. "Re-schedule the next check" under the Commands menu. The errors should disappear, and correct output will be shown.
Nagios Service / Daemon Commands:
Different Ubuntu versions have different methods for starting, stopping, restarting, and checking Nagios. Use the appropriate commands based on your version:
Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x:
sudo systemctl start nagios.service sudo systemctl stop nagios.service sudo systemctl restart nagios.service sudo systemctl status nagios.service
Congratulations! You've successfully deployed Nagios Core on Ubuntu, equipped with comprehensive monitoring and alerting capabilities. Monitor, optimize, and ensure the seamless performance of your IT environment with Nagios Core. Happy monitoring!
Reference :-
https://support.nagios.com/kb/article.php?id=96
Subscribe to my newsletter
Read articles from Amol Kadwe directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Amol Kadwe
Amol Kadwe
Hey there! I'm passionate about DevOps, with a strong IT background and a knack for automation. I'm skilled in version control using Git, setting up CI/CD pipelines, containerization with Docker, orchestrating deployments with Kubernetes, managing infrastructure operations, and leveraging cloud platforms like AWS, Azure, and GCP. I love sharing what I learn through tutorials and training sessions, so join me on my blog for practical DevOps insights and tips!