Closed kevinpapst closed 3 years ago
The script
function is intended to start shell scripts not command. Unfortunately, the description is not very good from myself. I will try to explain it better. So create a script (example mysql.sh
) and insert your commands here. Add this mysql.sh to your checks,
Ok, accepted. I feared that this will be your answer. I'd like to avoid extra scripts, a lot of checks could be squeezed into these one-liners 😁 especially as your own example includes a one-liner call to a command.
Can you explain the different behavior? Is it really intended that it does not work as I hoped it would? Or is that by accident?
I could only find an explanation that the "
should be safer with commands that include space.
Any opinion about true
vs /bin/true
?
It is really only intended to start scripts. I have also removed the example with /bin/true
.
Ok, then I will add extra scripts for the checks. Thanks for your feedback.
Notes
I had some problems when setting up all of my tests.
One is simple: the
/bin/true
does not exist on all systems (here Mac) whiletrue
andfalse
worked on several servers I tried. Not sure though which one is more cross-compatible.The other one is a bit trickier and I might be wrong, as my bash-foo is really far away from being good. But no matter what I tried, all
script
tests failed on my Mac and on my server. I am not sure why, either the way I use it or becuase I appended parameters to the script or because theif-evaluation
in the code wasn't ideal?Just for example, I added the following test which failed with your
if
before:After the change your examples and my added
script
checks worked.Here is the raw output of the script check
mysqladmin ping -h 127.0.0.1 --connect-timeout 2
that I use:The command might be confusing, it shows errors (which can be ignored) but for the check only the exit code is relevant.
UPDATE AFTER MORE TESTING
Maybe the entire if change is not necessary, there seems to be a difference between
and
The first one works in my case (error message but exit code 0 leads to operational), while the second one breaks (leads to outage). Do you happen to know the difference?
I could revert most of my changes and only remove the
"
. But before putting any more effort into this, I'd like to get some feedback.