By_ssh command argument missing in Director

Sorry I searched the forum and found the relevant topic

But still I am posting as the screenshots are in German and I am not that comfortable with icinga to be able to relate. I am sure people like me who are trying to learn icinga on his own will face similar issue and will look for solution

I have some AIX servers which I need to monitor using icinga2. As practice I was planning to do it via ssh.

  1. I have created password less login from my icinga master to the AIX box.
  2. I have copied a script on the AIX box /usr/lib64/nagios/plugin/check_aix_cpu.pl
  3. Went to Icinga Director → Command → External Command

image

  1. Looked at the fields there is no command field

Now based on the above link posted @PinkFrog it looks like I am suppose to create a new data field by_ssh_command

Questions
A: I have no clue how to create a data field. Where in director do I go? Some english screenshots will be great.
B: Once that is done I know I have to give the full command path along with variables it takes. For example /usr/lib64/nagios/plugins/check_aix_cpu.pl -c 90 -w 80. Now this will be distributed to a host group with lot of AIX servers. I expect that I should be able to override individual servers threshold if required.
C: I do not want to run these checks from master - but rather from the satellites. Is that possible? Where do I configure that in Director? I am OK to create password less login from both satellites to the AIX box.
D: Not relevant but do we have a list of recommended plugins for AIX?

A: image

B: Check the screenshots from the other thread and fit them to your needs. E.g put /usr/lib64/nagios/plugins/check_aix_cpu.pl -c $by_ssh_crit$ -w $by_ssh_warn$ in your by_ssh_command field and add the by_ssh_warn/crit fields to you service template and put the values in there. You can then override the values for each host in its services tab.
Or you add the by_ssh_warn/crit fields to the host template and set them for each host.

C: If the host, that the check belongs to, is check by the satellite, the check will also be run by the satellite.

1 Like

Thank You very much. It worked. by_ssh_command has to be named as by_ssh_command. I tried with by_ssh_cmd and it was not working for some reason. But Now things work like a charm

Because the by_ssh check command is pre-defined in the ITL and has it specific variables alredy defined.
Check it here: https://your.monitoring.host/icingaweb2/director/commands?type=external_object#!/icingaweb2/director/command/render?name=by_ssh

Hi I am not able to find the option define data fields in director. Looking for suggestions

It’s on the main page of the director if you scroll to the bottom.

Thanks,added data field, but still doesnot reflect in external command does it take time to get reflected

What do you mean by “reflected”?

If you want the datafield to show up in the configuration you will have to add it to either the command or the service template. How to do that is shown in post #1

If this is not what you meant please be more specific and maybe post some screenshots config snippets

Hi reflect in the sense, it doesnot show up when i try to add in external command though in the data field (by_ssh_command) its added. Also i see this

This is an external object. It has been imported from Icinga 2 through the Core API and cannot be managed with the Icinga Director. It is however perfectly valid to create objects using this or referring to this object. You might also want to define related Fields to make work based on this object more enjoyable.

image

Ok, I see.
You picked the “worst” possible example for a variable/datafield :smiley:

This one is “special” because in the ITL it has a Icinga DSL defintion, thus the Director can’t import it fully and therefore it is not listed in the suggested fields:

object CheckCommand "by_ssh" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_by_ssh" ]
    timeout = 1m
    arguments += {
        "-4" = {
            description = "Use IPv4 only"
            set_if = "$by_ssh_ipv4$"
        }
        "-6" = {
            description = "Use IPv6 only"
            set_if = "$by_ssh_ipv6$"
        }
        "-C" = {{
            /* Unable to fetch function body through API */
        }}

Just scroll down until you see your datafield and add it.

Small hint: You don’t have to manually create the datafields one by one. If the datafield does not exist at the moment you want to add them from the dropdown (section “Argument macros”), the Director will present you with a dialog which will create the datafield in one go.
Example:

ok got it. so i have to create new command in icinga director and then add by_ssh_commmand under arguments section

No.

Go to the by_ssh command in the External Commands sections, go to the Fields tab and look at the dropdown menu.

As you seem to already have added all possible variables from the Argument macros section, you only see Suggested fields and further down should be Other available fields
image

In the Other section you will find your by_ssh_command variable.

To explain the dropdown menu a bit:
Argument macros will display all variables from the command, seen in the Preview tab, with the exception of variables of set_if conditions and Icinga DSL definitions
image
image

Suggested fields list possibly fitting variables for that command, not sure on what logic this is based, though.

Other available fields lists all remaining variables that were defined via the Icinga Director.

Got it. worked. I created service, but i am unable to define the path of the script under custom variable by_ssh_command. is there a way to define user defined variable
image

looks like you have defined the by_ssh:command field with a type other than String.
Change it to String and you will be able to put in the path.

I have crated with data type: string only Is there any way to make icinga check run on remote hosts rather than by_ssh_command like below
/usr/lib/nagios/plugins/check_nrpe_v2.15’ ‘-H’ ‘hostname’ ‘-c’ ‘check_script’

If you want a certain check to be run on the remote host you have multiple options:

  • Icinga Agent is installed on the remote host
    – set command_endpoint in the service
  • no agent (linux)
    – check_by_ssh
    – script to be executed (like check_disk) have to be present on the remote host
    – needs configuration of a user with passwordless (priv/pub key) login

Running check_nrpe via check_by_ssh doesn’t make sense imo.
If your remote host has NRPE installed why not just run it from the Icinga server itself?

I think your further questions might not really about what this topic originally used address.
I’d say you open a new thread with a detailed description of your problem/goal and a fitting title :slight_smile:

ok got it, but any idea why i am not able to add the path option by_ssh_command when adding service though the datatype is string


It should work

The easiest way is to inspect and run it on your Master or Satellite from where you are making connection

Inspect should say something like this
‘/usr/lib64/nagios/plugins/check_by_ssh’ ‘-C’ ‘/usr/lib64/nagios/plugins/check_fs_aix -w 90 -c 95 -p jfs*’ ‘-H’ ‘XXX.XXX.XXX.XXX’ ‘-t’ ‘60’