đAdd a New Host For Monitoring Nagios (WebServer)
Configuration
WebServer
Install Prerequirement
apt update
apt install -y autoconf gcc libmcrypt-dev make libssl-dev dc build-essential gettext libdbd-mysql-perl
Download Source
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.4.6.tar.gz
tar zxf nagios-plugins.tar.gz
Install and compile
cd nagios-plugins-release-2.4.6/
./tools/setup
./configure
make
make install
Install NRPE Daemon on Agent
apt install -y autoconf automake gcc libc6 libmcrypt-dev make libssl-dev
Download NRPE (nrpe-4.1.0)
cd /tmp
wget --no-check-certificate -O nagios-nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.1.0/nrpe-4.1.0.tar.gz
tar zxf nagios-nrpe.tar.gz
Configure script and compile NRPE
cd nrpe-4.1.0/
./configure --enable-command-args
sudo make all
sudo make install-groups-users
sudo make install
sudo make install-config
sudo make install-init
Update Agent NRPE Configuration\
nano /usr/local/nagios/etc/nrpe.cfg
line 61 : add ip 0.0.0.0 line 106 : add the NMS Nagios private server ip line 306 : add the script
## check_nrpe script for Web-Instance.
command[check_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
command[check_ping]=/usr/local/nagios/libexec/check_ping -H <ip-private-host> -w 100.0,20% -c 500.0,60% -p 5
command[check_ssh]=/usr/local/nagios/libexec/check_ssh -4 <ip-private-host>
command[check_http]=/usr/local/nagios/libexec/check_http <ip-private-host>
command[check_apt]=/usr/local/nagios/libexec/check_apt
Start service NRPE
systemctl start nrpe.service
systemctl enable nrpe.service
systemctl status nrpe.service
NMS-Nagios
Check Target Connection
To see if check_nrpe on the Nagios server can connect to the NRPE agent on the remote host, run the following command on the Nagios Server.
/usr/local/nagios/libexec/check_nrpe -H <ip-private-host>
Create 2 New Files
cd /usr/local/nagios/etc
sudo touch hosts.cfg services.cfg
Edit File nagios.cfg
nano /usr/local/nagios/etc/nagios.cfg
# Define for host and service monitoring agent
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
Add the script above in lines 46-48
Edit file hosts.cfg
nano /usr/local/nagios/etc/hosts.cfg
## Default Linux Host Template ##
define host{
name linux-box ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0
}
## Define Host - Web Instance
define host{
use linux-box ; Inherit default values from a template
host_name <instance-name> ; The name we're giving to this server
alias debian ; A longer name for the server
address <ip-priv-webserver> ; IP address of Remote Linux host
}
Instance-Name = webserver ip-priv-webserver = 10.10.1.141
Edit File services.cfg
nano /usr/local/nagios/etc/services.cfg
define service{
use generic-service
host_name <instance-name>
service_description Root
check_command check_nrpe!check_root
}
define service{
use generic-service
host_name <instance-name>
service_description APT
check_command check_nrpe!check_apt
}
define service{
use generic-service
host_name <instance-name>
service_description CPU Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name <instance-name>
service_description Total Processes
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name <instance-name>
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name <instance-name>
service_description SSH Monitoring
check_command check_nrpe!check_ssh
}
## Script to check the status of the Web Server (HTTP Service)
define service{
use generic-service
host_name <instance-name>
service_description HTTP
check_command check_nrpe!check_http
}
Instance-Name = webserver
Check the Nagios configuration
Check the Nagios configuration file to see if there are errors.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Restart Service Nagios
systemctl restart nagios.service
Configuration is Completed
Open Browser
http://<ip-addr-pub-nagios>/nagios
username : nagiosadmin
password : nagiosadmin

PreviousInstall Nagios For Monitoring With a New EC2 InstanceNextAdd a New Host For Monitoring Nagios (DB-Instance)
Last updated