How to if network drive is mapped


I use nrpe_nt that runs a simple script on the host.

@echo off
if exist p:\nagioscheck.txt GOTO :ok
echo "P-drive nakijken !!!"
exit 2
echo "P-drive OK"
exit 0

If i run it locally it works perfect. When i run it from nagiosserver keeps telling P-drive doens’t exist.
I think it has something to do with the evironment. Has someone a working situation for checking network drive?

Thans in advance



I think you’re right about the environment: in fact, nrpe may not see the drive as mounted.
A way to do that would be to mount it before running the test, with a command like "net use p: \your_host\your_path
which would mount the drive every time you do the test … and that’s a silly idea, cause if the drive fails, the test would mount it again and return OK
=> maybe you could mount it at windows startup, with the same command line ?

Hope this helps


The drive is already mounted when windows starts-up via the login script.

I also used the /persistent:YES option ( mount for every user )
And i also started the nrpe service as the domain admin user.

I’m sure it’s a envirnment problem because i altered my script with if not exist and returned the same result.
P-drive doesn’t exist, so my script runs perfectly but it can’t find mounted drive.

@echo off
if not exist p:\nagioscheck.txt GOTO :nok
echo "P-drive OK"
exit 0
echo "P-drive doenst’ exist "
exit 2