cannot run custom command from anywhere but libexec folder

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Re: cannot run custom command from anywhere but libexec fold

Postby Nighthawkz » Fri Apr 13, 2018 8:17 am

ok if I created a custom script and run it returns as follows:

Code: Select all
0
Nighthawkz
 
Posts: 21
Joined: Fri Oct 20, 2017 7:05 am

Re: cannot run custom command from anywhere but libexec fold

Postby scottwilkerson » Fri Apr 13, 2018 8:25 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11179
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: cannot run custom command from anywhere but libexec fold

Postby danjoh » Fri Apr 13, 2018 8:38 am

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).
--
D/\N
danjoh
 
Posts: 53
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland

Re: cannot run custom command from anywhere but libexec fold

Postby scottwilkerson » Fri Apr 13, 2018 9:07 am

Thanks @danjoh
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11179
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: cannot run custom command from anywhere but libexec fold

Postby Nighthawkz » Sat Apr 14, 2018 3:21 am

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
Nighthawkz
 
Posts: 21
Joined: Fri Oct 20, 2017 7:05 am

Re: cannot run custom command from anywhere but libexec fold

Postby scottwilkerson » Mon Apr 16, 2018 7:21 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11179
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: cannot run custom command from anywhere but libexec fold

Postby Nighthawkz » Wed Apr 18, 2018 8:52 am

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.
Nighthawkz
 
Posts: 21
Joined: Fri Oct 20, 2017 7:05 am

Re: cannot run custom command from anywhere but libexec fold

Postby scottwilkerson » Wed Apr 18, 2018 8:56 am

Wow, well in the end that was easy.

Glad it is resolved
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11179
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Previous

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 12 guests