Arguments not reaching command

Hello everybody,
I have written a custom plugin to check ssl certificates on my nodes and now have the problem that the command and the service are defined automatically the way they should be but never receive the arguments they are supposed to be given.
The argument is in this case a list of domains that will be processed by the script, named --vhosts
The command definition is as follows:

object CheckCommand "check-certs" {
  import "generic-command"

  command = [ "/usr/bin/sudo", "/usr/lib/nagios/plugins/check_ssl_custom.sh", ]
  arguments = {
    "--vhosts" = {
      value = "$vars.vhosts$"
      description = "Array of virtual hosts"
    }
  }
}

and the corresponding service is defined as follows:

apply Service "check-certs" {
  import "generic-service"

  display_name = "SSL Certificates"
  host_name = "<FQDN>"
  check_command = "check-certs"
  command_endpoint = host.name
  vars.vhosts = [ "<vhost1", "<vhost2>", "<vhost3>", "etc." ]
  assign where host.name == "<FQDN>"
}

When I execute the plugin manually and parse arguments to it, it works the way it is supposed to, receives the arguments, outputs the status of the checked certificates etc.
If I don’t parse any arguments to the script, it still executes, but, as expected, it shows me a status error because it does not receive any input (I am very sure that it is not a permission issue, all sudoer files on all the servers have been properly edited to allow sudo execution of the command).
The status error has been configured by me in the script as a proper nagios-plugin output option.

I am using puppet to distribute the script to all nodes, but that shouldn’t matter as the configs are compiled correctly on all nodes.
I have even configured the script to print the arguments into a tmp file with this line:
echo "Received arguments: $@" >> /tmp/icinga2_plugin_debug.log
in my plugin, but apart from the "Received arguments: "-string, the file always stays empty, except for when I manually execute the script on a node via the commandline.

I don’t know where else to start debugging, it’s a mystery to me.
Since there are no errors in Icinga2, neither on the master nor on the nodes, I assume it’s not an issue with the definition of the command or the service.
The service is created and appears in Icingaweb2 as well, it just fails (meaning it has a status of “UNKOWN”).

So if you have any idea where the issue could be found, I’d be so greatful.
Thanks in advance for the input!

should be

value = “$vhosts$”

2 Likes

Thanks, that did the trick.
My plugin now works the way it should.

Thank you very much.