I have correct result in console but Icinga got ‘’

bash

(Rostyslav) #1

Hello,

I have written bash script who checks if a file exists on dir and it works well in the console but transfers to Icinga looks like Unicode symbol ‘’

Locales on client and Icinga’s server UTF8 script saved in UTF8 too.

Could someone prompt me or give an idea, please?

Regards,
Rostyslav


#2

Hi,

are you able (and allowed) to share your script here for better investigation on this?

First of all make sure that the script uses the correct path and keep in mind that relative paths may not work if the script is called by Icinga.

Cheers
Michael


(Rostyslav) #3

Hi,
Yes of course
I have placed on gist.github
file_if_exist.sh


(Michael Friedrich) #4

Hm, there’s no error handling for the find call, it just pipes everything into wc. I would split this up for better analysis and identify the culprit if either one or the other renders garbage here.


(Rostyslav) #5

I forgot to tell about that I use Icinga Director. Perhaps PHP somewhere converts output?


#6

You can query the Icinga API directly and have a look to last_check_result

$ curl -k -s -u root:icinga 'https://127.0.0.1:5665/v1/objects/services?service=hostname!servicename' | python -m json.tool

[...]
                "last_check_result": {
                    "active": true,
                    "check_source": "metis",
                    "command": [
                        "/home/michael/Coding/test.sh",
                        "-e",
                        "sql",
                        "-m",
                        "2",
                        "-s",
                        "/home/michael"
                    ],
                    "execution_end": 1526324289.869285,
                    "execution_start": 1526324289.860517,
                    "exit_status": 1.0,
                    "output": "CRITICAL: 1 files with extension sql exists",

[...]

Replace root:icinga (username:password) with valid API credentials. Also change hostname!servicename to your matching host- and service name.

If the output here is also malformed start with implementing error handling as @dnsmichi said.


(Rostyslav) #7

The error was related to Icinga Director. I had reconfigured it in this way and script works well now.