How to check Folder accessibility and files

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lgaddam
Posts: 116
Joined: Wed Aug 28, 2019 1:01 am

How to check Folder accessibility and files

Post by lgaddam »

Team,

Please help me how to configure monitoring in nagios, whether a folder in windows server is accessible or not and also need to report alert if no files available in that folder.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: How to check Folder accessibility and files

Post by mbellerue »

Okay, a couple of quick questions. Are you running an agent on the Windows machine, like NCPA? Also, when you say "check if a folder is accessible," do you mean accessible by a specific user, or might the directory just not exist?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
lgaddam
Posts: 116
Joined: Wed Aug 28, 2019 1:01 am

Re: How to check Folder accessibility and files

Post by lgaddam »

Are you running an agent on the Windows machine, like NCPA?
No we are not running with agents on remote windows servers. We are using WMI.

Is it mandatory to monitor remote machines with agent ?
Is agent monitoring is better than WMI monitoring ?
lso, when you say "check if a folder is accessible," do you mean accessible by a specific user, or might the directory just not exist?
Yes.
We need to monitor in below two cases for the folder. This is the requirement from client.
Not able to access folder & no files in folder.


I will check whether authencation is available or not meanwhile.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: How to check Folder accessibility and files

Post by mbellerue »

No, you don't have to use an agent for monitoring. It does make things quite a bit easier, but we definitely understand that not all environments tolerate agents.

You should be able to accomplish what you need by going through WMI. Unfortunately we are not experts with WMI, so we can't help you build the query you need for this. But if you run in to a problem with the check_wmi plugin, we can definitely help there. I would highly recommend keeping this link handy,
https://www.computerhope.com/wmic.htm

I've been working with it a little bit, and I think the fsdir will be a helpful alias for this. But I haven't been able to narrow it down to a specific file or directory just yet. So far I can only get it to walk the entire file system structure, which takes quite a bit of time, as you can imagine.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
lgaddam
Posts: 116
Joined: Wed Aug 28, 2019 1:01 am

Re: How to check Folder accessibility and files

Post by lgaddam »

I too not that much good at wmi and its usages and how to work them in Nagios.

Let me know the solution which you can provide to us whether its via agent or non-agent.
Provide me steps , i will work on that.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to check Folder accessibility and files

Post by lmiltchev »

You can try using the check_wmi_plus.pl plugin, which is installed by default in Nagios XI.

Example check that returns critical if there are files in the D:/TEMP folder:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl -H x.x.x.x -u username -p password -m checkfoldersize -a D:/TEMP --nodatamode -c 0
CRITICAL - [Triggered by _FolderSize>0] - Folder D:/TEMP/ is 14.381KB. Found 2 files(s). (List is on next line)|'D:/TEMP/ Size'=14726B;;0; 'File Count'=2;
The file(s) found are d:\temp\check_nna.py

Example check that returns ok if there are no files in the D:/TEMP folder:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl -H x.x.x.x -u username -p password -m checkfoldersize -a D:/TEMP --nodatamode -c 0
OK - Folder D:/TEMP/ is 0B. Found 0 files(s).|'D:/TEMP/ Size'=0B;;0; 'File Count'=0;
You can view the help menu (usage) of the plugin by running:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl --help
See some examples here:
https://edcint.co.nz/checkwmiplus/faq/c ... and-lines/

Here's a couple of links to documents that might be useful to you if you decide to try this plugin:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

https://support.nagios.com/kb/article/n ... g-579.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
lgaddam
Posts: 116
Joined: Wed Aug 28, 2019 1:01 am

Re: How to check Folder accessibility and files

Post by lgaddam »

Thank you very much for the update, this really helps.
Im following up to get username and password for that folder with client. Once I get I will check this.

And also is there any argument to verify whether the destination folder exists/accesible or not.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to check Folder accessibility and files

Post by lmiltchev »

And also is there any argument to verify whether the destination folder exists/accesible or not.
I didn't find an option in the plugin's help menu that can provide this functionality. There may be a way to run a WMI query for verify that folder exists. Creating and executing this query is out of scope of Nagios support, but this is a guide that can get you started:

https://docs.microsoft.com/en-us/previo ... echnet.10)

Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
lgaddam
Posts: 116
Joined: Wed Aug 28, 2019 1:01 am

Re: How to check Folder accessibility and files

Post by lgaddam »

Thanks for this. We are testing on this.

So, now its for storage device which I require help from you. To monitor accessibility and file availability on a shared path.

//xx.xx.xx.xx/Folder1/Folder2/
Inside this folder2, files should be present.

We have username/password to access, I checked that from desktop provided credentials working and im able to access the shared path.

Kindly help me how to do the monitoring in Nagios.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to check Folder accessibility and files

Post by lmiltchev »

I do not believe this is possible, but you could try contacting Microsoft support and see if there is a WMI query that would allow you to monitor accessibility and file availability on a shared path. In any case, you won't be able to achieve your goal by simply using the "check_wmi_plus.pl" plugin as this functionality is not available.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked