How to run agentless checks from satellite?

Hi,

I’m using the check_by_ssh plugin, its working fine if nagios plugins is installed on remote agent. how can run the checks from the satellite?

I followed this https://github.com/Icinga/icinga2/blob/master/doc/07-agent-based-monitoring.md

This is the error i’m getting:

Remote command execution failed: bash: /usr/lib/nagios/plugins/check_users: No such file or directory

Hi,

Please be a little more concrete here - where is the host/service object located, is that inside the satellite zone and checks a remote agent via by_ssh, or something else?

Cheers,
Michael

Thanks for your quick reply

The host/service object is located inside the satellite zone on the icinga master.

My Host:

object Host "snip-ai.123.local" {
  import "ssh-agent"

  address         = "192.168.0.175"
}

Service:

apply Service "users" {
  check_command = "by_ssh"

  vars.by_ssh_command = [ "/usr/lib/nagios/plugins/check_users" ]

  vars.by_ssh_arguments = {
    "-w" = {
      value = "$users_wgreater$"
    }
    "-c" = {
      value = "$users_cgreater$"
    }
  }

  vars.users_wgreater = 3
  vars.users_cgreater = 5

  assign where host.vars.os_type == "linux" && host.vars.agent_type == "ssh"
}

Hi,

maybe the path is incorrect - if the Host is a RHEL based one, it changes to /usr/lib64/nagios/plugins.
You can check such with running ssh manually with ls -la /usr/lib/nagios/plugins for instance.

You could help yourself with adding specific host templates and import them on the host level.

template Host "rhel-host" {
  vars.plugin_dir = "/usr/lib64/nagios/plugins"
  vars.distribution_type = "rhel"
}
template Host "sles-host" {
  vars.plugin_dir = "/usr/lib/nagios/plugins"
  vars.distribution_type = "sles"
}
template Host "debian-host" {
  vars.plugin_dir = "/usr/lib/nagios/plugins"
  vars.distribution_type = "debian"
}
object Host "snip-ai.123.local" {
  import "ssh-agent"
  import "rhel-host"

  address         = "192.168.0.175"
}
apply Service "users" {
  check_command = "by_ssh"

  var plugin_dir = PluginDir // Use a default value

  if (host.vars.plugin_dir != "") {
    plugin_dir = host.vars.plugin_dir
  } 

  vars.by_ssh_command = [ plugin_dir + "/check_users" ]

...

An alternative method would be to specify the distribution_type and match based on this in the service apply rule. I prefer to stash this into the host templates as you do not need to duplicate the string values inside the service apply rules then.

Or you defined the different paths as constants, e.g. RhelPluginDir, DebianPluginDir, SlesPluginDir and use these inside the service apply rule. Depends on your preferred style.

Cheers,
Michael

Its not the path. i have one remote agent that is working, i install nagios-plugins on it

The other computer that i want to monitor i cant install nagios-plugins on it this why im trying to run the checks command on the satellite.

Does ssh agent require that nagios-plugins is install on the remote agent?

The command which is executed on the remote host needs all binaries to execute, be it monitoring plugins or any other script. If you cannot install anything, you’ll need to find workarounds to execute system commands like ps or df and write a wrapper script on the satellite side then being called instead of check_by_ssh.

Cheers,
Michael

Thanks Michael.

much appreciated