Hi,
I have a service running a script that runs commands via ssh in remote boxes. It fails in funny ways intermittently. On another Nagios install that's supposed to be the same, the same service always seems to work fine. The scripts are identical. I added a line to the script to touch a file to see who's running the script. I had assumed it would run as nagios, but I its owned by apache on the server with the problem.
Works:
-rw-r--r-- 1 nagios nagios 0 Oct 20 16:21 /tmp/check_capacity.txt
Fails:
-rw-r--r-- 1 apache apache 0 Oct 20 16:13 /tmp/check_capacity.txt
So on one system, the script is running as apache, and on the other as nagios. Where is the user running the service defined? I don't see it in nagios.cfg
When I test the service (test check command button), the command always fails on either system.
OUTPUT: Could not connect to...
When run by the nagios user, the script runs fine every time.
Service test button runs script as apache user
Re: Service test button runs script as apache user
When you use the Test Check Command button, it is always run by apache. If the check is run organically, it is run by nagios. What is likely happening is that you are testing it with the Test Check button first, and due to the permissions on the file it cannot be overwritten when nagios runs it organically, so it appears to always be run by apache. I'd bet if you skipped the test phase, it would work as expected.
Former Nagios employee
Re: Service test button runs script as apache user
If it normally runs as nagios, that's a good thing at least...
It seems asinine to test as a user that won't run the service. What's the point of testing?
I delete the file at the beginning: rm /tmp/check_capacity.txt; touch /tmp/check_capacity.txt; chmod 666 /tmp/check_capacity.txt
Maybe set UID permission would help. Its a pain to not be able to use the test button (bad lazy user).
This can be closed.
Thanks
It seems asinine to test as a user that won't run the service. What's the point of testing?
I delete the file at the beginning: rm /tmp/check_capacity.txt; touch /tmp/check_capacity.txt; chmod 666 /tmp/check_capacity.txt
Maybe set UID permission would help. Its a pain to not be able to use the test button (bad lazy user).
This can be closed.
Thanks
Re: Service test button runs script as apache user
Thanks for the feedback, gormank!
FYI, modifying the way "test" button works under the CCM is being discussed among our developers. I expect to see some changes in the future versions of XI.
I am closing this topic.
FYI, modifying the way "test" button works under the CCM is being discussed among our developers. I expect to see some changes in the future versions of XI.
I am closing this topic.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Service test button runs script as apache user
Just to tack on, even running it as nagios would not truly be the same as actually loading it into the running nagios configuration, which means things like the $USERn$ macros would have no meaning.
Former Nagios employee