Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Nagios Core on CentOS 8/RHEL 8

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to install and configure Nagios Core on CentOS 8/RHEL 8. The article is rich in content and analyzes and describes it from a professional point of view. I hope you can get something after reading this article.

Nagios is a free and open source network and alert engine that monitors a variety of devices, such as network devices and servers in the network. It supports Linux and Windows, and provides an intuitive Web interface that allows you to easily monitor network resources. After professional configuration, it can send you an email alert when the server or network device goes offline or fails.

Prerequisites for Nagios Core

Before you begin, check and make sure that the following items are available:

RHEL 8/CentOS 8 environment

The environment can be accessed through SSH

Fast and stable Internet connection

After meeting the above requirements, let's get started!

Step 1: install LAMP

In order for Nagios to work as expected, you need to install LAMP or other Web software because they will run on the browser. To do this, execute the following command:

# dnf install httpd mariadb-server php-mysqlnd php-fpm

Install-LAMP-stack-CentOS8

You need to make sure that the Apache Web server is up and running. To do this, use the following command to enable and start the Apache server:

# systemctl start httpd# systemctl enable httpd

Start-enable-httpd-centos8

Check the running status of the Apache server:

# systemctl status httpd

Check-status-httpd-centos8

Next, we need to enable and start the MariaDB server by running the following command:

# systemctl start mariadb# systemctl enable mariadb

Start-enable-MariaDB-CentOS8

To check the MariaDB status, run:

# systemctl status mariadb

Check-MariaDB-status-CentOS8

In addition, you may consider strengthening or protecting the server from unauthorized access. To protect the server, run the following command:

# mysql_secure_installation

Be sure to set a strong password for your MySQL instance. For follow-up prompts, enter "Y" and press enter.

Secure-MySQL-server-CentOS8

Step 2: install the necessary software packages

In addition to installing LAMP, you need some other software packages to install and configure Nagios correctly. Therefore, install the package as follows:

# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix

Install-requisite-packages-CentOS8

Step 3: create a Nagios user account

Next, we need to create a user account for the Nagios user. To do this, run the following command:

# adduser nagios# passwd nagios

Create-new-user-for-Nagios

Now we need to create a group for Nagios and add Nagios users to the group.

# groupadd nagiosxi

Now add Nagios users to the group:

# usermod-aG nagiosxi nagios

In addition, add the Apache user to the Nagios group:

# usermod-aG nagiosxi apache

Add-Nagios-group-user

Step 4: download and install Nagios Core

Now we can continue to install Nagios Core. The latest stable version of Nagios 4.4.5 was released on August 19, 2019. But first, download the Nagios tarball file from its official website.

To download Nagios Core, first go to the / tmp directory:

# cd / tmp

Next, download the tarball file:

# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz

Download-Nagios-CentOS8

After downloading the tarball file, extract it using the following command:

# tar-xvf nagios-4.4.5.tar.gz

Next, go to the uncompressed folder:

# cd nagios-4.4.5

Run the following commands in this order:

#. / configure-with-command-group=nagcmd# make all# make install# make install-init# make install-daemoninit# make install-config# make install-commandmode# make install-exfoliation

To configure Apache, run the following command:

# make install-webconf step 5: configure Apache Web server authentication

Next, we will set up authentication for the user nagiosadmin. Please be careful not to change the user name, otherwise, you may be asked for further configuration, which may be tedious.

To set up authentication, run the following command:

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

Configure-Apache-webserver-authentication-CentOS8

You will be prompted to enter the password of the nagiosadmin user. Enter and confirm the password as required. At the end of this tutorial, you will use this user to log in to Nagios.

For the changes to take effect, restart the Web server:

# systemctl restart httpd step 6: download and install the Nagios plug-in

Plug-ins can extend the functionality of the Nagios server. They will help you monitor a variety of services, network devices and applications. To download the tarball file for the plug-in, run the following command:

# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Next, extract the tarball file and go to the uncompressed plug-ins folder:

# tar-xvf nagios-plugins-2.2.1.tar.gz# cd nagios-plugins-2.2.1

To install the plug-in, compile the source code as follows:

#. / configure-- with-nagios-user=nagios-- with-nagios-group=nagiosxi# make# make install step 7: verify and start Nagios

After successfully installing the Nagios plug-in, verify the Nagios configuration to ensure that everything is fine and that there are no errors in the configuration:

# / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg

Verify-Nagios-settings-CentOS8

Next, start Nagios and verify its status:

# systemctl start nagios# systemctl status nagios

Start-check-status-Nagios-CentOS8

If there is a firewall in the system, use the following command to allow port "80":

# firewall-cmd-permanent-add-port=80/tcp# firewall-cmd-reload step 8: access the Nagios panel through the Web browser

To access Nagios, open the IP address of the server, as follows: http://server-ip/nagios.

A pop-up window will appear prompting for the user name and password we created in step 5. Enter credentials and click "Sign In".

Access-Nagios-via-web-browser-CentOS8

This will lead you to the Nagios panel, as shown below:

Nagios-dashboard-CentOS8

We finally successfully installed and configured Nagios Core on CentOS 8 / RHEL 8.

The above is the editor for you to share how to install and configure Nagios Core on CentOS 8/RHEL 8, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report