Page 1 of 2
Monitor mapped network drives
Posted: Thu Feb 18, 2016 4:03 pm
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.
Re: Monitor mapped network drives
Posted: Thu Feb 18, 2016 5:58 pm
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:
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.
Re: Monitor mapped network drives
Posted: Fri Feb 19, 2016 7:10 am
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.
Re: Monitor mapped network drives
Posted: Fri Feb 19, 2016 3:12 pm
by hsmith
What version of NSClient are you running? I can try to lab this one up.
Re: Monitor mapped network drives
Posted: Fri Feb 19, 2016 3:45 pm
by jkinning
I (0.4.3.131 2015-02-15)
Re: Monitor mapped network drives
Posted: Sun Feb 21, 2016 5:39 pm
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.
Re: Monitor mapped network drives
Posted: Wed Feb 24, 2016 7:21 am
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.
Re: Monitor mapped network drives
Posted: Wed Feb 24, 2016 9:48 am
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.
Re: Monitor mapped network drives
Posted: Wed Feb 24, 2016 10:53 am
by lmiltchev
Thanks WillemDH!
Re: Monitor mapped network drives
Posted: Wed Feb 24, 2016 11:26 am
by jkinning
Yes, thanks WillemDH I'll give that a try.