Create a check walktrough with director

this has surely been asked many times but I cant find a complete walkthrough from command to deployment.
I try to achieve a IDE SMART check on a remote host. icinga is running on a monitoring server and on the target host the agent is running. I established “built-in” checks on APT, disk, load, disk space.

Now I want to check SMART. So I found the plugin check_ide_smart on the host. I can run it on /dev/sda as root returning OK.

Next I create a command C SMART DISK as “Icinga Check Command”, path: PluginDir + “check_ide_smart”, then I added an argument “-d” as mandatory.

Then, I created a service template ST SMART DISK, the check commando is: “C SMART DISK”. I checked execute on agent and setup some timeouts, etc.

Now I create a service: S SMART Disk and reference to the template ST SMART Disk and reference it to a host template vmHostTemplate. Nothing else.
The target host is based on the vmHostTemplate.

I wonder now why I nowhere can set my created argument?
And: the result is funny. Deploying the config results in another check but the check returns:
Icinga 2 has been running for 3 hours, 3 minutes and 13 seconds. Version: r2.11.2-1

Is this the correct procedure?
Where can I set the argument because I have several disks on the target host?
Why does my check return the strange result on icinga?
Where can I follow/debug/see what is going? There is no reference to “ide” on the log of the monitor. There is no log on the target host.

Best regards

Hi and welcome.

Please share the configuration of

  • your command
  • your service template
  • your service

Basically, yes

You need to add the field for the argument to either the command or the service template to be able to fill something in and give it to the argument.

The Director provides an “Inspect” link on the details page of the host/service, if you click on that the executed command land can be seen.

Here is my configuration:

object CheckCommand “C SMART Disk”
import "[icinga-check-command]
command = [ PluginDir + “check_ide_smart” ]
arguments +=
“-d” = { description = “Device to be checked” required = true }

Service template:

template Service “ST SMART Disk”
check_command = “[C SMART Disk]”
max_check_attempts = “3”
check_interval = 5m
retry_interval = 1m
check_timeout = 30s
enable_active_checks = true
enable_passive_checks = true
command_endpoint = host_name


apply Service “S SMART Disk” {
import "[ST SMART Disk]
assign where “vmHostTemplate” in host.templates
import DirectorOverrideTemplate

I can apply “inspect” only to the host. There is only one check_command mentioned, this is hostalive.
I will tried to add fields to complete the agrument.

I added now a field smart_device and populated it in the service object.
It did not change the output.
At the core: Why do I get a check result that has nothing to do with my check?

You need to add the field to the command config and set it as the value of your -d argument.


object CheckCommand "haproxy_state" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_haproxy.rb" ]
    timeout = 1m
    arguments += {
        "-P" = {
            required = true
            value = "$haproxy_password$"
        "-U" = {
            required = true
            value = "$haproxy_user$"
        "-c" = {
            required = false
            value = "$haproxy_critical$"
        "-u" = {
            required = true
            value = "$haproxy_url$"
        "-w" = {
            required = false
            value = "$haproxy_warning$"

Looks like this in the Director:

Because you are overriding the check command somewhere. Did you import multiple templates anywhere?

also please take a look at this guide for post formatting :slight_smile:

Code snippets with some indentations and some highlighting are much easier to read :slight_smile:

Because you are overriding the check command somewhere

That was a valuable comment. I chose “Icinga check command”, not “Plugin check command”. After changing that I had a progress.

Now, the check returns “Device smart_device could not be opened”. smart_device is my argument. In the check details is a section “custom variables (Angepasste Variablen in German)” Smart Device /dev/sda.
Whereever I look I call it smart_device. So where does “Smart Device” come from?

Thank you for the link to formatting. I thought I can only choose from the menu band.

good catch :)!

Sounds like you have a variable smart_device now, but it is not (correctly) connected to the command.
Take a look at my screeshots/config snippets from the previous post and compare it to your setup.

In case you can’t figure it out, please show your updated configs again:)

  • check command
  • service template
  • service apply

I got it now, almost. I deleted the chain command>service template>service and set it up from scratch.
Now I dont have enough access rights to the smart tool on the client.
I guess it is a common thing: agent runs as nagios and requires root rights.
It works when I set the sticky bit on the check. Is this best practice?