In recent months many enterprise customers have asked me for a solution to create services on their monitored Icinga hosts automatically. They want a single point of insertion (like a list) for all services on the host as well as for the NetEye system to do all the work managing their creation and deletion.
IDEA: We can use the custom variables and properties defined on a Host Object and use their values together with the Director Automation feature to manage services’ lifetimes.
The Director Automation module works with the Import Source and Sync Rule feature, which allows fetching data from various data sources (internal/external), manipulating it, and then performing actions (create/modify/delete) on any Icinga Objects.
A simple example of applying this use case is the automatic monitoring of specific running services or processes on a Windows or Linux host. To reach our goal we divide the problem into 3 steps:
First of all, we need to create the variables that the user can populate as properties of the Host Object, taking into consideration the elements necessary for the creation of the service.
The main elements are:
We can use the SQL Import source directly on Director DB to extract all the instances from the variables “automatic_*_list” and the related Host OS that we populated in the step before.
The last main step is to create the Sync Rules, which are related to the Import Sources above, in order to automatically manage all the services on each host object. The most important thing is to correctly choose the Import Template that will be used for monitoring the service.
The properties needed for the service are:
host_os=linuxthen apply the template that checks Linux services, or if
host_os=windowsthen apply the template that checks Windows services)
purgeset to YES, so that when the variable values on Host Object change the service, it’s modified accordingly.
Now when running the Import Sources and the Sync Rules, services are automatically created in Director. The Director’s activity log shows precisely what changes are waiting to be deployed to Icinga. Clicking on each element displays an exact diff of the old and new configurations. Thus the user always has control over the infrastructure impact of Rules.
If all seems good, we just need to deploy the configuration to Icinga and all our services will be automatically monitored.
This approach can be extended to multiple use cases, for example to monitor different disk partitions on hosts, or to monitor the multiple interfaces on a network switch (very useful).
To make the automation even more automatic, you can schedule the Job to run every
X minutes via Import and Sync.