Pipe char ("|") in argument list of check_by_ssh

Hi, I want to set a regex string as check_by_ssh argument. I assume Icinga interprets the pipe as shell pipe:

  vars.by_ssh_arguments = {
    "-c" = "[Ee]rror\\|[Ee]xception\\|[Ff]ail"

I tried with |, \|, \\|, \\\| and \\\\| but nothing worked. How to set arguments with pipes?

I am not sure, but Icinga escapes every element of the command with single quotes. So I would have said | should be enough.

What I would do to verify is:

  • Configure it like expected
  • Execute the check
  • Look into the API how the command is actually build (Can be done by querying the service from the API, using the console on CLI or if using Director via the Inspect action in the UI)
  • Copy the command to the shell and see what the problem is (Sometimes running it with sudo as icinga/nagios user and using sh -c is required to really see the problem)
  • Adjust and repeat if required

I did not try it again. I solved it now by not using check_by_ssh but the Icinga Agent. Now the argument works without escaping as expected.

the -C is a command to send via ssh so what you have won’t work. if it was:

"-C" = "cat file | grep -i Error"

that might work.