NRPE timing out

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

NRPE timing out

Post 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!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NRPE timing out

Post 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>
Be sure to check out our Knowledgebase for helpful articles and solutions!
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

Re: NRPE timing out

Post 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!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE timing out

Post 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
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

Re: NRPE timing out

Post by SavaSC »

It is unrestricted.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE timing out

Post 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 -
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

Re: NRPE timing out

Post by SavaSC »

Now I get the following error:
-command- : The term '-command-' is not recognized as the name of a cmdlet
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE timing out

Post 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).
SavaSC
Posts: 238
Joined: Wed Feb 23, 2011 4:49 pm

Re: NRPE timing out

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: NRPE timing out

Post 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
Former Nagios Employee
Locked