Page 1 of 2

NRPE timing out

Posted: Wed Jul 20, 2016 3:29 pm
by SavaSC
Hello,

I am trying to get Nagios to run a script on our web servers to verify that our whole logging in system is working. I have a PowerShell script that is working to do the checks. I have set up the following command:

Code: Select all

Define Command{ 
Command_Name     check_Login
command_line        $USER1$/check_nrpe -H $HOSTADDRESS$ -n -C foo.ps1
}
I created a Service to use this command and associated it with a Host.

The problem is that what is returned is:
(No output returned from plugin)
This script does take a bit to execute. I'm thinking that the delay is too long and Nagios gives up before it returns anything. I have checked the nrpe.cfg file and the command_timeout is 60. The check_nrpe command has a 45 second timeout. Each time I run the service check it takes no more than 10 seconds to return the error.

Any ideas what I'm doing wrong?

Thanks!

Re: NRPE timing out

Posted: Wed Jul 20, 2016 3:40 pm
by lmiltchev
Are you running NRPE with no SSL? Run the following commands from the command line, and show the output:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <client ip>
/usr/local/nagios/libexec/check_nrpe -H <client ip> -n
Can you also show us how your command is defined on the client (remote box)? Is the name of your command "foo.ps1"?

Also, to specify a command with check_nrpe you need to use "c", not "C"...

Example:

Code: Select all

./check_nrpe -H <client ip> -c <command>

Re: NRPE timing out

Posted: Thu Jul 21, 2016 12:00 pm
by SavaSC
Sorry to take so long to reply. I change to lower-case "c" and that did advance things. I then went looking through everything I have done and found some mistakes I made and corrected things. Now, I am getting the following error:
(Service check timed out after 60.01 seconds)
Apparently, I have an issue with the script communicating with NSClient++ because I have changed the script to only have two lines, and I still get this error. Here are the lines:
weblogin-savacentral-2012r2.ps1

Code: Select all

Write-Host "CRITICAL - Failed at login"
Exit 2
Here is my current setup.

nrpe.cfg

Code: Select all

command_timeout=120

connection_timeout=300
Check_nrpe command line

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c $ARG1$ $ARG2$
check_SavaConnect command line

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_SavaConnect -t 120
NSC.ini on client Win2012r2 server

Code: Select all

[Script Wrappings]
ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -


[External Scripts]
check_SavaConnect=cmd /c echo scripts\weblogin-savacentral-2012r2.ps1; exit($lastexitcode)| powershell.exe
*[edit due to clicking wrong button]*
Any ideas on what I have wrong?

Thanks!

Re: NRPE timing out

Posted: Thu Jul 21, 2016 12:14 pm
by ssax
What is the execution policy on the server? Open a powershell console and run this command:

Code: Select all

Get-ExecutionPolicy
You can set it to unrestricted with this command:

Code: Select all

Set-ExecutionPolicy unrestricted
Thank you

Re: NRPE timing out

Posted: Thu Jul 21, 2016 12:19 pm
by SavaSC
It is unrestricted.

Re: NRPE timing out

Posted: Thu Jul 21, 2016 12:28 pm
by ssax
Change your nsclient.ini to this, restart the nsclient service, test, and let us know the results:

Code: Select all

check_SavaConnec = cmd /c echo scripts\weblogin-savacentral-2012r2.ps1; exit($lastexitcode) | powershell.exe -command -

Re: NRPE timing out

Posted: Thu Jul 21, 2016 2:21 pm
by SavaSC
Now I get the following error:
-command- : The term '-command-' is not recognized as the name of a cmdlet

Re: NRPE timing out

Posted: Thu Jul 21, 2016 2:28 pm
by ssax
There should be a space in there:

Code: Select all

-command[SPACE]-
What version of NSClient++ are you using anyways? You can grab it from add/remove programs (programs and features).

Re: NRPE timing out

Posted: Thu Jul 21, 2016 2:40 pm
by SavaSC
Well, that got me a completely new error.
CRITICAL - Failed at login
There is already a NRPE check happening on this machine but it works fine. Not sure what "login" could be failing.

*EDIT*

Forgot the version. 0.3.9.328

Re: NRPE timing out

Posted: Thu Jul 21, 2016 3:10 pm
by rkennedy
SavaSC wrote:Well, that got me a completely new error.
CRITICAL - Failed at login
There is already a NRPE check happening on this machine but it works fine. Not sure what "login" could be failing.

*EDIT*

Forgot the version. 0.3.9.328
You indicated these were the only lines, so I believe the script is working as expected. -
Apparently, I have an issue with the script communicating with NSClient++ because I have changed the script to only have two lines, and I still get this error. Here are the lines:
weblogin-savacentral-2012r2.ps1

Code: Select all

    Write-Host "CRITICAL - Failed at login"
    Exit 2