Create command from bash script

Hello, I am trying to create a command for chrony check (check_ntp), for that I go to Icinga Director and create the command like this:

  CheckCommand object "check_chrony" {
       import "plugin-check-command"
       command = [PluginDir + "/"]
       arguments + = {
           "-c" = {
               order = 4
               required = true
               value = "$ ntp_critical $"
           "-w" = {
               order = 2
               skip_key = true
               value = "$ ntp_warning $"

The service template defined it like this:

    template Service "check_chrony_svc" {
        import "director-generic-service"

        check_command = "check_chrony"
        check_period = "Always"
        command_endpoint = host_name

I added it under host templates later.

I am having two themes to use it:
1 - I am getting an alert with “Info: Error: Non-optional macro ‘ntp_critical’ used in argument ‘-c’ is missing.” From here I cannot realize what I am doing wrong, nor do I understand well where to take the variables “ntp_critical” and “ntp_warning” that have the same name as those of a check_ntp_time that I used without defining anything, it was already in "external commands "
2 - After defining a variable in Icinga Director - Define Data Fields, I cannot see it to use it in “Service apply rules”, in this case it is a “using_chrony” variable, to identify the hosts that use chrony instead of ntpd.
I appreciate the help you can give me either by guiding me or by indicating where I find the documentation to understand that since I have been reading something but I am confused.

Not sure if that is working too:

value = "$ ntp_critical $"

value = "$ntp_critical$"

Also you need to define the default value somewhere, If you want to edit variables inside a service template you need to create a field inside the command deiniftion or directly with “Define Data Fields” button. If you use the second approach, you need to add the field to your service template.

1 Like

Tks for the response.
Space is formed here by assigning bash format.
In the icinga director configuration has not spaces.


you have in your defined the -c as required, but you dont set the variable in your service definition or in your command definition.

Add this tou your service and everything should be fine.

   vars.ntp_critical = "whateveryouneedforyourplugin"

Replace that whatever… with a value the plugin expects.


1 Like

This solved my problem \ # 1. Tks
Now I need to be able to set a variable to true for specific hosts, and then be able to use this in a service application rule.
Can you help me with this?

In order to leave here what I did to solve my problem, what I did was in the Linux host template, add the variable, in this way to each host that is applied inherits the variable and in this way the “apply rule” is applied correspondent.