Contents
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
|
1 2 |
# apt update # apt install autoconf gcc libc6 make wget unzip libgd-dev |
2. Installing Nagios Core
①Download
|
1 |
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.5.10.tar.gz |
②Install
|
1 2 3 4 5 |
# apt install libssl-dev # tar zxvf nagios-4.5.10.tar.gz # cd nagios-4.5.10 # ./configure |
It appears as follows
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
*** Configuration summary for nagios 4.5.10 2025-10-28 ***: 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/apache2/sites-available Mail program: /usr/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
|
1 |
# make all |
It appears as follows
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
*** 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: https://library.nagios.com 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: https://support.nagios.com ************************************************************* Enjoy. |
Create Nagios Users and Groups
|
1 2 3 |
# make install-groups-users groupadd -r nagios useradd -g nagios nagios |
Add Apache User to Nagios Group
|
1 |
# usermod -aG nagios www-data |
Install Nagios Core
|
1 |
# make install |
Install Nagios init script
|
1 2 3 |
# make install-init /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 |
Install external command files and permissions
|
1 2 3 4 5 6 |
# 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 Nagios Configuration Files
|
1 2 3 4 5 6 |
# make install-config *** 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 Apache configuration files for Nagios
|
1 2 3 4 5 6 7 |
# make install-webconf /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf if [ 1 -eq 1 ]; then \ ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \ fi *** Nagios/Apache conf file installed *** |
|
1 2 |
# a2enmod cgi # systemctl restart apache2 |
3. Install Nagios Plugin
①Download the latest code from the Nagios Plugins page
|
1 |
# wget https://nagios-plugins.org/download/nagios-plugins-2.4.9.tar.gz |
②Install
|
1 2 3 4 5 |
# tar -xvf nagios-plugins-2.4.9.tar.gz # cd nagios-plugins-2.4.9 # ./configure --with-nagios-user=nagios --with-nagios-group=nagios # make # make install |
The following nagios-plugins are available:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# ls /usr/local/nagios/libexec check_apt check_ftp check_mrtgtraf check_procs check_udp check_breeze check_http check_nagios check_real check_ups check_by_ssh check_icmp check_nntp check_rpc check_uptime check_clamd check_ide_smart check_nntps check_sensors check_users check_cluster check_ifoperstatus check_nt check_simap check_wave check_dhcp check_ifstatus check_ntp check_smtp negate check_dig check_imap check_ntp_peer check_spop remove_perfdata check_disk check_ircd check_ntp_time check_ssh urlize check_disk_smb check_jabber check_nwstat check_ssl_validity utils.pm check_dns check_load check_oracle check_ssmtp utils.sh check_dummy check_log check_overcr check_swap check_file_age check_mailq check_ping check_tcp check_flexlm check_mrtg check_pop check_time |
③Create necessary directories
|
1 2 |
# mkdir -p /usr/local/nagios/var/spool/checkresults # chown -R nagios:nagios /usr/local/nagios/var/spool/checkresults |
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.
|
1 2 3 4 |
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: [password] Re-type new password: [again password] Adding password for user nagiosadmin |
Set ownership and permissions
|
1 2 |
# chown www-data:www-data /usr/local/nagios/etc/htpasswd.users # chmod 640 /usr/local/nagios/etc/htpasswd.users |
Restart Apache
|
1 |
# systemctl restart apache2 |
Allow HTTP service port in firewall
|
1 2 |
# ufw allow http # ufw reload |
Start and Enable Nagios Services
|
1 2 |
# systemctl enable nagios --now Created symlink /etc/systemd/system/multi-user.target.wants/nagios.service → /lib/systemd/system/nagios.service. |
Reboot system
|
1 |
# shutdown -r now |
Confirmation of service execution
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# systemctl status nagios ● nagios.service - Nagios Core 4.5.10 Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; preset: enabled) Active: active (running) since Tue 2026-01-13 14:25:49 JST; 37s ago Invocation: 454bfc9ed3214e1c828e54e0d6102e67 Docs: https://www.nagios.org/documentation Process: 1108 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS) Process: 1160 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS) Main PID: 1199 (nagios) Tasks: 6 (limit: 3911) Memory: 6.4M (peak: 7.2M) CPU: 72ms CGroup: /system.slice/nagios.service ├─1199 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg ├─1286 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1287 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1288 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1289 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh └─1304 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg Jan 13 14:25:49 Lepard nagios[1199]: qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized Jan 13 14:25:49 Lepard nagios[1199]: qh: core query handler registered Jan 13 14:25:49 Lepard nagios[1199]: qh: echo service query handler registered Jan 13 14:25:49 Lepard nagios[1199]: qh: help for the query handler registered Jan 13 14:25:49 Lepard nagios[1199]: wproc: Successfully registered manager as @wproc with query handler Jan 13 14:25:49 Lepard nagios[1199]: wproc: Registry request: name=Core Worker 1286;pid=1286 Jan 13 14:25:49 Lepard nagios[1199]: wproc: Registry request: name=Core Worker 1287;pid=1287 Jan 13 14:25:49 Lepard nagios[1199]: wproc: Registry request: name=Core Worker 1288;pid=1288 Jan 13 14:25:49 Lepard nagios[1199]: wproc: Registry request: name=Core Worker 1289;pid=1289 Jan 13 14:25:49 Lepard nagios[1199]: Successfully launched command file worker with pid 1304 |
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
[Log 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. Nagios Agent Configuration
To monitor the agent. Install the following
• NRPE Agent to run plugins
6.1 Installing Nagios NRPE Agent
NRPE agent available in default Ubuntu repository
|
1 2 3 4 5 6 7 |
# apt-cache policy nagios-nrpe-server nagios-nrpe-server: Installed: (none) Candidate: 4.1.3-1ubuntu1 Version table: 4.1.3-1ubuntu1 500 500 http://jp.archive.ubuntu.com/ubuntu questing/universe amd64 Packages |
|
1 |
# apt install nagios-nrpe-server |
Version Check
|
1 2 3 |
# nrpe -V NRPE - Nagios Remote Plugin Executor Version: 4.1.3 |
Start and activate the service
|
1 2 3 4 |
# systemctl enable --now nagios-nrpe-server Synchronizing state of nagios-nrpe-server.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable nagios-nrpe-server |
Check the status of the NRPE agent
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# systemctl status nagios-nrpe-server ● nagios-nrpe-server.service - Nagios Remote Plugin Executor Loaded: loaded (/usr/lib/systemd/system/nagios-nrpe-server.service; enabled; preset: enabled) Active: active (running) since Mon 2025-11-24 09:26:30 JST; 46s ago Invocation: 989a85dc230a4cfdac616d6f9a8641bf Docs: http://www.nagios.org/documentation Main PID: 2056 (nrpe) Tasks: 1 (limit: 4595) Memory: 1.4M (peak: 1.8M) CPU: 13ms CGroup: /system.slice/nagios-nrpe-server.service └─2056 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f Nov 24 09:26:30 Lepard systemd[1]: Started nagios-nrpe-server.service - Nagios Remote Plugin Executor. Nov 24 09:26:30 Lepard (nrpe)[2056]: nagios-nrpe-server.service: Referenced but unset environment variable evaluates to an empty string: NRPE_OPTS Nov 24 09:26:30 Lepard nrpe[2056]: Starting up daemon Nov 24 09:26:30 Lepard nrpe[2056]: Server listening on 0.0.0.0 port 5666. Nov 24 09:26:30 Lepard nrpe[2056]: Server listening on :: port 5666. Nov 24 09:26:30 Lepard nrpe[2056]: Listening for connections on port 5666 Nov 24 09:26:30 Lepard nrpe[2056]: Allowing connections from: 127.0.0.1,::1 |
Allow services to pass through the firewall
NRPE uses TCP port 5666 by default.
|
1 2 |
# ufw allow 5666/tcp # ufw reload |
Check if port 5666/tcp is listening
|
1 2 3 4 |
# ss -altnp | grep 5666 LISTEN 0 5 0.0.0.0:5666 0.0.0.0:* users:(("nrpe",pid=21947,fd=4)) LISTEN 0 5 [::]:5666 [::]:* users:(("nrpe",pid=21947,fd=5)) |
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 : Ubuntu24.04
IP address : 192.168.11.85
7.1 Configuration File Editing
|
1 2 3 |
# vi /usr/local/nagios/etc/nagios.cfg Line 51 cfg_dir=/usr/local/nagios/etc/servers #Uncomment |
7.2 Directory Create
|
1 2 3 |
# mkdir /usr/local/nagios/etc/servers # chgrp nagios /usr/local/nagios/etc/servers # chmod 750 /usr/local/nagios/etc/servers |
7.3 Create new definition file
The name "korodes.cfg" can be arbitrary.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# vi /usr/local/nagios/etc/servers/korodes.cfg define host { use linux-server host_name korodes alias korodes address 192.168.11.85 } define service { use generic-service host_name korodes service_description PING check_command check_ping!100.0,20%!500.0,60% } |
7.4 Restart Nagios server
|
1 |
# systemctl restart nagios.service |
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 : Ubuntu24.04
IP address : 192.168.11.85
8.1 Configuration on the server to be monitored
8.1.1 Agent installed on monitored hosts
Install nrpe and typical service plugins from EPEL
|
1 |
# apt install nagios-nrpe-server |
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
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# systemctl enable nagios-nrpe-server Synchronizing state of nagios-nrpe-server.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable nagios-nrpe-server # systemctl start nagios-nrpe-server # /etc/init.d/nagios-nrpe-server status ● nagios-nrpe-server.service - Nagios Remote Plugin Executor Loaded: loaded (/usr/lib/systemd/system/nagios-nrpe-server.service; enabled; preset: enabled) Active: active (running) since Tue 2026-01-13 16:02:34 JST; 4min 10s ago Docs: http://www.nagios.org/documentation Main PID: 29269 (nrpe) Tasks: 1 (limit: 4547) Memory: 1.0M (peak: 4.2M) CPU: 17ms CGroup: /system.slice/nagios-nrpe-server.service └─29269 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f Jan 13 16:02:34 Lion systemd[1]: Started nagios-nrpe-server.service - Nagios Remote Plugin Executor. Jan 13 16:02:34 Lion (nrpe)[29269]: nagios-nrpe-server.service: Referenced but unset environment variable evaluates to an empty string: NRPE_OPTS Jan 13 16:02:34 Lion nrpe[29269]: Starting up daemon Jan 13 16:02:34 Lion nrpe[29269]: Server listening on 0.0.0.0 port 5666. Jan 13 16:02:34 Lion nrpe[29269]: Server listening on :: port 5666. Jan 13 16:02:34 Lion nrpe[29269]: Listening for connections on port 5666 Jan 13 16:02:34 Lion nrpe[29269]: Allowing connections from: 127.0.0.1,::1 |
8.1.4 Open NRPE ports 5666/tcp and 5666/udp on firewall
|
1 2 3 |
# ufw allow 5666/tcp # ufw allow 5666/udp # ufw reload |
8.2 Nagios Server Side Configuration
8.2.1 nrpe plugin installation
|
1 |
# apt install nagios-nrpe-plugin |
8.2.2 Copy to nagios plugin directory
|
1 |
# cp /usr/lib/nagios/plugins/check_nrpe /usr/local/nagios/libexec/ |
8.2.3 commands.cfg edit
|
1 2 3 4 5 6 7 |
# vi /usr/local/nagios/etc/objects/commands.cfg # Add to the last line define command { command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } |
8.2.4 Edit and add korodes.cfg created when you added the host earlier
I'll add HTTP,SSH,FTP this time.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# vi /usr/local/nagios/etc/servers/korodes.cfg # Add the following: # 'HTTP' command definition define service{ use local-service host_name korodes service_description HTTP check_command check_http } # 'SSH' command definition define service{ use local-service host_name korodes service_description SSH check_command check_ssh } # 'FTP' command definition define service{ use local-service host_name korodes service_description FTP check_command check_ftp } |
8.2.5 Restart Nagios
|
1 |
# systemctl restart nagios.service |
8.2.6 Accsess http://[Nagios Server IP Address]/nagios
Newly added monitoring services are added as shown in the figure below.

