Icinga2 Configuration: Adding Hosts and Services

Once we installed Nagios Plugins, we have many plugins available in /usr/local/nagios/plugins directory.

We will create a command based on those available plugins or we can create our own plugin. Create a command in commands.conf file.

See a sample command below.

// commands.conf

// Tomact Service check command

object CheckCommand "Tomcat_App" {

import "plugin-check-command"

command = [PluginDir + "/check_tcp"]

arguments = {

"-p" = "$tcp_port$"

"-H" = "$tcp_address$"



Create a Service:

Now we can define a service associated to the command “Tomcat_App”

apply Service "Tomcat_App" {

check_command = "Tomcat_App"

assign where host.vars.app_type == "Tomcat"


Add service to host:

Add our desired host configuration inside the hosts.conf file. Below you see a sample host configuration.

object Host "Server-1-Tomcat-Service" {

// import host template. We created our custom template and not using generic host template

// import "generic-host"

import "tomcat-server-host"

// associated command

check_command = "Tomcat_App"

// host IPV4 address

address = ""

// virtual host information

vars.http_vhosts["Tomcat app running on port 9080"] = {

// applicatin port

http_port = 9080

// URI of the virtual host

http_uri = "/elogadmin"


// custome variables

vars.host_group = "MyApp"

vars.app_type = "Tomcat"


Now we have done our configuration to monitor an application running on tomcat server. Now you need to restart the Icinga2 server.

# service icinga2 restart

Sé el primero en comentar

Dejar una contestacion

Tu dirección de correo electrónico no será publicada.