Hello Readers, In this blog, we’ll learn about Nagios which is an open-source monitoring system for computer systems. also its features, architecture as well, and how we can install Nagios on ubuntu.
What is Nagios?
Nagios monitors your entire IT infrastructure to ensure systems, applications, services,, and business processes are working properly.
Nagios Features:
- Scalable, Managable and Secure
- Good logs and database system
- Automatically sends alert
- Detects network errors and server crashes
- Monitor BP and IT infrastructure with a single pass
Nagios Aechitecture:
- Nagios is built on a server/agents architecture
- Usually, on a netwotk , a nagios server is running on a host, and plugins interact with local and all the remote hosts that need to be monitored.
- These plugins will send information to the scheduler, which displays that in GUI.
Monitoring Remote linux hosts:
Now we’re gonna talk about NPRE which is Nagios Plugin Remote Executor, which is basically used for monitoring remote Linux or UNIX machines.
So it’ll allow you to execute Nagios plugins on those remote machines.
Now the main reason for doing this is to allow Nagios to monitor local resources like CPU logs, memory usage, etc on remote machines.
since these public resources are not usually exposed to external machines so agents like NRPE must be installed on the remote Linux.
Installation:
update the system
sudo apt update
Now install packages requirement by Nagios:
sudo apt install -y autoconf bc gawk dc build-essential gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev libmcrypt-dev make libssl-dev snmp libnet-snmp-perl gettext
the above command will install package dependencies for the Nagios server.
create a nagios directory and got to it. For instance,
mkdir nagios && cd nagios
download Nagios from nagios official site.
sudo wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
sudo tar -xvf nagios-4.4.6.tar.gz
cd nagios-4.4.6
Similarly, compile Nagios source code and define the Apache virtual host configuration for Nagios
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
now create the Nagios user and group and add the www-data Apache user to the Nagios group.
sudo make install-groups-users
sudo usermod -a -G nagios www-data
Similarly, install Nagios binaries, service daemon script, and the command mode
sudo make install
install the init script in /lib/systemd/system
sudo make install-init
installs and configure permission on the directory for holding the external command file.
sudo make install-commandmode
install sample config file in /usr/local/nagios/etc
sudo make install-config
sudo make install-webconf
sudo apt update &&
sudo apt reinstall apache2 libapache2-mod-wsgi
and then edit .bashrc and add PATH=”/usr/sbin:$PATH” , save and close
source .bashrc
sudo a2enmode rewrite cgi
After that creates a new apache basic authentication for user “nagiosadmin”
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cd .. && sudo apt install monitoring-plugins nagios-nrpe-plugin -y
cd /usr/local/nagios/etc
sudo vi nagios.cfg
uncomment line 51,52,53,54 to define the directory for storing all server hosts configuration.
Therefore, create new folders called servers, printers, switches, routers for storing all server hosts configuration.
sudo mkdir servers printers switches routers
sudo vi resource.cfg
After that, go to line 25, comment on it, and add the below content:
$USER1$=/usr/lib/nagios/plugins
cd objects
sudo vi contacts.cfg
and add your email
sudo vi commands.cfg
and add the below code at the end of the file
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
However,if ufw isn’t running on your system
sudo ufw enable
sudo ufw status
sudo ufw allow apache
sudo ufw status
sudo ufw reload
restart apache and nagios service
sudo systemctl restart apache2
sudo systemctl restart nagios
Similarly, enable apache and nagios services to autostart boot time.
sudo systemctl enable apache2
sudo systemctl enable nagios
sudo systemctl status apache2
sudo systemctl status nagios
ifconfig
http://<your ip>/nagios
After that goes to the browser and enter the username and password.
Conclusion:
In conclusion, we’ve learned about what is Nagios monitoring tool and how we can set up this and you may check our other monitoring tools which is helpful.

Thanks for sharing!
One question, can we configure it to monitor a webservice (or any other service) in another server?