How to Install Nagios Open Source Monitoring on CentOS 9 Stream Server. In this tutorial we will introduce Nagios with it’s main advantages and then we will proceed to download Nagios server and compile it from the downloaded source.
Nagios is very useful monitoring tool for Network and System administrator that helps to add and monitor any number of hosts and network devices from the web based console. If you are looking for an open source monitoring solution then Nagios is the best option for you.
What Is Nagios Monitoring Tool?
Nagios is an open source monitoring tool for computer systems. The tool is designed to run on the Linux operating system. It is used to monitor devices running on Linux, Windows and Unix Operating systems (OSes). The system conducts periodic checks regularly on critical parameters of application, network and server resources.
Nagios’ dashboard provides an overview of these critical parameters. Based on these parameters and thresholds, it sends out alerts to its users. You can receive the notification in different ways, including email and text messages. Then, an authorization system allows the administrator to restrict the access.
Furthermore, you can run Nagios either opting for an agent based or agentless configuration. While agent based configurations are installed both on hardware and software to collect data and then reported back to the management server, agentless monitoring uses the existing protocol to emulate an agent. However, whatever system you choose, they will be able to monitor file system usage, OS metrics, service and process states, etc.
Install Nagios Open Source Monitoring on CentOS 9 Stream Server
Prerequisites
A server running CentOS 9 Stream with SSH access.
A root user or a user with sudo privileges.
Install LAMP Server
First, you will need to install the LAMP server to access the Nagios via web browser. You can install all LAMP components by running the following command:
By default, Nagios is not included in the Centos 9 default repo. So you will need to compile it from the source. First, you will need to install all required dependencies needed to compile Nagios. You can install all of them using the following command:
Once the download is completed, extract the downloaded source with the following command:
tar -xvf nagios-4.4.5.tar.gz
Next, navigate to the Nagios source directory and configure it with the following command:
cd nagios-4.4.5
./configure --with-command-group=nagcmd
You will get the following output:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
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: /usr/sbin/sendmail
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.
Next, install systemd service file for Nagios using the following command:
make install-init
make install-daemoninit
Here please install Nagios config, and other configuration file with the following command:
make install-config
make install-commandmode
make install-exfoliation
Next, install Nagios web server configuration file with the following command:
make install-webconf
You will get the following output:
/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 ***
Setup Nagios Admin Password
By default, Nagios web interface is not secured with username and password. For security reasons, it is a good idea to secure Nagios admin console with username and password. You can set Nagios admin password with the following command:
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
Please start the Nagios service and enable it to start at system reboot:
systemctl start nagios
systemctl enable nagios
To check the Nagios service, run the following command:
systemctl status nagios
You should see the Nagios active status in the following output:
● nagios.service - Nagios Core 4.4.5
Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-06-25 06:45:04 UTC; 6s ago
Docs: https://www.nagios.org/documentation
Process: 48453 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Process: 48452 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Main PID: 48455 (nagios)
Tasks: 6 (limit: 23696)
Memory: 2.3M
CGroup: /system.slice/nagios.service
├─48455 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
├─48456 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
├─48457 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
├─48458 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
├─48459 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
└─48460 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
Jun 25 06:45:04 centos9 nagios[48455]: qh: Socket 'https://net.cloudinfrastructureservices.co.uk/usr/local/nagios/var/rw/nagios.qh' successfully initialized
Jun 25 06:45:04 centos9 nagios[48455]: qh: core query handler registered
Jun 25 06:45:04 centos9 nagios[48455]: qh: echo service query handler registered
Jun 25 06:45:04 centos9 nagios[48455]: qh: help for the query handler registered
Jun 25 06:45:04 centos9 nagios[48455]: wproc: Successfully registered manager as @wproc with query handler
Jun 25 06:45:04 centos9 nagios[48455]: wproc: Registry request: name=Core Worker 48457;pid=48457
Jun 25 06:45:04 centos9 nagios[48455]: wproc: Registry request: name=Core Worker 48458;pid=48458
Jun 25 06:45:04 centos9 nagios[48455]: wproc: Registry request: name=Core Worker 48456;pid=48456
Jun 25 06:45:04 centos9 nagios[48455]: wproc: Registry request: name=Core Worker 48459;pid=48459
Jun 25 06:45:05 centos9 nagios[48455]: Successfully launched command file worker with pid 48460
Configure Firewall
If firewalld service is installed and running on your server then you will need to allow the HTTP port 80 via firewalld service. You can allow it using the following command:
firewall-cmd --add-port=80/tcp --permanent
Next, reload the firewalld service to apply the firewall rule:
Great job! We have learned How to Install Nagios Open Source Monitoring on CentOS 9 Stream Server. Let’s summarize.
How to Install Nagios Open Source Monitoring on CentOS 9 Stream Server Conclusion
The Nagios monitoring tool is a free and powerful tool that allows system administrator to detect and fix the issues present in the network from the central place. Nagios web based console helps you to monitor and add several remote machines and network devices via web browser.
In the above guide, we explained how to install the latest version of Nagios on CentOS 9 Stream server. We also explained how to install the Nagios and NRPE plugins and configure them to monitor the server itself. You can now add the remote hosts to the Nagios and start monitoring them from the central location.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.