Ubuntu Server26.10 : Nagios Server

Open source integrated monitoring software "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

# apt -y install nagios4

Apache Restart

# a2enmod cgi
# systemctl restart nagios4 apache2

3. Install Nagios Plugin

①Install

# apt -y install nagios-plugins

The following nagios-plugins are available:

 # ls /usr/lib/nagios/plugins/

check_apt       check_fping         check_load         check_nwstat     check_ssh
check_breeze    check_ftp           check_log          check_oracle     check_ssmtp    
check_by_ssh    check_game          check_mailq        check_overcr     check_swap     
check_clamd     check_host          check_mrtg         check_ping       check_tcp      
check_cluster   check_hpjd          check_mrtgtraf     check_pop        check_time     
check_curl      check_http          check_mssql        check_procs      check_udp      
check_dbi       check_icmp          check_mysql        check_radius     check_ups      
check_dhcp      check_ide_smart     check_mysql_query  check_real       check_users    
check_dig       check_ifoperstatus  check_nagios       check_rpc        check_wave     
check_disk      check_ifstatus      check_nntp         check_rta_multi  negate
check_disk_smb  check_imap          check_nntps        check_sensors    urlize
check_dns       check_ircd          check_nt           check_simap      utils.pm       
check_dummy     check_jabber        check_ntp          check_smtp       utils.sh       
check_file_age  check_ldap          check_ntp_peer     check_snmp
check_flexlm    check_ldaps         check_ntp_time     check_spop

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.

# htdigest /etc/nagios4/htdigest.users "Nagios4" nagiosadmin
New password:  [password]
Re-type new password:  [again password]
Adding password for user nagiosadmin

Allow HTTP service port in firewall

# ufw allow http
# ufw reload

Start and Enable Nagios Services

# systemctl enable nagios4 --now
Created symlink '/etc/systemd/system/multi-user.target.wants/nagios4.service' → '/usr/lib/systemd/system/nagios4.service'.

Confirmation of service execution

# systemctl status nagios4

● nagios4.service - nagios4
     Loaded: loaded (/usr/lib/systemd/system/nagios4.service; enabled; preset: enabled)
     Active: active (running) since Mon 2026-10-19 13:41:43 JST; 7min ago
 Invocation: cfa131779dc9434cbd5c011aabc18f3c
       Docs: man:nagios4
    Process: 11351 ExecStartPre=sh -c nagiospipe=$$(sed -n "s/^command_file=\(.*\)/\1/p" ${NAGIOSCFG}); [ >
   Main PID: 11356 (nagios4)
      Tasks: 6 (limit: 3938)
     Memory: 2.5M (peak: 4M)
        CPU: 186ms
     CGroup: /system.slice/nagios4.service
             ├─11356 /usr/sbin/nagios4 /etc/nagios4/nagios.cfg
             ├─11357 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh
             ├─11358 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh
             ├─11359 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh
             ├─11360 /usr/sbin/nagios4 --worker /var/lib/nagios4/rw/nagios.qh
             └─11362 /usr/sbin/nagios4 /etc/nagios4/nagios.cfg

Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11357;pid=11357
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11357;pid=11357
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11358;pid=11358
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11359;pid=11359
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11360;pid=11360
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11358;pid=11358
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11359;pid=11359
Oct 19 13:41:43 Lepard nagios4[11356]: wproc: Registry request: name=Core Worker 11360;pid=11360
Oct 19 13:41:43 Lepard nagios4[11356]: Successfully launched command file worker with pid 11362
Oct 19 13:41:43 Lepard nagios4[11356]: Successfully launched command file worker with pid 11362

5. Access the Nagios Web Interface

If you go to http://[FQDN]/nagios/ or http://[IP address]/nagios4 in any browser, you will see the following dashboard.

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.

※ If you have assigned the SSH port to custom configuration 2244, change localhost.cfg as follows

# vi /etc/nagios4/objects/localhost.cfg
Per Line143:
check_command           check_ssh
↓
check_command           check_ssh!-p 2244
# systemctl restart nagios4

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

# apt-cache policy nagios-nrpe-server
nagios-nrpe-server:
  Installed: (none)
  Candidate: 4.1.3-1ubuntu3
  Version table:
     4.1.3-1ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu stonking/universe amd64 Packages
# apt install -y nagios-nrpe-server

Version Check

# nrpe -V
NRPE - Nagios Remote Plugin Executor
Version: 4.1.3

Start and activate the service

# systemctl enable --now nagios-nrpe-server

Check the status of the NRPE agent

# 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 2026-10-19 14:22:50 JST; 1min 54s ago
 Invocation: aa3f5dcbe4aa4f59a4a493eb0d3074e5
       Docs: http://www.nagios.org/documentation
   Main PID: 6213 (nrpe)
      Tasks: 1 (limit: 3938)
     Memory: 1.3M (peak: 2.2M)
        CPU: 10ms
     CGroup: /system.slice/nagios-nrpe-server.service
             └─6213 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f

Oct 19 14:22:50 Lepard systemd[1]: Started nagios-nrpe-server.service - Nagios Remote Plugin Executor.     
Oct 19 14:22:50 Lepard (nrpe)[6213]: nagios-nrpe-server.service: Referenced but unset environment variable>
Oct 19 14:22:50 Lepard nrpe[6213]: Starting up daemon
Oct 19 14:22:50 Lepard nrpe[6213]: Server listening on 0.0.0.0 port 5666.
Oct 19 14:22:50 Lepard nrpe[6213]: Server listening on :: port 5666.
Oct 19 14:22:50 Lepard nrpe[6213]: Listening for connections on port 5666
Oct 19 14:22:50 Lepard nrpe[6213]: Allowing connections from: 127.0.0.1,::1

Allow services to pass through the firewall
NRPE uses TCP port 5666 by default.

# ufw allow 5666/tcp
# ufw reload

Check if port 5666/tcp is listening

# ss -altnp | grep 5666
LISTEN 0      5            0.0.0.0:5666       0.0.0.0:*    users:(("nrpe",pid=6213,fd=4))
LISTEN 0      5               [::]:5666          [::]:*    users:(("nrpe",pid=6213,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 : Ubuntu26.10
IP address : 192.168.11.85

7.1 Configuration File Editing

# vi /etc/nagios4/nagios.cfg
Line 62 : Uncomment
cfg_dir=/etc/nagios4/servers

7.2 Directory Create

# mkdir /etc/nagios4/servers
# chgrp nagios  /etc/nagios4/servers
# chmod 750 /etc/nagios4/servers

7.3 Create new definition file

The name "korodes.cfg" can be arbitrary.

# vi /etc/nagios4/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

# systemctl restart nagios4.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 : Ubuntu26.10
IP address : 192.168.11.85

8.1 Configuration on the server to be monitored

8.1.1 Agent installed on monitored hosts

# apt install -y 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

# systemctl 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 Mon 2026-10-19 14:33:56 JST; 6min ago
 Invocation: 1337774dc6424a0c885b9947e5dadc5a
       Docs: http://www.nagios.org/documentation
   Main PID: 5491 (nrpe)
      Tasks: 1 (limit: 3939)
     Memory: 1.3M (peak: 2.2M)
        CPU: 31ms
     CGroup: /system.slice/nagios-nrpe-server.service
             mq5491 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f

Oct 19 14:33:56 Lion systemd[1]: Started nagios-nrpe-server.service - Nagios Remote Plugin Executor.
Oct 19 14:33:56 Lion (nrpe)[5491]: nagios-nrpe-server.service: Referenced but unset environment variable evaluates to an empty string: NRPE_OPTS
Oct 19 14:33:56 Lion nrpe[5491]: Starting up daemon
Oct 19 14:33:56 Lion nrpe[5491]: Server listening on 0.0.0.0 port 5666.
Oct 19 14:33:56 Lion nrpe[5491]: Server listening on :: port 5666.
Oct 19 14:33:56 Lion nrpe[5491]: Listening for connections on port 5666
Oct 19 14:33:56 Lion nrpe[5491]: Allowing connections from: 127.0.0.1,::1

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

# ufw allow 5666/tcp
# ufw allow 5666/udp
# ufw reload
8.2 Nagios Server Side Configuration

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

# vi /etc/nagios4/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.2 Restart Nagios

# systemctl restart nagios4.service

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