Creating Host groups and adding Hosts to Nagios

Today we are going to discuss on Nagios Host group creation and Host addition for the Nagios platform. The host groups provide clean grouping of the hosts. 

Creating Host Groups in Nagios

  • Create a hostgroups.cfg using the below command

vi /usr/local/nagios/etc/objects/hostgroups.cfg

  • Then add the following to the hostgroups.cfg.

define hostgroup {
         hostgroup_name NAMEOFGROUP
         alias NAMEOFGROUP alias

  • Add the entry in the Nagios.cfg file

nano /usr/local/nagios/etc/nagios.cfg

  • Then, add the below line at the end of the file


  • Finally, we need to add the servers to the host group (as below)

define host {
host_name NAMEOFHOST
hostgroups NAMEOFGROUP

  • Also, make sure to restart the nagios service – service nagios restart

Then, we will look at Host addition process

Continue reading “Creating Host groups and adding Hosts to Nagios”

On Agents (Ubuntu)

  • Install the NRPE tools – sudo apt-get install nagios-nrpe-server nagios-plugins
  • After that, need to define the Nagios server address

sudo nano /etc/nagios/nrpe.cfg

  • Then access the “allowed_hosts” section and update as appropiately [i.e: allowed_hosts=,]
  • Save and exit the changes, then restart the NRPE service

sudo systemctl restart nagios-nrpe-server

  • You may verify the NRPE service with the command – /usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

On Nagios Server

  • Once you are done with the Agents, you come back to the Nagios server. Even here, we start by installing the NRPE – sudo apt install nagios-nrpe-plugin
  • Then, access the relavent config file and enable “servers” category 

sudo nano /usr/local/nagios/etc/nagios.cfg

  • To enable cfg_dir=/usr/local/nagios/etc/servers simply uncomment the line
  • After that, we need to create custom commands for Monitoring sensors

sudo nano /usr/local/nagios/etc/objects/commands.cfg

  • In the bottom of cfg file, you may add the following (save and close to commit the changes)

define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

  • Next, we need to create a client coniguration file – sudo nano /usr/local/nagios/etc/servers/client.cfg
  • There, you may define the host systems with the required object definitions

NOTE: make sure to verify whether the used syntaxes are correct with the below command. Also please refer the Nagios official documentation

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

  • Finally, restart the nagios [sudo systemctl restart nagios] service and hopefully you should be seeing the Hosts

Open Source VPN solution for any OS/Task

As IT professionals, there are times where we need to setup reliable VPN connections without any hassle.

Recently I came across an issue where we had to carry out a cloud to cloud data center migration. The limitation was we had no option to use configure VPN connection between the cloud service providers. Almost all the network ports were closed except port 80 & 443. So to overcome the issue, we used an open source client/server based solution called “SoftEther VPN“. This VPN solution provides more security and also works fine with Windows, Linux, Mac OS X, FreeBSD and Solaris. This system will have both client/server interfaces.

SoftEther VPN Windows Server and Client Setup (How To)