Page 2 of 2

Re: cannot run custom command from anywhere but libexec fold

Posted: Fri Apr 13, 2018 8:17 am
by Nighthawkz
ok if I created a custom script and run it returns as follows:

Code: Select all

0

Re: cannot run custom command from anywhere but libexec fold

Posted: Fri Apr 13, 2018 8:25 am
by scottwilkerson
In your CompCU.jar it is creating a file cu_output.xml somewhere, and this file likely need to be writable by the nagios user

Re: cannot run custom command from anywhere but libexec fold

Posted: Fri Apr 13, 2018 8:38 am
by danjoh
What I meant is that after you have executed the command "/usr/bin/java...." and it finishes, you then execute "echo $?" (do not execute any additional commands in-between).

Code: Select all

Error setting up log file null: File already exists and cant delete it (is it in use?)
Exception saving output file [cu_output.xml]: java.io.FileNotFoundException: cu_output.xml (Permission denied)
There you go...
The command tries to delete/create the file "cu_output.xml". Where a can not tell, but probably someplace where root is allowed to write but the nagios user is not, OR, root has created the file (from your command that was run as root) and the nagios user is not allowed to delete/recreate the file.
Do a search to find the "cu_output.xml" file (find / -name cu_output.xml) and check the creation time - if it matches with when you run your command as root, then delete the file and try rerunning the command as nagios (WITHOUT trying to run it as root in between)..

You could maybe also try to add "-xmloutputfile ’/tmp/cu_output.xml’" to the command line (I do not know the CompCU.jar application so I am not sure if this works, but I saw this option in the manual).

Re: cannot run custom command from anywhere but libexec fold

Posted: Fri Apr 13, 2018 9:07 am
by scottwilkerson
Thanks @danjoh

Re: cannot run custom command from anywhere but libexec fold

Posted: Sat Apr 14, 2018 3:21 am
by Nighthawkz
thank you both for your help and patience so far!


I did as you said.

removed the xml. reran as user nagios. ran successfully. xml file created with nagios as owner. The 127 error still occurs when nagios trys to run it automatically.

The error mentions worker3 at the end of it (see original post) so i logged into that box as user nagios. the script and jar file had been sync'd across to it and have correct permissions. no xml file. so i ran the script manually on worker3. script ran fine. xml created with nagios as owner.

error still occurs

regards

Re: cannot run custom command from anywhere but libexec fold

Posted: Mon Apr 16, 2018 7:21 am
by scottwilkerson
If you have this setup with Mod-Gearman and workers, you are going to need to force this to always run on the same worker, so it always has access to the files that are written to the filesystem, also you need to make sure that the file that is sync'd is the one where the full paths were added for java and the .jar file

Re: cannot run custom command from anywhere but libexec fold

Posted: Wed Apr 18, 2018 8:52 am
by Nighthawkz
well...i fell daft. the problem was simply my eyesight. i had an extra "s" on the end of the check in the command.cfg, Changed it and it works a treat. case closed!

thanks again for your help.

Re: cannot run custom command from anywhere but libexec fold

Posted: Wed Apr 18, 2018 8:56 am
by scottwilkerson
Wow, well in the end that was easy.

Glad it is resolved