Check_by_ssh working on first added host but not on hosts added after, getting "returned status 255" for all services

Hi All,

I am complete new to Icinga, started using Icinga just last week. With help of online community forums I tried monitoring disk services on linux host without using agent. I added public key of “nagios” user from master server to the hosts, command line working fine using check_by_ssh plugin for all the hosts added. But the problem is with Icingaweb2 ui. I am able to see service working fine on only first host added but other host added afterwards are throwing “check_by_ssh” returned status 255. Below are my conf files:

  1. commands.conf

object CheckCommand “diskchecksun” {
import “plugin-check-command”
command = [ PluginDir + “/” + “check_by_ssh”, “-q”, “-H”, “$address$”, “-l”, “$user$”, “-C”, "$plugin_path$/check_disk -w $warningg$ -c $criticall$ -p $path1$ -p $path2$ " ]
}

  1. services.conf

apply Service “disksun” {
import “generic-service”
check_command = “diskchecksun”
assign where host.vars.agent == “db_sun”
}

  1. hosts.conf

object Host “host1” {
import “generic-host”
address = “host1.xyz”
vars.os = “Linux”
vars.agent = “db_sun”
vars.user = “host1user”
vars.plugin_path = “/host1/plugin/path”
vars.warningg = “10%”
vars.criticall = “5%”
vars.path1 = “/host1/path1”
vars.path2 = “/host1/path2”
}

object Host “host2” {
import “generic-host”
address = “host2.xyz”
vars.os = “Linux”
vars.agent = “db_sun”
vars.user = “host2user”
vars.plugin_path = “/host2/plugin/path”
vars.path1 = “/host2/path1”
vars.path2 = “/host2/path2”
}

In this example “host1” is working fine but “host2” is throwing error.

Please help to resolve the issue.

The Icinga 2 network monitoring daemon (version: r2.10.5-1)

Hiiii @Manish31,

with your service apply definition, it will only apply to hosts that are vars.agent like db_sun and not to db_hp.

But here you have assigned vars.agent to db_hp, which the Apply service rule does not exist at all.

You either have to do like this,

Change vars.agent = "db_hp" to vars.agent ="db_sun"

or you define an additional apply service for the second host like this.

apply Service “disksun2” {
import “generic-service”
check_command = “diskchecksun”
assign where host.vars.agent == “db_hp”
}

Best,
Yonas

Hi @yhabteab, Thanks for reply. Sorry it was mistake from my side, I did not change the vars.agent value while posting the problem. Actually it is same name in my original script.

I got the solution for this issue. Performed below steps:

  1. Copied icinga user public key in addition to nagios user public key in authorized_keys file.
  2. Added -E and -o StrictHostKeyChecking=no in commands.conf file.

object CheckCommand “diskchecksun” {
import “plugin-check-command”
command = [ PluginDir + “/” + “check_by_ssh”, “-E”, “-H”, “$address$”, “-l”, “$user$”, “-o”, “StrictHostKeyChecking=no”, “-C”, "$plugin_path$/check_disk -w $warningg$ -c $criticall$ -p $path1$ -p $path2$ " ]
}

Hope this solution helps others too. :slight_smile:

2 Likes