Page 1 of 2
Check shared folder size
Posted: Wed Apr 05, 2017 9:53 am
by W.W.
Hi,
Excuse my English, it is not not my native language.
I have a nagios 4.1 to install(settle) and to configure all work well, I would like now to monitor 3 shared folders.
I arrive to monitor one of those folder by using a check nrpe
Code: Select all
define service{
use generic-service
host_name $HOSTNAME
service_description Dossier FolderName
check_command check_nrpe!check_files -H $HOSTNAME -a file="PATH" "warning=size>20000k" "detail-syntax=%(name) #size:%(size)" total
}
For the 2 other folder I do the same thing, for one of them I have status information =
Failed to process command: boost:: filesystem:: status: Access is denied: "D:FolderSubFolder"
and the other one contains more than 700 000 files and 45 000 folders but in the nagios Web interface under status information I have
OK: All 1 files are OK so there is something wrong
I am a novice concerning nagios and I do not know where his errors can come.
Thank you for your answers.
Re: Check shared folder size
Posted: Wed Apr 05, 2017 2:30 pm
by mcapra
I assume this is a Windows machine you are attempting to monitor?
If so, do you know which version of NSClient++ this Windows machine is using? It can usually be found with:
For example, here is me checking the NSClient++ version of a remote Windows machine in my lab environment:
Code: Select all
[root@xi-stable ~]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99
I (0.5.0.62 2016-09-14) seem to be doing fine...
Re: Check shared folder size
Posted: Thu Apr 06, 2017 6:31 am
by W.W.
Thanks for your reply.
Yes, it's a windows machine that running windows server 2003 and the nsclient++ version is 0.4.3.143-x64
Re: Check shared folder size
Posted: Thu Apr 06, 2017 4:26 pm
by mcapra
Can you share the full check commands your services are using? Back-slashes don't tend to cooperate well in Linux and will often need to be escaped. You can PM it if you would rather it not be public information.
Re: Check shared folder size
Posted: Fri Apr 07, 2017 2:44 am
by W.W.
It's the commands that I have already specified at the top in the definition of the service
Code: Select all
check_nrpe!check_files -H $HOSTNAME -a file="D:\Folder\Name" "warning=size>20000k" "detail-syntax=%(name) #size:%(size)" total
Thank again
Re: Check shared folder size
Posted: Fri Apr 07, 2017 10:30 am
by mcapra
Right, but seeing the actual path confirms my suspicion that un-escaped back-slashes are used.
Since
\ is a reserved character in just about every modern Linux CLI, and Nagios Core just piggy-backs off of that for executing plugins, you'll need to properly escape your Windows file paths like so:
Try using double backslashes instead for your paths.
Re: Check shared folder size
Posted: Mon Apr 10, 2017 3:28 am
by W.W.
Ok, I use the double backslashe and i got the same result. In nagios web interface i still have OK: All 1 files are ok while there is not only a single file in this folder
Correct me if i'm wrong, the error could it come from the autorization on sharing folder ?
Re: Check shared folder size
Posted: Mon Apr 10, 2017 2:15 pm
by mcapra
W.W. wrote:Correct me if i'm wrong, the error could it come from the autorization on sharing folder ?
check_nrpe is going to reach out to NSClient++ to do the actual checking. So if the Windows system user the NSClient++ service is running under does not have read permissions on the folder and it's sub-folders, I can see that happening.
It's also worth mentioning that NSClient++ includes the root folder as a "file". See this example:
Code: Select all
[root@xi-stable httpd]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -c check_files -a file="C:\\Users\\admin\\Documents\\files" "warning=size>20000k" "detail-syntax=%(name) #size:%(size)" total
OK: All 6 files are ok|'test.txt size'=0MB;19.53125;0 'test3.txt size'=0MB;19.53125;0 'test4.txt size'=0MB;19.53125;0 'testlog.txt size'=0.00056MB;19.53125;0 'testlog_bob.txt size'=0.10288MB;19.53125;0 'total size'=0.10344MB;19.53125;0
The output says "6 files" when there are only 5 "files" in the directory. This is because the root directory is included as a "file":
Code: Select all
C:\Users\admin>dir "C:\Users\admin\Documents\files"
Volume in drive C has no label.
Volume Serial Number is CA4B-B3F3
Directory of C:\Users\admin\Documents\files
10/19/2016 06:36 PM <DIR> .
10/19/2016 06:36 PM <DIR> ..
07/08/2016 07:53 PM 0 test.txt
08/18/2016 04:20 PM 0 test3.txt
07/08/2016 07:53 PM 0 test4.txt
10/17/2016 09:43 PM 590 testlog.txt
10/19/2016 08:45 PM 107,879 testlog_bob.txt
5 File(s) 108,469 bytes
2 Dir(s) 30,933,823,488 bytes free
Re: Check shared folder size
Posted: Tue Apr 11, 2017 2:24 am
by W.W.
I gonna check it out and come back to you. For the fact that NSClient++ include the directory as a file i noticed that during my test
Thank you for your time
Re: Check shared folder size
Posted: Tue Apr 11, 2017 10:37 am
by mcapra
Sure thing! Let us know if you have additional questions regarding this.