Argument for check_files

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Argument for check_files

Post by cocoyanouck »

Sorry to open a new topic, but i've any questions about this topic : https://support.nagios.com/forum/viewto ... 2&start=10

I've this command which is now OK :

define service{
use generic-service
host_name NAME OF MY SERVER
notification_interval 20
service_description Number of files on Request
check_command check_nrpe!check_files!path='c:\\GESTION\\REQUEST' pattern=*.* 'warning=count>5' 'critical=count>10' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
}

But when I've no files in this directory, I've a notification "no files found" state : unknown.

I think i may write an argument, but don't find it.

Thanks,
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Argument for check_files

Post by tmcdonald »

What are you looking to accomplish? That appears to be the correct output. The empty-state parameter says "Return status to use when nothing matched filter." according to the documentation: http://docs.nsclient.org/reference/wind ... mpty-state
Former Nagios employee
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Argument for check_files

Post by cocoyanouck »

Hum, when I have one, two, three or four files in this directory, I've no notification (it's correct), and the status on the web interface (or in the output of the nagios-debian) "all 1/2/3/4 files are OK".

When I have more than 4 files, I've a warning or critical notifications => it's also true.

But when I've no files in this directory, i don't what to receive a notification. And actually, I've the status UNKNOWN (that's not good) and the output"no files found (that's correct).

So I wonder if my command is correct, or if an argument is missing or another is incorrect (i.e empty-state) ?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Argument for check_files

Post by rkennedy »

I believe your syntax looks good.

What version of NSClient++ are you running? It looks like this was a previous issue. https://github.com/mickem/nscp/issues/74
Former Nagios Employee
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Argument for check_files

Post by cocoyanouck »

I currently use 0.4.4 but I can test with 0.5.0 tomorrow if necessary.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Argument for check_files

Post by rkennedy »

Can you expand on what version of 0.4.4 you're running? It seems to be exiting properly over here. (in my example, C:\blah2\fds is completely non-existent) -

Code: Select all

[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c check_files -a "path=C:\blah2\fds" "empty-state=CRITICAL"
No files found
[root@localhost libexec]# echo $?
2
[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c check_files -a "path=C:\blah2\fds" "empty-state=WARNING"
No files found
[root@localhost libexec]# echo $?
1
[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c check_files -a "path=C:\blah2\fds" "empty-state=OK"     
No files found
[root@localhost libexec]# echo $?
0
The version of NSClient++ -

Code: Select all

[root@localhost libexec]# ./check_nrpe -H 192.168.5.47
I (0.4.4.15 2015-11-25) seem to be doing fine...
Could you attempt something similar over the command line? echo $? will just show the code that the plugin exited with, so this will help debug. For reference - 0=OK,1=WARNING,2=CRITICAL,3=UNKNOWN
Former Nagios Employee
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Argument for check_files

Post by cocoyanouck »

My version of NSCLIENT :

Code: Select all

I (0.4.4.19 2015-12-08) seem to be doing fine...
When I test with somes files in the directory, the output is (whatever the value of "empty-sate") :

Code: Select all

OK : All X files are OK.
And echo$? :

Code: Select all

0

When I delete all the files, the output is :

Code: Select all

No files found
And echo$? :

Code: Select all

0
I understand that the output is correct (no files found), and the echo too (status OK). But the status on the web interface is different (unknown, in orange/yellow color).
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Argument for check_files

Post by rkennedy »

I understand that, the reason it's displaying as UNKNOWN is because it's exiting with a 3. I'd advise trying to either upgrade NSClient++, or downgrade to the version I'm using.

As it's working fine on my end, it seems to be an issue with certain NSClient++ versions that comes / goes as it pleases.
Former Nagios Employee
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Argument for check_files

Post by cocoyanouck »

I've tried this morning with NSCLIENT 0.5.0 and that's the same problem :(
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Argument for check_files

Post by rkennedy »

rkennedy wrote:Can you expand on what version of 0.4.4 you're running? It seems to be exiting properly over here. (in my example, C:\blah2\fds is completely non-existent) -

Code: Select all

[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c check_files -a "path=C:\blah2\fds" "empty-state=CRITICAL"
No files found
[root@localhost libexec]# echo $?
2
[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c check_files -a "path=C:\blah2\fds" "empty-state=WARNING"
No files found
[root@localhost libexec]# echo $?
1
[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c check_files -a "path=C:\blah2\fds" "empty-state=OK"     
No files found
[root@localhost libexec]# echo $?
0
The version of NSClient++ -

Code: Select all

[root@localhost libexec]# ./check_nrpe -H 192.168.5.47
I (0.4.4.15 2015-11-25) seem to be doing fine...
Could you attempt something similar over the command line? echo $? will just show the code that the plugin exited with, so this will help debug. For reference - 0=OK,1=WARNING,2=CRITICAL,3=UNKNOWN
Can you please do something similar to this testing, and post the full result for us to look at? It could be s small formatting issue, the single quotes vs the double quotes.
Former Nagios Employee
Locked