Easy relation of basic icinga2 monitoring components

a scheme of relation from plugin to command to a template and to service in icinga2 monitoring system

During Icinga Fundamental Training, we in dexor often get the question “Yes, that’s all clear, but can you briefly explain again what a command, a service template, a service, etc. is?”. This is a short memo of basic icinga2 monitoring system terminology with simple explanations. For the precise definition please refer to the official documentation of icinga2

Plugin

A plugin is a piece of software on the host where the check must be executed. It is an executable file – a script or a binary file that can be run with some flags and arguments to get the check result. A plugin is not a part of icinga2. There are some plugins in the package “monitoring plugins”. Moreover, one may use plugins for another monitoring system, such as Nagios, or it is possible to create own plugins (in the best case using the guidelines)

Command

A command is a definition of the plugin for icinga2 monitoring system. It has, in the best case, the information of how the plugin (a piece of software on the host) can be executed. A command has information on which keys might be applied, which default values will be used, which macros it uses, and in which order the arguments and flags must appear. It also may have the location path of the plugin on the machine. 

Service Template

A service template is a way in which the command is to be used. A single command can be used for monitoring different services. For example, the ” http ” command of the check_http plugin can check HTTP or HTTPS web pages from the monitoring plugins. It can also check the expiry date of the SSL certificate or examine the content of the page. For all these cases, we can define different service templates. So we can create a service template and specify the command arguments, their order and values using variables. This is how we define the way we use commands for our checks in the icinga2 monitoring system.

Service

A service – is a binding of a service template to a particular host. After we define the way the command will be used – we must specify to which host it will be applied. There are three ways how we can bind service templates to hosts:

  1. Single Service – create a service and specify the exact host we want to bind the service template to.
  2. Apply Rule – by the creation of a set of conditions, we will identify the hosts we will bind our service template to.
  3. Service set – we will create a bundle of service templates, and by the creation of a set of conditions, we will identify the hosts we will bind the entire bundle of service templates.

These three ways simply represent different relations between service templates and hosts. A Single Service is a one-to-one relation, apply rule – one-to-many, and service set is many-to-many. It is worth noting that in the case of single-service – we will create a service itself. Two other options – are the only rules for the creation of the objects. icinga2 will create the service objects (as if you would do that directly) under the hood for you.


” A Single Service is a one-to-one relation, apply rule – one-to-many, and service set is a many-to-many relation”

icinga2 trainer about relativity

Check source

An important aspect of the whole story – is where the plugin must be executed. You probably noticed, that in the description of the term Service, we said – “we bind the host and service template” – not “we will run the command on that host”. This is done because in icinga2 we have plugins that we want to run locally and plugins which we want to run remotely. This is the task of us to identify how we want to use the particular plugin.

For example plugin check_load – must be executed locally – it cannot connect somehow to the remote machine. In its turn, the plugin check_mysql may use the network, or connect to the MySQL locally using localhost. The way the interaction will be performed is better to define in the service template. We simply must think about it when we define a service template, and ensure that the piece of software (plugin) is located on the machine icinga2 will execute it on.

Long story short

A Plugin is a piece of software. Command – is the description of how this piece of software can be used. Service template – is the way the command is intended to be used. Service – is specifying where the command will be executed, in the way defined in the service template.

Leave a Reply

Your email address will not be published.