Monitor mapped network drives

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Monitor mapped network drives

Post by jkinning »

Is there a way to monitor network drive mappings from a server? I have a server that is running the NSClient++ and it keeps losing some drive mappings, server is 2012r2 windows. When they are no longer available I would like to be notified. I am coming up with blanks on how do accomplish this.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Monitor mapped network drives

Post by Box293 »

I am yet to play with this feature however I believe these are "remote drives"

http://docs.nsclient.org/reference/wind ... -drivesize

To check the size of all fixed and network drives and make sure they have at least 1gig free space:

Code: Select all

check_drivesize "crit=free<1g" drive=* "filter=type in ('fixed', 'remote')"
L     client OK: All drives ok
L     client  Performance data: 'C:\ free'=18GB;0;2;0;223 'C:\ free %'=8%;0;0;0;100 'D:\ free'=18GB;0;4;0;465 'D:\ free %'=3%;0;0;0;100 'M:\ free'=83GB;0;27;0;2746 'M:\ free %'=3%;0;0;0;100
To checking UNC Paths. Please note that I need to use \ to escape the back-slashes from check_nrpe you can escape using ‘ instead which is simpler:

Code: Select all

check_drivesize drive=\\\\medin-ds\\data\\ "crit=free<10%"
L     client CRITICAL: \\medin-ds\data\: 2.6TB/2.68TB used
L     client  Performance data: '\\medin-ds\data\ free'=83GB;0;274;0;2746 '\\medin-ds\data\ free %'=3%;0;9;0;100
Important

Please note that UNC paths are only avalible in each session meaning a user mounted share will not be visible to NSClient++ (since services run in their own session). But as long as NSClient++ can access the share it still works as long as you specify the UNC path. In other words the following will NOT work:

Code: Select all

check_drivesize drive=m:
But the following will:

Code: Select all

check_drivesize drive=\\myserver\\mydrive
In reality, the service runs as the system account. Even if you changed the service to run as the user account that has the mapped drive, that will be a different session and won't be a true reflection.

Perhaps a background powershell script could run as the logged on user. If it detects a drive mapping is lost it could log it to a text file. Then have another script that NSClient++ calls which can check this file and return the relevant result based on it's findings.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor mapped network drives

Post by jkinning »

I am not getting this to work.

Code: Select all

[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -t 55 -c check_drivesize -a "filter=type = 'fixed' and drive regexp '.*[C-Z].*'" "warn=free<15%" "crit=free<5%"
OK All 2 drive(s) are ok|'C:\ free'=22.90067GB;7.4997;2.4999;0;49.99804 'C:\ free %'=45%;14;4;0;100 'D:\ free'=25.30082GB;5.99955;1.99985;0;39.99706 'D:\ free %'=63%;14;4;0;100
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -t 55 -c check_drivesize -a "filter=type in ('fixed', 'remote') and drive regexp '.*[C-Z].*'" "warn=free<15%" "crit=free<5%"
OK All 2 drive(s) are ok|'C:\ free'=22.90074GB;7.4997;2.4999;0;49.99804 'C:\ free %'=45%;14;4;0;100 'D:\ free'=25.30082GB;5.99955;1.99985;0;39.99706 'D:\ free %'=63%;14;4;0;100
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -t 55 -c check_drivesize "crit=free<1g" drive=* "filter=type in ('fixed', 'remote')"
OK All 4 drive(s) are ok|'A:\ used'=0B;0;0;0;0 'C:\ used'=27.0973GB;39.99843;44.99823;0;49.99804 'C:\ used %'=54%;79;89;0;100 'D:\ used'=14.69624GB;31.99765;35.99736;0;39.99706 'D:\ used %'=36%;79;89;0;100 'E:\ used'=0B;0;0;0;0
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -c check_drivesize "crit=free<1g" drive=* "filter=type in ('fixed', 'remote')"
OK All 4 drive(s) are ok|'A:\ used'=0B;0;0;0;0 'C:\ used'=27.09703GB;39.99843;44.99823;0;49.99804 'C:\ used %'=54%;79;89;0;100 'D:\ used'=14.69624GB;31.99765;35.99736;0;39.99706 'D:\ used %'=36%;79;89;0;100 'E:\ used'=0B;0;0;0;0
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -c check_drivesize drive=\\cinfs05p.ws.wsfgrp.net\\enterprise_vol1
OK All 4 drive(s) are ok|'A:\ used'=0B;0;0;0;0 'C:\ used'=27.10531GB;39.99843;44.99823;0;49.99804 'C:\ used %'=54%;79;89;0;100 'D:\ used'=14.69624GB;31.99765;35.99736;0;39.99706 'D:\ used %'=36%;79;89;0;100 'E:\ used'=0B;0;0;0;0
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -c check_drivesize drive=\\\\cinfs05p.ws.wsfgrp.net\\enterprise_vol1
OK All 4 drive(s) are ok|'A:\ used'=0B;0;0;0;0 'C:\ used'=27.10522GB;39.99843;44.99823;0;49.99804 'C:\ used %'=54%;79;89;0;100 'D:\ used'=14.69624GB;31.99765;35.99736;0;39.99706 'D:\ used %'=36%;79;89;0;100 'E:\ used'=0B;0;0;0;0
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -c check_drivesize drive='\\wsl_prodimg.ws.wsfgrp.net'
OK All 4 drive(s) are ok|'A:\ used'=0B;0;0;0;0 'C:\ used'=27.10219GB;39.99843;44.99823;0;49.99804 'C:\ used %'=54%;79;89;0;100 'D:\ used'=14.69624GB;31.99765;35.99736;0;39.99706 'D:\ used %'=36%;79;89;0;100 'E:\ used'=0B;0;0;0;0
[nagios@nagiosl1t libexec]$ ./check_nrpe -H imgqry1p -c check_drivesize drive=\\\\wsl_prodimg\\PRODIMG_VOL1
OK All 4 drive(s) are ok|'A:\ used'=0B;0;0;0;0 'C:\ used'=27.10209GB;39.99843;44.99823;0;49.99804 'C:\ used %'=54%;79;89;0;100 'D:\ used'=14.69624GB;31.99765;35.99736;0;39.99706 'D:\ used %'=36%;79;89;0;100 'E:\ used'=0B;0;0;0;0
All I get are the fixed drives, I am not getting any of the network mapped drives like M, O, and R.
You do not have the required permissions to view the files attached to this post.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Monitor mapped network drives

Post by hsmith »

What version of NSClient are you running? I can try to lab this one up.
Former Nagios Employee.
me.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor mapped network drives

Post by jkinning »

I (0.4.3.131 2015-02-15)
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Monitor mapped network drives

Post by Box293 »

Box293 wrote:Please note that UNC paths are only avalible in each session meaning a user mounted share will not be visible to NSClient++ (since services run in their own session). But as long as NSClient++ can access the share it still works as long as you specify the UNC path.
That comment from the Developers website says it all.

In think you are going to need to develop a solution like I described.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor mapped network drives

Post by jkinning »

Thanks. I'll see if I can come up with a powershell script to run as the user with mapped drives and output something like OK to a file for Nagios to monitor.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Monitor mapped network drives

Post by WillemDH »

Or you could just run NSCLient++ service with an account with permissions on the UNC path and monitor the full path instead of the mapped drive letter... I know I got this working somewhere.
Nagios XI 5.8.1
https://outsideit.net
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor mapped network drives

Post by lmiltchev »

Thanks WillemDH!
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor mapped network drives

Post by jkinning »

Yes, thanks WillemDH I'll give that a try.
Locked