Different PATH environment variable per host for CheckCommand

This forum was archived to /woltlab and is now in read-only mode.
  • Hi,

    I'm trying to use the check_raid plugin. This plugin supports different storage solutions and some of my machines require StorMan from Adaptec to be installed. Because StorMan is installed to /usr/StorMan by default it's not within the PATH.

    I could add a wrapper script to the path but what is the Icinga2 solutions to this problem? There could be different CheckCommands for each env.

    Then I tried using the env attribute of CheckCommand:

    1. object CheckCommand "raid" {
    2. import "plugin-check-command"
    3. command = [ PluginDir + "/check_raid" ]
    4. if (env) {
    5. env += vars.raid_env
    6. } else {
    7. env = vars.raid_env
    8. }
    9. }

    The if/else is required because env may not be initialized.

    1. apply Service "raid" {
    2. import "generic-service"
    3. check_command = "raid"
    4. command_endpoint = host.vars.client_endpoint
    5. assign where host.vars.raid
    6. }

    1. object Host "some.host.name" {
    2. import "satellite-host"
    3. check_command = "cluster-zone"
    4. vars.raid = true
    5. vars.raid_path = "/usr/StorMan"
    6. }

    The env does not seem to be forwarded to the satellite.

    Is there a better way to have the CheckCommand called like this:

    PATH=/usr/StorMan /usr/lib/navios/plugins/check_raid

    Thanks for you help!

  • Thanks for your help. Using a symlnk is easy enough.

    What do you mean by "weird"? I wanted to be able to set any env var by host and the env attribute looked like a dictionary.

  • You create services for hosts that have host.vars.raid set.

    In the Service you set command_endpoint = host.vars.client_endpoint but vars.client_endpoint is not set in the shown host object.

    In the Check_Command you use vars.raid_env, but where does that come from ?

    According to the docs, you would need something like

    1. env.PATH = "$existing_path_wherever_it_may_come_from$:$individual_path$"

    But how to get the machines current path in question ?

    As you can see, there are a few quircks with your idea - or i did not follow you carefully enough.

  • I used two different hosts to test this and I took the wrong host definition. The definition I wanted to show had a definition like

    1. object Host "some.host.name" {
    2. ...
    3. vars.raid_path = { "PATH" = "/some/path" }
    4. ...
    5. }

    while the corresponding command looked like this when I tried the solution from my first post:

    1. object CheckCommand "raid" {
    2. ...
    3. env.PATH = "$raid_path$"
    4. ...
    5. }

    My problem with this solution is related to what you said before. You can only override the PATH variable. So if you don't have the variable in your template the variable resolves to "" and clears the PATH.

    To solve my problem (check_raid not able to find arcconf) overriding the path with a single value had been enough.

    If you wanted to extend the PATH variable this would have to be a feature of Icinga2.