Discover how to install Nagios on CentOS 6 with this step-by-step guide. Ensure effective monitoring of your network services and infrastructure. #centlinux #linux #nagios
Table of Contents
What is Nagios Core?
Nagios Core is a free and open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved. Nagios Core is the monitoring and alerting engine that serves as the primary application around which hundreds of Nagios projects are built.
In this article, we will setup a network monitoring server by installing Nagios Core 4.2 on a preconfigured CentOS 6 machine.

Read Also: How to install LAMP on CentOS 7
Linux Server Specification
Nagios Core 4.2 does not have any specific system requirements except it requires a Linux 5/6/7 Server. Therefore, we have setup a virtual machine with the following specification:
- CPU – 2.4 Ghz (2 cores)
- Memory – 1 GB
- Storage – 20 GB
- Swap – 2 GB
- Operating System – CentOS 6.7
If you’re serious about mastering IT infrastructure monitoring, the Zabbix Application and Network Monitoring by Sean Bradley course is a must-have resource. This practical training walks you through real-world scenarios to monitor servers, applications, and networks with confidence, making it ideal for system administrators, DevOps engineers, and IT professionals aiming to level up their skills. By enrolling, you’ll gain hands-on knowledge that can save countless hours in troubleshooting and system management. [Click here to check out the course]
Disclaimer: This link is an affiliate link, which means I may earn a small commission at no extra cost to you if you decide to purchase through it. This helps support my blog and allows me to continue creating useful content.
Install Nagios on CentOS 6
Verify kernel version and network configurations.
uname -aOutput:
Linux nagios01.test.local 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Check network configuration.
ip addrOutput:
1: lo: mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:c6:33:f9 brd ff:ff:ff:ff:ff:ff
inet 192.168.79.139/24 brd 192.168.79.255 scope global eth0
inet6 fe80::20c:29ff:fec6:33f9/64 scope link
valid_lft forever preferred_lft forever
Install required packages using yum.
yum install -y make net-snmp httpd php gcc glibc glibc-common gd gd-devel wget unzipCreate User and Group for Nagios.
useradd nagios
groupadd nagcmdAdd users to nagcmd group.
usermod -G nagcmd nagios
usermod -G nagcmd apacheCreate a directory to download Nagios packages.
mkdir -p /soft/nagios
cd /soft/nagiosDownload Nagios Core 4.2 and Nagios Plugins 2.1 tarballs from https://www.nagios.org/.
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gzExtract downloaded tarballs.
tar -xvf nagios-4.2.0.tar.gz
tar -xvf nagios-plugins-2.1.2.tar.gzCompile and install Nagios Core.
cd /soft/nagios/nagios-4.2.0
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconfConfigure Nagios Core 4.2 on CentOS 6
Open contact.cfg file in vi editor.
vi /usr/local/nagios/etc/objects/contacts.cfgand change the email address of nagiosadmin with your email address to receive notifications.
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 alaric.bird@gmail.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}Nagios Core does not provide any authentication method, therefore we are required to setup Basic HTTP Authentication for Nagios web interface.
htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadminStart httpd service and enable it on runlevel 3 and 5.
service httpd start
chkconfig --level 35 httpd onCompile and install Nagios Plugins.
cd /soft/nagios/nagios-plugins-2.1.2
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make installVerify Nagios configurations.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgOutput:
Nagios Core 4.2.0
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-01-2016
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
Start nagios service and enable it on Runlevel 3 and 5.
chkconfig --level 35 nagios on
service nagios startDisable SELinux.
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/configAllow HTTP Port in Linux firewall using iptables.
iptables -I INPUT 5 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
service iptables saveNow open Nagios in browser, and user the nagiosadmin to login.





Final Thoughts
Installing Nagios on CentOS 6 is a critical step to ensure effective monitoring of your network services and infrastructure. By following this guide, you can set up Nagios smoothly and enhance your system’s reliability and performance.
Need expert AWS and Linux system administration? From cloud architecture to server optimization, I provide reliable and efficient solutions tailored to your needs. Hire me today!

Leave a Reply
Please log in to post a comment.