How to Add Linux Host to Nagios

In the previous article, we already install Nagios application on our server. Now we will add the Linux host to be monitored in Nagios with IP host is 192.168.56.102 and its hostname is ngoprek. I use OS CentOS for Nagios Server. In Nagios, there are important files related to monitoring and user notifications that must be known by System Administrator that can be seen in the diagram below:

add host
To configure Nagios to monitor other hosts, we must configure nagios.cfg file in the folder /usr/local/nagios/etc/. Add below script in the file:

Next, we add new file ngoprek.cfg in the folder /usr/local/nagios/etc/objects/ and insert below scripts:

# Define a host for the local machine

define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name ngoprek
alias ngoprek
address 192.168.56.102
}

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
use generic-service ; Name of service template to use
host_name ngoprek
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}

# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
use generic-service ; Name of service template to use
host_name ngoprek
service_description HTTP
check_command check_http
notifications_enabled 0
}

# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 processes.

define service{
use generic-service ; Name of service template to use
host_name ngoprek
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}

# Define a service to check the load on the local machine.

define service{
use generic-service ; Name of service template to use
host_name ngoprek
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}

After that, type these commands and make sure there is no error:

Open the browser and the new host should be monitored on Nagios.
add linux host

Reference:
the-tech-tutorial.com

Leave a Reply

Your email address will not be published. Required fields are marked *