Hello everybody,
I’m having trouble creating a service check with check_by_ssh
Under /etc/icinga2/zones.d/master/ I added a file called sshcommand.conf
The content looks like this:
object CheckCommand "by-ssh-test" {
import "by_ssh"
vars.by_ssh_command = "/usr/lib/nagios/plugins/check_by_shh -C $by_ssh_test_command$"
vars.by_ssh_test_command = "/apps/test/test-shh/check.sh"
}
The service is supposed to be generated via the API, so I created a file named by_ssh.json:
{
"attrs": {
"check_command": "by-ssh-test",
"display_name": "check-by-ssh-test",
"host_name": "testname.dc.lan",
"import": [
"generic-service"
],
"vars": {
"by_ssh_logname": "testuser"
}
},
"name": "testname.dc.lan!check-by-ssh-test",
"type": "Service"
}
When calling the curl command, however, the following error message always appears:
curl -k -s -u root:icinga -H “Accept: application/json” -X PUT https://localhost:5665/v1/objects/services/testname.dc.lan\!check-by-ssh-test\?pretty=1 -d @by_shh.json
{ "results": [ { "code": 500.0, "errors": [ "Error: Validation failed for object 'testname.dc.lan!check-by-ssh-test' of type 'Service'; Attribute 'check_command': Attribute must not be empty.\nLocation: in /var/lib/icinga2/api/packages/_api/localhost.mn.biz-1529512723-1/conf.d/services/testname.dc.lan!check-by-ssh-test.conf: 1:0-1:38" ], "status": "Object could not be created." } ] }
The direct call with curl works:
/usr/lib64/nagios/plugins/check_by_ssh -H testname.dc.lan -l testuser -C “/apps/test/test-ssh/check.sh”
Result:
OK - check_by_ssh: Remote command ‘/apps/test/test-ssh/check.sh’ returned status 0
Maybe someone has a tip for me
Thanks and greetings Andy