Page 1 of 2
Issue with check command
Posted: Mon May 06, 2013 4:58 pm
by imrob
Hi,
I've run into an issue while evaluating Nagios XI
System: Centos 6.4
Platform: Xenserver 5.6sp2 vm
Nagios XI Version: 2012R1.8
Since I've used nagios OSS for a while so I'm doing the configuration of our test box via the core config manager.
I have the following check command that works fine via cli:
[root@nagiosxitest services]# /usr/local/nagios/libexec/check_nt -H 10.1.5.147 -s "" -p 1248 -v COUNTER -l "\LogicalDisk(C:)\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
Disk Free Space 38.70 % | 'Disk Free Space %.2f %%'=38.704600%;90.000000;95.000000;
10.1.5.147 has the nsclient++ as shown in the windows server auto discover wizard. The return values look correct from the cli command above.
However, when I define the following in the gui, it fails:
===================================
Config name: win_diskc
Description: Disk C: Free Space Pct
Check command: check_xi_service_nsclient
Active[X]
Command view: $USER1$/check_nt -H $HOSTADDRESS$ -s "$ARG1$" -p 1248 -v $ARG2$ $ARG3$ $ARG4$
$ARG1$ [ ]
$ARG2$ [ COUNTER ]
$ARG3$ [ -l "\LogicalDisk(C:)\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95 ]
===================================
Running "Test check command" shows the following:
===================================
COMMAND: /usr/local/nagios/libexec/check_nt -H 10.1.5.147 -s "" -p 1248 -v COUNTER -l "\\LogicalDisk\(C:\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
OUTPUT: Disk Free Space 0.00 % | 'Disk Free Space %.2f %%'=0.000000%;90.000000;95.000000;
===================================
I believe that the "LogicalDisk(C:)" is being (incorrectly?) escaped as LogicalDisk\(C:\) and this is what is causing it to fail.
Please advise if I am wrong and what I'm doing wrong.
If I'm correct, is there a work-around or bugfix for this issue?
Thanks,
Robert
Re: Issue with check command
Posted: Tue May 07, 2013 9:22 am
by slansing
The test may fail since it may be required to escape the backslashes that are being used in the ARG3 value. See this wiki page for an example of escaping a special character:
http://support.nagios.com/wiki/index.ph ... ck_Command
What the test was doing was escaping those characters once, but the command line read the slashes that were added as literal, so what you need to do is add double slashes where that test did, in the ARG3 value. For example:
Code: Select all
-l "\\LogicalDisk\\(C:\\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
And then verify after the config has been saved and applied, via the schedule an immediate check function on the service details page of the service itself. If the double slashes do not work where they were not present before, try switching them to singles like so:
Code: Select all
-l "\\LogicalDisk\(C:\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
Re: Issue with check command
Posted: Tue May 07, 2013 11:00 am
by imrob
slansing wrote:The test may fail since it may be required to escape the backslashes that are being used in the ARG3 value. See this wiki page for an example of escaping a special character:
http://support.nagios.com/wiki/index.ph ... ck_Command
What the test was doing was escaping those characters once, but the command line read the slashes that were added as literal, so what you need to do is add double slashes where that test did, in the ARG3 value. For example:
Code: Select all
-l "\\LogicalDisk\\(C:\\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
And then verify after the config has been saved and applied, via the schedule an immediate check function on the service details page of the service itself. If the double slashes do not work where they were not present before, try switching them to singles like so:
Code: Select all
-l "\\LogicalDisk\(C:\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
I understand the reasoning behind this, and I'll give it a shot, thanks.
Any way this may be fixed to make it a bit easier for Windows Admins who don't know the internals of linux shell escape character?
Re: Issue with check command
Posted: Tue May 07, 2013 11:04 am
by imrob
I copied and pasted your example and it did not solve the issue:
$ARG3$ [ -l "\\LogicalDisk\\(C:\\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95 ]
Output of test command:
Code: Select all
COMMAND: /usr/local/nagios/libexec/check_nt -H 10.1.5.147 -s "" -p 1248 -v COUNTER -l "\\\\LogicalDisk\\\\\(C:\\\\\)\\\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
OUTPUT: Disk Free Space 0.00 % | 'Disk Free Space %.2f %%'=0.000000%;90.000000;95.000000;
Edit: I forgot to meniton that I tried single slashes first, as I believe that is what works on the CLI.
Re: Issue with check command
Posted: Tue May 07, 2013 1:28 pm
by slansing
Did you try these by forcing the check command through "Home > Service Details > "Service's name" > Schedule an immediate check button
I do not believe that you would be able to test this through the "Test" function in the CCM due to having to escape the slashes. Currently the only way to test changes like this would be through the schedule check button in the service's details page itself, not the CCM..apologies if I was unclear.
Re: Issue with check command
Posted: Tue May 07, 2013 1:57 pm
by imrob
No I did not.
This does kind of show that the "test check command" in services is broken then...no? I'll try actually setting up the check and assiging it to a host to see if it actually returns any data.
Edit:
Code: Select all
-l "\LogicalDisk(C:)\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
Returned 0
Code: Select all
-l "\\LogicalDisk\\(C:\\)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
Returned 0
Code: Select all
-l "\\LogicalDisk(C:)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
Returned the correct number.
So I guess it comes down to removing the "escaping" of the ()'s that the test check tries to do. Does this sound correct? Is this something that will be fixed so non-linux/non-shell people will have the test command work as expected?
Re: Issue with check command
Posted: Tue May 07, 2013 2:26 pm
by abrist
The test check adds the escaping right before the check as it is a one-shot test. The XI interface will also add escaping, but does so behind the scenes.
Re: Issue with check command
Posted: Tue May 07, 2013 2:34 pm
by imrob
Why then would the test NOT work but when actually setting it up that way as a service, work?
Re: Issue with check command
Posted: Tue May 07, 2013 2:40 pm
by abrist
Sometimes the test check command does not work for checks if those checks cannot be run as user "apache". There are also some extra precautions taken with the test check command as there are security concerns with allowing any plugin to be run from the web ui as a one shot.
Re: Issue with check command
Posted: Tue May 07, 2013 2:48 pm
by imrob
abrist wrote:Sometimes the test check command does not work for checks if those checks cannot be run as user "apache". There are also some extra precautions taken with the test check command as there are security concerns with allowing any plugin to be run from the web ui as a one shot.
Running it as user apache seems to be OK:
Code: Select all
bash-4.1$ whoami
apache
bash-4.1$ /usr/local/nagios/libexec/check_nt -H 10.1.5.147 -s "" -p 1248 -v COUNTER -l "\\LogicalDisk(C:)\\% Free Space","Disk Free Space %.2f %%" -w 90 -c 95
Disk Free Space 38.68 % | 'Disk Free Space %.2f %%'=38.680800%;90.000000;95.000000;
That makes sense. Is there some security issue that requires escaping ()'s as that seems to be the issue.....
I wonder if there is another way to escape the ()'s, securely, while still making sure the check works -- OR notifying the end user that checks with ()'s may not work...