Page 1 of 1
Custom Command Issue
Posted: Fri Sep 17, 2021 3:31 pm
by kcarlson
Hello, I am having an issue with setting up a new command with a custom plugin. I have loaded the plugin then created a new command that uses it. I then create a new custom service on an existing host. I choose the new command and enter my options. When I click the "Run Check Command" option I receive no output back. I then take the command that was ran and copy and paste it into a command line. I receive output back from the plugin when doing this.
I'm wondering if there is an issue with the custom command that is built. When I substitute other commands in the service drop down I get some sort of an answer back.
When viewing this new service the only thing that is presented is "(No output on stdout) stderr:". When searching on this error I see that a host or option is incorrect. Somewhat confused by that as the same command works within my CLI. I also saw a mention of checking the 'resource.cfg' file to make sure your path is correct. I believe it is but can provide that if needed. I do have other plugins running custom commands without issue.
I have attached my custom command as well as the service that is built. I have also attached screenshots showing my 'run check command' as well as the CLI output from the same command.
Any help in getting this working would be greatly appreciated.
Thanks!
Re: Custom Command Issue
Posted: Mon Sep 20, 2021 10:46 am
by benjaminsmith
HI,
I then take the command that was ran and copy and paste it into a command line. I receive output back from the plugin when doing this.
The fact that it works from the CLI is usually the result of incorrect permission on the plugin. Try logging in on the CLI as the nagios user account,
su - nagios , and run the plugin, do you get the same results?
--Benjamin
If that's not the issue, please send us the system profile as well.
To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Re: Custom Command Issue
Posted: Mon Sep 20, 2021 1:21 pm
by kcarlson
Hi Benjamin
Thank you for the reply. Attempting to run the plugin as user 'nagios' results in the same zero output like the run check command does. I have changed permissions on this plugin but still am unable to run the plugin. I have PM'd you a system profile. Still wondering if this is a permissions issue but am not seeing the issue at this time.
Thanks!
Re: Custom Command Issue
Posted: Tue Sep 21, 2021 10:02 am
by benjaminsmith
HI,
Thank you for the profile, that looks correct. Let's double-check the permissions, please login to the CLI and run the following command.
Code: Select all
ls -l /usr/local/nagios/libexec/check_iftraffic_e7.pl
If it was working from the CLI but then does not as the nagios user, that would indicate a permissions issue. Were you logged in as root when running it before from the CLI?
Benjamin
Re: Custom Command Issue
Posted: Tue Sep 21, 2021 10:19 am
by kcarlson
Correct, from CLI the plugin will run as the root user but not the nagios user. I was thinking permissions as well but am not seeing anything obvious. here is the output from the command:
[root@nagios ~]# ls -l /usr/local/nagios/libexec/check_iftraffic_e7.pl
-rwxrwxrwx 1 nagios nagios 39142 Sep 15 14:00 /usr/local/nagios/libexec/check_iftraffic_e7.pl
Thanks!
Re: Custom Command Issue
Posted: Wed Sep 22, 2021 10:42 am
by benjaminsmith
Hi,
Those permissions should work, the reccomend settings are as follows.
Code: Select all
chown apache:nagios /usr/local/nagios/libexec/mynagiosplugin.pl
chmod 775 /usr/local/nagios/libexec/mynagiosplugin.pl
Can you upload the custom script to the thread or send it over in a private message. I would like to take a look, it might not be returning the correct output ( see:
https://nagios-plugins.org/doc/guidelines.html). Thanks, Benjamin
Re: Custom Command Issue
Posted: Wed Sep 22, 2021 11:22 am
by kcarlson
Thank you for posting recommended settings. I have corrected mine to match the recommended ones. I will PM you the plugin.
Thanks!
Re: Custom Command Issue
Posted: Thu Sep 23, 2021 12:25 pm
by benjaminsmith
Hi,
So I've been able to repeat the same error. It works from the CLI and returns a correct exit code.
cli-output.png
However, neither Core nor XI can read string output, but it does read the exit status. In this case, the service is returning OK.
xi-output.png
You'll notice it outputs perf data in the CLI, but that's not getting processed either.
xi-performance.png
It will work for monitoring since it's returning correct exit codes, but you won't get the system output or perf data. It looks like the output is not to plugin specs.
https://nagios-plugins.org/doc/guidelines.html
--Benjamin