Install Nagios Monitoring Tool on AlmaLinux 9 with Best Guide

Posted on

Install Nagios Monitoring Tool on AlmaLinux 9 with Best Guide

Install Nagios Monitoring Tool on AlmaLinux 9 with Best Guide

This guide intends to teach you to Install Nagios Monitoring Tool on AlmaLinux 9. Nagios is a powerful tool used for network monitoring, providing comprehensive system information and real-time application oversight. It allows users to maintain server statistics, identify performance bottlenecks, and receive alerts when issues arise.

Nagios excels at server monitoring, pinpointing performance problems. The tool maintains server statistics, identifies and resolves performance-related issues, and sends alerts when issues are detected.

Let’s walk through the steps to Install Nagios Monitoring Tool on AlmaLinux 9.

To begin, you’ll need to meet a few prerequisites.

1. Requirements for Nagios Core Setup

First, ensure you are logged into your server as a non-root user with sudo privileges and that a basic firewall is set up. Refer to our guide on Initial Server Setup with AlmaLinux 9 for assistance.

Next, you must have Apache installed on your server. For this purpose, you can follow this guide on Install Apache Web Server on AlmaLinux 9.

You also need PHP installed on your server. To do this, you can follow our guide on How To Install PHP 8.2 on AlmaLinux 9.

Finally, disable SELinux by following this guide: How To Disable SELinux on AlmaLinux.

Once these prerequisites are fulfilled, proceed with the following steps to Install Nagios Monitoring Tool on AlmaLinux 9.

2. Install Required Packages For Nagios on AlmaLinux 9

Execute the following command to install the necessary packages and dependencies:

sudo dnf install php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget make gettext autoconf net-snmp-utils perl-Net-SNMP postfix unzip automake -y

3. Download the Latest Release of Nagios

Navigate to the /usr/src/ directory:

cd /usr/src/

Visit the Project GitHub repository and download the latest Nagios tar.gz file using the wget command:

sudo wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.4.10/nagios-4.4.10.tar.gz

After the download completes, extract the file:

sudo tar zxf nagios-*.tar.gz

Then, change your current directory to the extracted Nagios directory:

cd nagios-4.4.10

4. Compile and Build Nagios Monitoring Tool on AlmaLinux 9

Run the configure script to check for dependencies:

sudo ./configure

Initiate the compilation process:

sudo make all

This compilation may take some time. Upon completion, you should see output similar to this:

**Output**
For more information on obtaining support for Nagios, visit
...
*************************************************************
Enjoy.

Create the Nagios user and group:

sudo make install-groups-users
**Output**
groupadd -r nagios
useradd -g nagios nagios

Add the Apache user to the Nagios group:

sudo usermod -a -G nagios apache

Install Nagios binary, CGI, and HTML files:

sudo make install
**Output**
...
*** Main program, CGIs and HTML files installed ***
...

Create the external command directory and set permissions:

sudo make install-commandmode
**Output**
*** External command directory configured ***

Install the sample Nagios configuration files:

sudo make install-config
**Output**
*** 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 web server configuration files:

sudo make install-webconf
**Output**
*** Nagios/Apache conf file installed ***

Restart Apache:

sudo systemctl restart httpd

Install a systemd unit file and configure Nagios to start on boot:

sudo make install-daemoninit
**Output**
*** Init script installed ***

5. Create an Admin User for Nagios on AlmaLinux 9

Create an admin user (e.g., nagiosadmin) to access the Nagios web interface.

Run the htpasswd command:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Enter and confirm the password for the new user:

**Output**
New password:
Re-type new password:
Adding password for user nagiosadmin

Restart Apache to apply the changes:

sudo systemctl restart httpd

6. Configure Firewall for Nagios on AlmaLinux 9

Allow traffic on HTTP and HTTPS:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https

Reload the firewall to apply the new rules:

sudo firewall-cmd --reload

7. Install Nagios Monitoring Tool Plugins on AlmaLinux 9

Navigate to the /usr/src directory:

cd /usr/src/

Download the latest version of Nagios Plugins from the project GitHub repository:

sudo wget -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.3/nagios-plugins-2.4.3.tar.gz

Extract the tar file:

sudo tar zxf nagios-plugins.tar.gz

Change to the Nagios plugins directory:

cd nagios-plugins-2.4.3

Compile and install the Nagios plugins:

sudo ./configure
sudo make
sudo make install

8. Start Nagios Service on AlmaLinux 9

Start the Nagios service:

sudo systemctl start nagios

Verify that Nagios is running:

sudo systemctl status nagios
**Output**
● nagios.service - Nagios Core 4.4.10
     Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor pr>
     Active: **active** (**running**) since Wed 2023-02-15 03:11:45 EST; 5s ago
       Docs: https://www.nagios.org/documentation
    Process: 112909 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nag>
    Process: 112910 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios>
   Main PID: 112911 (nagios)
      Tasks: 6 (limit: 23609)
     Memory: 6.1M
        CPU: 311ms
     CGroup: /system.slice/nagios.service
...

9. Access Nagios Monitoring Tool Web Interface

Access the Nagios web interface by entering your server’s IP address in your web browser followed by /nagios:

http://server-ip/nagios

Enter the nagiosadmin user credentials and click sign in:

Nagios login screen

You will be redirected to the default Nagios home page:

Nagios dashboard

You have successfully installed Nagios!

For further information, consult the Nagios Documentation page.

Conclusion

You have now successfully learned how to Install Nagios Monitoring Tool on AlmaLinux 9. Nagios Core is a valuable free tool for monitoring servers, networks, and applications on AlmaLinux 9, checking the proper functioning of services like websites, databases, and email servers. Enjoy monitoring your infrastructure!

You may also be interested in:

Install the ispmanager control panel on AlmaLinux 8

Apache Spark Installation AlmaLinux 9

Set up OpenCV Library on AlmaLinux 8

Alternatives to package cleanup old kernels on AlmaLinux

Download and install Zabbix 6.4 for AlmaLinux 9

AlmaLinux 9 Install TeamViewer

How to Install Etherpad on AlmaLinux 9

Alternative Solutions for Monitoring on AlmaLinux 9

While Nagios is a robust solution, alternative monitoring tools offer different strengths and approaches. Here are two alternatives to consider for monitoring your AlmaLinux 9 server:

1. Zabbix:

Zabbix is an enterprise-class open-source distributed monitoring solution. It is designed for monitoring the availability and performance of IT infrastructure components, including networks, servers, virtual machines, applications, and services. Zabbix offers a broader range of built-in monitoring features and a more sophisticated alerting system compared to Nagios out-of-the-box. Zabbix uses agents installed on monitored hosts to collect data, but it also supports agentless monitoring using protocols like SNMP, IPMI, and JMX.

Why choose Zabbix over Nagios?

  • Ease of use: Zabbix generally has a steeper learning curve for initial setup, but its web interface is often considered more intuitive for ongoing management and configuration than Nagios.
  • Scalability: Zabbix is designed for large-scale deployments and can handle thousands of monitored devices.
  • Built-in Features: Zabbix includes many features that require additional plugins or configuration in Nagios, such as automatic discovery, trend analysis, and capacity planning.

Example of installing Zabbix agent on AlmaLinux 9:

# Add Zabbix repository
sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm

# Install Zabbix agent
sudo dnf install zabbix-agent

# Configure Zabbix agent (edit /etc/zabbix/zabbix_agentd.conf)
# Example:
# Server=zabbix_server_ip
# ServerActive=zabbix_server_ip
# Hostname=your_almalinux_hostname

# Start Zabbix agent
sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent

2. Prometheus and Grafana:

Prometheus is an open-source systems monitoring and alerting toolkit. It excels at collecting and storing metrics as time-series data. Grafana is an open-source data visualization and monitoring suite. It works seamlessly with Prometheus to provide dashboards, graphs, and alerts based on the collected metrics. This combination is particularly well-suited for monitoring containerized environments and applications using microservices architectures. Prometheus uses a pull-based model, scraping metrics from exposed endpoints.

Why choose Prometheus and Grafana over Nagios?

  • Cloud-Native Focus: Prometheus is designed for dynamic and ephemeral environments like those found in cloud and containerized deployments.
  • Time-Series Data: Prometheus’s time-series database is optimized for storing and querying metrics, enabling advanced analysis and anomaly detection.
  • Visualization: Grafana provides powerful and flexible dashboards for visualizing metrics and creating custom alerts.

Example of installing Prometheus on AlmaLinux 9:

# Download Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.46.0/prometheus-2.46.0.linux-amd64.tar.gz

# Extract Prometheus
tar xvfz prometheus-2.46.0.linux-amd64.tar.gz

# Move Prometheus binaries
sudo mv prometheus-2.46.0.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-2.46.0.linux-amd64/promtool /usr/local/bin/

# Create Prometheus user and group
sudo groupadd prometheus
sudo useradd -g prometheus -M -r -s /bin/false prometheus

# Create directories
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus

# Move configuration file
sudo mv prometheus-2.46.0.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml

# Change ownership
sudo chown -R prometheus:prometheus /etc/prometheus
sudo chown -R prometheus:prometheus /var/lib/prometheus

# Create systemd service file ( /etc/systemd/system/prometheus.service)
# Example:
#[Unit]
#Description=Prometheus
#Wants=network-online.target
#After=network-online.target

#[Service]
#User=prometheus
#Group=prometheus
#Type=simple
#ExecStart=/usr/local/bin/prometheus 
#    --config.file=/etc/prometheus/prometheus.yml 
#    --storage.tsdb.path=/var/lib/prometheus/ 
#    --web.console.path=/usr/share/prometheus/consoles 
#    --web.console.templates=/usr/share/prometheus/console_libraries

#[Install]
#WantedBy=multi-user.target

# Enable and start Prometheus
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus

These alternative solutions offer different approaches to monitoring and may be more suitable depending on your specific requirements and infrastructure. Consider evaluating these tools to determine which best meets your needs for monitoring your AlmaLinux 9 server. Remember to properly secure your monitoring tools by implementing appropriate access controls and network security measures.

Leave a Reply

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