Director Automation - sync rule - Import services

Hi,

Can someone walk me through this data import. I have hosts in Icinga. All have default service hostalive and this is working.

But i need to automaticly add a large number of services to these hosts. Either One service to one host (1-1). Or some smarter way since some of the services have the same command. These can be matched with “host_name” the variable below. I now want to import services via Director Automation. This is my current input file:

services.csv:

“host_name”;“display_name”;“check_command”
“t3333”;“A big check of things”;“check_nrpe!check_thisandthat -a BANANA”
“t2222”;“A big check of things”;“check_nrpe!check_thisandthat -a BANANA”
“t3333”;“A big check of things”;“check_nrpe!check_thisandthat -a KIWI”
etc etc…

This input file can be enriched, splitted or modified any way needed.

Could you point me in the direction of what is needed here. Im guessing i start with a Import source for this, wich works. Then a Sync Rule for object type: service. But how should the sync rule be configured?

Thanks for any help
Gustav


Loaded Modules
businessprocess 2.5.1 Configure
icingadb 1.1.2 Configure
cube 1.3.3 Configure
director 1.11.1 Configure
fileshipper 1.2.0 Configure
grafana 2.0.3 Configure
incubator 0.22.0 Configure
pdfexport 0.11.0 Configure
reporting 1.0.2 Configure
toplevelview 1.0.0 Configure

Hi @Gustav,
You are on the right way :slight_smile:
In the “Sync Rule”, under the “Properties” Tab you have to create some Properties. Since you are effectively creating a Service object (or many) you need at least a object_name (name of the created Service), a check_command (theoratically at least, practically use “Inheritance (Import)” and import a Service template of your choosing) and the targeted Host (host field).
In each “Property” you map a column of your input (or a hard coded value) to a part of the Service object.

Since the check_command in Icinga2 is different than in Nagios you have to split the check_command in your CSV at the ! to get the first part ( which is the CheckCommand in Icinga2 speak) and the arguments which have to be assigned somewhat differently.

I hope this helps somewhat. Keep us updated on the journey :slight_smile:

Thanks Lorenz for the answer. My sync rule looks like this for object Service now:

Its syncing without errors.

Well i think i might be close, but I cannot get the arguments right. There seems to be an extra ‘-a’ sneaked in in the command:
image

Its not from vars.nrpe_arguments

I suspect the ‘-a’ got stuck somewhere in icinga from my frantic trial and error work earlier. :brain:

But I thought I deleated everything I created when testing actually. :man_shrugging:

This seems to disturb the nagios command, so the output just presents some default nagios version text.
image

I didn’t use NRPE lately so I am little bit rusty there.
I think there is a small misconception here about how Icinga2 works. In Nagiso (AFAIK) you defined the whole Command manually check_nrpe -a $ARG1$... , where Icinga2 abstracts the whole thing to a CheckCommand and the CheckCommandArguments, meaning basically that the arguments can generated in a more flexible way.

The variable nrpe_arguments (which you correctly found) is not "all the things after check_nrpe, but “The values to pass to the ‘-a’ argument of check_nrpe”.
So, the easy fix might be to remove -a from the CSV :slight_smile: