I have a Nagios host which is monitoring Windows servers using NRPE. One of the tasks is to remotely connect to a Windows Server, using NRPE, and run a Python script.
The python script simply checks the status of some backups. The Python scripts uses a module called 'win_unc' which is used to connect to a network share.
When I run the script directly and locally on the Windows Server it runs fine. When the script is called by NRPE remotely we get the following error:
<class 'win_unc.errors.ShellCommandError'>
()
The command `NET USE "\\X.X.X.X\backups" "PasswordRemoved" /USER:"UserRemoved" /PERSISTENT:NO` exited with error code 2.
Is the issue because the Nagios box, calling the script, cannot run the 'NET USE...' command?
I'm not aware of any reason why NRPE would have
net use
blocked. I would instead suspect the account NRPE is running under on the Windows box (probably Local System). Try creating a service account to run NRPE (preferably a Managed Service Account).