Page 1 of 1
NRPE not giving the correct output
Posted: Tue Nov 24, 2020 1:54 am
by RebeccaIlene
Hi Team,
There is a custom powershell script that I am using to get the count of file in a folder.
When I run the powershell it gives the correct output but when the same command is checked in Nagios it gives the wrong output.
What can be causing this?
Powershell output:
PS C:\Program Files\NSClient++\scripts> .\check_file.ps1 -Path "\\folder.lan\Apps\Uat\*.CSV" -Time 6000 -crit 0
Ok: 2 files found - 8172_1_20201124104257.CSV 8170_1_20201124093016.CSV.|found_files=2;0;0;
PS C:\Program Files\NSClient++\scripts>
nsc_custom file command definition:
check_file_Apps_UAT=check_file.ps1 -Path "\\folder.lan\Apps\Uat\*.CSV" -Time 6000 -crit 0
Nagios output:
[root@hostname libexec]# ./check_nrpe -H $hostname$ -t 120 -c check_file_Apps_UAT
Critical: 0 files found - .|found_files=0;0;0;
Re: NRPE not giving the correct output
Posted: Tue Nov 24, 2020 5:03 pm
by dchurch
RebeccaIlene wrote:same command is checked in Nagios
If you mean by this that you're running this in the "Run Check Command" modal dialog from within the Nagios XI web interface, then that's a known issue. There's a bug in the escaping of the command when you run it from that dialog box.
Best workaround I can give is to take what that the command line says in the dialog, and try running that directly on the command line.
If you're still having issues, please post the contents of C:\Program Files (x86)\Nagios\NCPA\var\log\ncpa_listener.log
Re: NRPE not giving the correct output
Posted: Tue Nov 24, 2020 8:41 pm
by RebeccaIlene
Yes, have checked this in command line as well and it still throws the wrong output.
Re: NRPE not giving the correct output
Posted: Wed Nov 25, 2020 3:33 pm
by dchurch
Can you please post the contents of C:\Program Files (x86)\Nagios\NCPA\var\log\ncpa_listener.log
Re: NRPE not giving the correct output
Posted: Thu Nov 26, 2020 11:59 am
by RebeccaIlene
We are not using NCPA for this. Using NSClient ++
Re: NRPE not giving the correct output
Posted: Mon Nov 30, 2020 12:33 pm
by dchurch
I think the NRPE listener is having issues accessing the "\\folder.lan\Apps\Uat" directory. The NRPE listener runs as the Local System account by default. Under a Windows "domain," there's probably going to be difficulty granting that user access to network resources, since it's not a "domain" user - it's a system local one. The full name of the account it runs as is prefixed by your local machine name, e.g. MYCOMPUTERNAME\Local System.
What you could do to test this is pop open a shell as Local System and run your PowerShell script, but I wasn't able to get this working - probably due to my computer being joined to a domain.
If you open the Service in the Windows management console, you should be able to set the NSClient++ service's login user to someone with access to the Windows shared folder.
If you're still having issues, please post the contents of C:\Program Files\NSClient++\nsclient.log so we can diagnose further.
Re: NRPE not giving the correct output
Posted: Mon Jan 04, 2021 7:21 pm
by RebeccaIlene
This is fixed now. The NSClient service was running using the local account rather than the service account that has access.
After updating the service to run with the service account it worked.
You can close this case.
Re: NRPE not giving the correct output
Posted: Tue Jan 05, 2021 7:21 am
by scottwilkerson
RebeccaIlene wrote:This is fixed now. The NSClient service was running using the local account rather than the service account that has access.
After updating the service to run with the service account it worked.
You can close this case.
Locking thread