業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

Fedora44 : Nagios Server

Nagios Server

Nagios is an open source monitoring solution running on Linux.
Nagios is designed to periodically check critical network, application, or server parameters.
These parameters include microprocessor load, number of running processes, log files, disk and memory usage, as well as many other services such as SMTP (Simple Mail Transfer Protocol), HTTP (Hypertext Transfer Protocol), POP3 (Post Office Protocol 3), etc. can be checked.

These parameters require a microprocessor load, a database such as PHP or MySQL to run Nagois, and a web server such as Apache or Nginx. We will proceed under the assumption that all of these have already been configured.

1.  Install necessary packages

2. Installing Nagios Core

①Create a Nagios user and set a password.

➁To enable the sending of external commands via the web interface, create a new group named "nagcmd". Add both the nagios user and the apache user to that group.

➂Nagios Download

④Install

It appears as follows

It appears as follows

Install Nagios Core

Install the Nagios init script

Install external command files and permissions

Install the Nagios configuration files

Edit the /usr/local/nagios/etc/objects/contacts.cfg configuration file and change the email address associated with the nagiosadmin contact definition to the address used for receiving alerts.

Install the Apache configuration file for Nagios

3. Install the Nagios plugin

Download the latest code from the Nagios Plugins page

②Install

The following nagios-plugins are available

Create necessary directories

4. Creating a Nagios Web User

Create a user account to access the Nagios Web Dashboard. This user account is used for authentication.
The default name of the user is nagiosadmin, which is defined as the preferred user name in the /usr/local/nagios/etc/cgi.cfg file.

Set ownership and permissions

Restart Apache

Allow HTTP service port in firewall

Start and Enable Nagios Services

Reboot system

Confirmation of service execution

5. Access the Nagios Web Interface

Access http://[FQDN]/nagios or http://[IP address]/nagios in any browser.
Username : nagoisadmin
Password : Password specified when the user was created above
[Sign in]

After successful login, the following dashboard will appear

Show host availability
Click on [Hosts] in the left menu

Click [Tactical Overview] on the left menu to view the monitoring data

Click [Current Status] [Services] on the left menu : The current monitoring service details are displayed.

6. Configuring the NRPE Plugin

To monitor the agent, install the following:

6.1 Install the nrpe plugin

If an SSL error occurs when running "make all"

Use the ./configure --disable-ssl flag to disable SSL in the NRPE configuration

Install the NRPE plugin daemon and sample configuration files

Install the NRPE daemon as a service

Open the /usr/local/nagios/etc/nrpe.cfg file and add the IP addresses of the local host and the Nagios monitoring server

Check Version

Start the service and enable it

Open the NRPE port in the firewall
NRPE uses TCP port 5666 by default. If you have a firewall in place, open this port to allow external checks from the Nagios monitoring server.

Check if port 5666/tcp is listening

Run the "check_nrpe" command to verify that the NRPE daemon is running properly
The version of NRPE currently installed is displayed

7. Adding a monitored host

Add the following server to the host and configure it as a target for simple ping death/activity monitoring
OS : Fedora43
IP address : 192.168.11.85

7.1 Configuration File Editing

7.2 Directory Create

7.3 Create new definition file

The name "korodes.cfg" can be arbitrary.

7.4 Restart Nagios server

Log in to the Nagios server (http://[server IP address]/nagios) and look at Hosts, and the host is added.

8. Adding Monitoring Services

Add monitoring services to the hosts added above.
OS : Fedora43
IPアドレス : 192.168.11.85

8.1Configuration on the server to be monitored

8.1.1 Agent installed on monitored hosts
Install NRPE and common service plugins

8.1.2 Configuration File Editing

# vi /etc/nagios/nrpe.cfg

Line 106 : Add a host to allow connections (specify Nagios server)
allowed_hosts=127.0.0.1,::1,192.168.11.83

Line 122 : Allow command arguments
dont_blame_nrpe=1

Line 300-304 : Comment and add
# command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
# command[check_load]=/usr/lib/nagios/plugins/check_load -r -w .15,.10,.05 -c .30,.25,.20
# command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
# command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
# command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

Add part of the plugin

command[check_by_ssh]=/usr/lib/nagios/plugins/check_by_ssh $ARG1$
command[check_dhcp]=/usr/lib/nagios/plugins/check_dhcp $ARG1$
command[check_disk]=/usr/lib/nagios/plugins/check_disk $ARG1$
command[check_file_age]=/usr/lib/nagios/plugins/check_file_age $ARG1$
command[check_ftp]=/usr/lib/nagios/plugins/check_ftp $ARG1$
command[check_http]=/usr/lib/nagios/plugins/check_http $ARG1$
command[check_imap]=/usr/lib/nagios/plugins/check_imap $ARG1$
command[check_load]=/usr/lib/nagios/plugins/check_load $ARG1$
command[check_log]=/usr/lib/nagios/plugins/check_log $ARG1$
command[check_mysql]=/usr/lib/nagios/plugins/check_mysql $ARG1$
command[check_ntp]=/usr/lib/nagios/plugins/check_ntp $ARG1$
command[check_ntp_peer]=/usr/lib/nagios/plugins/check_ntp_peer $ARG1$
command[check_ntp_time]=/usr/lib/nagios/plugins/check_ntp_time $ARG1$
command[check_ping]=/usr/lib/nagios/plugins/check_ping $ARG1$
command[check_pop]=/usr/lib/nagios/plugins/check_pop $ARG1$
command[check_spop]=/usr/lib/nagios/plugins/check_spop $ARG1$
command[check_procs]=/usr/lib/nagios/plugins/check_procs $ARG1$
command[check_smtp]=/usr/lib/nagios/plugins/check_smtp $ARG1$
command[check_ssmtp]=/usr/lib/nagios/plugins/check_ssmtp $ARG1$
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh $ARG1$
command[check_swap]=/usr/lib/nagios/plugins/check_swap $ARG1$
command[check_tcp]=/usr/lib/nagios/plugins/check_tcp $ARG1$
command[check_udp]=/usr/lib/nagios/plugins/check_udp $ARG1$
command[check_ups]=/usr/lib/nagios/plugins/check_ups $ARG1$
command[check_users]=/usr/lib/nagios/plugins/check_users $ARG1$

8.1.3 nrpe server activation and startup

8.1.4 Open NRPE ports 5666/tcp and 5666/udp on firewall

8.2 Nagios Server Side Configuration

8.2.1 commands.cfg edit

8.2.2 Edit and add korodes.cfg created when you added the host earlier
I'll add HTTP,SSH,FTP this time.

8.2.5 Restart Nagios

8.2.6 Accsess http://[Nagios Server IP Address]/nagios
Newly added monitoring services are added as shown in the figure below.

Copied title and URL