I have recently created a custom script that I can’t find out why it doesn’t produce any output on the icingaweb2. I use a variable to collect some results inside the script and then I print that variable but It doesn’t seem to produce any output. When I run it from the terminal it works as intended.
Alternatively use the “logger” command in your script to get the value of
$variable output to syslog where you can then check whether it contains what
you expect.
I tested it with a simple string, it works. But when I try to implement it with my results it doesn’t.
The data that I want to display are something like this:
variable="First line\n Second line\n"
echo $variable
First line\n Second line\n
# This seems to be equal to the previous one, but shell-internally it is not
echo "$variable"
First line\n Second line\n
echo -e "$variable"
First line
Second line
The output format it’s not the problem, I think at least.
In any case I tried the echo -e, the printf, and both with double quotes and without.
Still I get no output on the icingaweb. I am sure that I do something wrong but I don’t know what.
And again, when I run it in terminal I get the results but not in the web interface
Maybe you can enable debuglog (icinga2 feature enable debuglog) on the Icinga2 host which executes the script and look for the debuglog (/var/log/icinga2/debug.log) to check what gets effectively executed (options, arguments, …).