Share on Social Media

Discover how to effortlessly install Nagios Core on Rocky Linux 9 with our step-by-step guide. Enhance your system monitoring capabilities and ensure the reliability of your infrastructure with this powerful open-source solution. #centlinux #linux #nagios

What is Nagios Core?:

Nagios Core /ˈnɑːɡiːoʊs/, formerly known as Nagios, 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.

Ethan Galstad and a group of developers originally wrote Nagios as NetSaint. As of 2015 they actively maintain both the official and unofficial plugins. Nagios is a recursive acronym: “Nagios Ain’t Gonna Insist On Sainthood” – “sainthood” makes reference to the original name NetSaint, which changed in response to a legal challenge by owners of a similar trademark. “Agios” (or “hagios”) also transliterates the Greek word άγιος, which means “saint”.

Nagios was originally designed to run under Linux, but it also runs on other Unix variants. It is free software licensed under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. (Source: Wikipedia)

Nagios Core vs Zabbix

Nagios Core and Zabbix are both popular open-source network monitoring tools, but they have different approaches and features. Here’s a comparison:

  • Architecture:
  • Nagios Core: Nagios follows a plugin-based architecture. It uses a central server that monitors hosts and services by executing plugins on remote machines.
  • Zabbix: Zabbix employs an agent-based architecture. It relies on agents installed on monitored devices to collect data, which is then sent to a central server for processing.
  • Ease of Use:
  • Nagios Core: Nagios requires more manual configuration and setup compared to Zabbix. It’s highly customizable but may have a steeper learning curve for beginners.
  • Zabbix: Zabbix offers a more user-friendly interface and simplified setup process. It provides built-in templates for various devices and services, making it easier to get started.
  • Monitoring Capabilities:
  • Nagios Core: Nagios Core provides comprehensive monitoring capabilities, including network, server, and application monitoring. It supports event handling, alerting, and reporting.
  • Zabbix: Zabbix offers a wide range of monitoring functionalities, including network, server, cloud, and application monitoring. It provides real-time monitoring, triggers, alarms, and visualization features.
  • Scalability:
  • Nagios Core: Nagios Core may require additional effort to scale for large environments. While it can handle thousands of devices, scalability can become a concern in extremely large deployments.
  • Zabbix: Zabbix is known for its scalability and performance. It’s capable of handling thousands of devices and checks efficiently, making it suitable for enterprise-level deployments.
  • Community and Support:
  • Nagios Core: Nagios has a large and active community with extensive documentation and user-contributed plugins. However, official support is primarily available through paid Nagios XI subscriptions.
  • Zabbix: Zabbix also has a strong community and provides extensive documentation. Additionally, official commercial support is available from the Zabbix company.

Ultimately, the choice between Nagios Core and Zabbix depends on factors such as your specific monitoring requirements, existing infrastructure, scalability needs, and preferences for ease of use. Both tools are powerful options for network monitoring, and the best choice will vary depending on the unique needs of your organization.

Recommended Online Training: Nagios for DevOps and IT Network System Administrators

5810998 8358 3show?id=oLRJ54lcVEg&offerid=1074530.5810998&bids=1074530

Environment Specification

We are using a minimal Rocky Linux 9 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux release 9.1 (Blue Onyx)
  • Hostname – nagios-01.centlinux.com
  • IP Address – 192.168.88.128/24

Prepare your Linux Server:

By using a ssh client, login as root user on your Rocky Linux server.

Set a Fully Qualified Domain Name (FQDN) for your Linux machine. You may also need to setup Local DNS resolution Or you can install a Linux based DNS server for this purpose.

# hostnamectl set-hostname nagios-01.centlinux.com
# echo "192.168.88.128 nagios-01 nagios-01.centlinux.com" >> /etc/hosts

Refresh your Yum cache and update software packages in your Linux operating system.

# dnf makecache
# dnf update -y

If the above command updates your Linux Kernel, then you should reboot your Linux operating system with newly installed Kernel before installing Nagios Core software.

# reboot

After reboot, check the version of your Linux operating system and Kernel.

# cat /etc/rocky-release
Rocky Linux release 9.1 (Blue Onyx)

# uname -r
5.14.0-162.18.1.el9_1.x86_64

SELinux may cause problems for Nagios Core software. Therefore, it is recommended in the Nagios Core documentation to disable SELinux or put it in permissive mode before installing your network monitoring software.

You can use following commands to permanantly disable SELinux on Rocky Linux 9.

# sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
# setenforce 0

Install Nagios Core Prerequisites:

Nagios Core requires some software packages. You can install all these packages by using following dnf command.

# dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel tar openssl-devel make gettext automake autoconf net-snmp net-snmp-utils epel-release

Rebuild your yum cache for EPEL repository.

# dnf makecache

Execute following command to install perl-Net-SNMP package from EPEL yum repository.

# dnf install -y perl-Net-SNMP

Enable and start Apache and PHP services.

# systemctl enable --now httpd.service php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

Install Nagios on Rocky Linux 9

Currently Nagios Core 4.4.10 is available at their official website.

You can download it by executing wget command at Linux bash prompt.

# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.10.tar.gz
--2023-03-14 21:21:57--  https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.10.tar.gz
Resolving assets.nagios.com (assets.nagios.com)... 45.79.49.120, 2600:3c00::f03c:92ff:fef7:45ce
Connecting to assets.nagios.com (assets.nagios.com)|45.79.49.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11339491 (11M) [application/x-gzip]
Saving to: ‘nagios-4.4.10.tar.gz’

nagios-4.4.10.tar.g 100%[===================>]  10.81M   929KB/s    in 12s

2023-03-14 21:22:10 (943 KB/s) - ‘nagios-4.4.10.tar.gz’ saved [11339491/11339491]

Extract the downloaded Nagios Core source as follows.

# tar xzf nagios-4.4.10.tar.gz

Go to extracted directory and configure the Nagios setup according to your server environment.

# cd nagios-4.4.10
# ./configure
...
...
...
Creating sample config files in sample-config/ ...


*** Configuration summary for nagios 4.4.10 2023-01-17 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagios
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  /run/nagios.lock
   Check result directory:  /usr/local/nagios/var/spool/checkresults
           Init directory:  /lib/systemd/system
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu
          IOBroker Method:  epoll

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

Compile Nagios main program and CGIs using following command.

# make all
...
...
...
*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with testing or installing Nagios as follows (type
'make' without any arguments for a list of all possible options):

  make test
     - This runs the test suite

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /lib/systemd/system

  make install-daemoninit
     - This will initialize the init script
       in /lib/systemd/system

  make install-groups-users
     - This adds the users and groups if they do not exist

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface

  make install-classicui
     - This installs the classic theme for the Nagios
       web interface


*** Support Notes *******************************************

If you have questions about configuring or running Nagios,
please make sure that you:

     - Look at the sample config files
     - Read the documentation on the Nagios Library at:
           
Nagios Library
before you post a question to one of the mailing lists. Also make sure to include pertinent information that could help others help you. This might include: - What version of Nagios you are using - What version of the plugins you are using - Relevant snippets from your config files - Relevant error messages from the Nagios log file For more information on obtaining support for Nagios, visit:
Nagios Support Home
************************************************************* Enjoy.

Create the required OS users and groups by using the following command.

# make install-groups-users
groupadd -r nagios
useradd -g nagios nagios

Add nagios as secondary group of apache user.

# usermod -a -G nagios apache

Install the already compiled Nagios Core binaries on your Rocky Linux server.

# make install

To configure autostart of Nagios network monitoring software, you need to create a systemd service. The Nagios installer also provides a method to create the required service.

You can create the Nagios service by using the following command.

# make install-daemoninit
/usr/bin/install -c -m 755 -d -o root -g root /lib/systemd/system
/usr/bin/install -c -m 755 -o root -g root startup/default-service /lib/systemd/system/nagios.service
Created symlink /etc/systemd/system/multi-user.target.wants/nagios.service → /usr/lib/systemd/system/nagios.service.

*** Init script installed ***

You can use the following command to configure Nagios Core command mode on Rocky Linux 9.

# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw

*** External command directory configured ***

Install the Nagios sample configuration file on your Rocky Linux server by using the following command format.

# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

Install the Apache configuration file to configure the Nagios web interface.

# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
if [ 0 -eq 1 ]; then 
        ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; 
fi

*** Nagios/Apache conf file installed ***

Everything has been configured successfully. Now it is time to start and test the Nagios and Apache services.

# systemctl restart httpd nagios

Configure Linux Firewall:

Allow the Apache web service in your Linux firewall.

# firewall-cmd --permanent --add-service=http
success

# firewall-cmd --reload
success

Configure Basic HTTP Authentication:

Nagios Core does not provide a native authentication method, therefore, you have to use Basic HTTP authentication to create authentication control for the Nagios web interface.

Create an Admin user and add it to htaccess password file.

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Install Nagios Plugins:

To monitor a machine with Nagios network monitoring software, you need to install the relevant plugins/agents on that machine.

Nagios Plugins is a pack of more than 50 plugins that provides the plugins to monitor most common metrics and services on a machine.

Download Nagios Plugins from their official website.

# wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
--2023-03-14 21:54:23--  https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
Resolving nagios-plugins.org (nagios-plugins.org)... 45.56.123.251
Connecting to nagios-plugins.org (nagios-plugins.org)|45.56.123.251|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2782610 (2.7M) [application/x-gzip]
Saving to: ‘nagios-plugins-2.3.3.tar.gz’

nagios-plugins-2.3. 100%[===================>]   2.65M   885KB/s    in 3.1s

2023-03-14 21:54:28 (885 KB/s) - ‘nagios-plugins-2.3.3.tar.gz’ saved [2782610/2782610]

Extract the downloaded tarball using tar command.

# tar zxf nagios-plugins-2.3.3.tar.gz

Go to extracted setup directory and build and install Nagios Plugins from source.

# cd nagios-plugins-2.3.3
# ./configure
# make
# make install

Restart the Nagios Service to take changes into effect.

# systemctl restart nagios.service

Browse URL http://nagios-01.centlinux.com/nagios in a web browser.

You need to Login as nagiosadmin user.

Nagios Core Dashboard
Nagios Core Dashboard

We are now at the Dashboard of Nagios Core web interface. Click on “Services”.

Nagios Core Services
Nagios Core Services

Recommended Book: Learning Nagios – Third Edition (PAID LINK)

Video: Nagios Installation on Linux

YouTube player

Final Thoughts

Equip yourself with the essential knowledge to seamlessly install Nagios Core on Rocky Linux 9. Strengthen your system monitoring infrastructure and elevate your network’s reliability with this versatile and robust open-source tool. Let this guide empower you to optimize your system’s performance and maintain peak operational efficiency.

2 thoughts on “Install Nagios Core on Rocky Linux 9”

Leave a Reply

Your email address will not be published. Required fields are marked *