Page 1 of 2

CHECK_NRPE: Received 0 bytes from daemon

Posted: Wed Mar 30, 2016 10:57 am
by rambertnala
Dear friends. Hi from Spain.

I have a problem and i would like to know if it has solution or not.

I wanna execute a .bat file located in a server through nrpe. Let me explain you.

I have installed NSclient++ on host.

I have a .bat file in path C:\Program Files\NSClient++\scripts\custom named comando.bat. This one file only stops and starts some services.

When i call it from my nagios server

\path_to_nrpe\check_nrpe -H IP_HOST -t 60 -c command_remote

I received this message

CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages

If I connect to HOST (teamviewer or any other software ) I can see that comando.bat is being executed successfully.

What am i doing bad?

Thanks and regards

I'm using Nsclient++ 0.4.3.143

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Wed Mar 30, 2016 11:42 am
by tmcdonald
How long is comando.bat taking to run? If it takes too long, you might see this error.

We have a NRPE troubleshooting doc:

https://assets.nagios.com/downloads/nag ... utions.pdf

I would take a look at section 5 on page 6, that's where this error is detailed. This doc is for NRPE, so there might be some differences since you are using NRPE through NSClient.

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Thu Mar 31, 2016 6:15 am
by rambertnala
Hi friends.

command.bat takes about 30-45 seconds

regards

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Thu Mar 31, 2016 11:23 am
by rambertnala
Hi i send you my command.bat


net stop service1
taskkill /f /im process1.exe /im process2.exe /im process3.exe /im process4.exe /im process5.exe /im process6.exe /im process7.exe /im process8.exe /im process9.exe
net stop service2 && net stop service3 && net stop service4 && net stop service5
echo.
echo All Services stopped
echo.
echo Let's start Services
net start service4 && net start service5 && net start service3 && net start service2
net start service1
echo All Services started


Regards

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Thu Mar 31, 2016 11:43 am
by rkennedy
Can you try running it with a -t 120 to give the script a longer amount of time to respond?

Let us know if that helps.

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Fri Apr 01, 2016 5:29 am
by rambertnala
Hi friends.

I did it.

/usr/local/nagios/libexec/check_nrpe -H IP_HOST -t 120 -c exe_command

Same message

CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Fri Apr 01, 2016 6:06 am
by rambertnala
Log message

2016-04-01 12:58:32: error:D:\source\nscp\include\socket/connection.hpp:149: Failed to send data: El identificador de archivo proporcionado no es vĂ¡lido

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Fri Apr 01, 2016 10:35 am
by hsmith
That error is saying that the file handle is not valid, can we see your NSClient.ini with any sensitive information edited out?

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Mon Apr 04, 2016 5:01 am
by rambertnala
Hi

This is my nsclient.ini

I have removed my ip_server at allowed hosts line

Code: Select all

# If you want to fill this file with all avalible options run the following command:
#   nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
#   nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help


; Undocumented section


[/settings/default]

; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 127.0.0.1,ip_server

; PASSWORD - Password used to authenticate against server
password = 


; Undocumented section
[/settings/NRPE/server]

; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket.  default-workarounds	Various workarounds for what I understand to be broken ssl implementations no-sslv2	

Do not use the SSLv2 protocol. no-sslv3	Do not use the SSLv3 protocol. no-tlsv1	Do not use the TLSv1 protocol. single-dh-use	Always create a new key when using temporary/ephemeral DH parameters. 

This option must be used to prevent small subgroup attacks, when the DH parameters were not generated using "strong" primes (e.g. when using DSA-parameters).   
ssl options = no-sslv2,no-sslv3

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true

; PORT NUMBER - Port to use for NRPE.
port = 5666

; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket.  none	The server will not send a client certificate request to the client, so the client will not send a 

certificate. peer	The server sends a client certificate request to the client and the certificate returned (if any) is checked. fail-if-no-cert	if the client did not return a certificate, the 

TLS/SSL handshake is immediately terminated. This flag must be used together with peer. peer-cert	Alias for peer and fail-if-no-cert. workarounds	Various bug workarounds. single	Always create a 

new key when using tmp_dh parameters. client-once	Only request a client certificate on the initial TLS/SSL handshake. This flag must be used together with verify-peer   
verify mode = none

; ALLOW INSECURE CHIPHERS and ENCRYPTION - Only enable this if you are using legacy check_nrpe client.
insecure = true


; Undocumented section

[/modules]
NrpeListener.dll
CheckDisk.dll
CheckEventLog.dll
CheckExternalScripts.dll
CheckHelpers.dll
CheckLogFile.dll
CheckNSCP.dll
CheckSystem.dll
CheckTaskSched.dll
CheckWMI.dll
check_nrpe.dll
CommandClient.dll
DotnetPlugins.dll
GraphiteClient.dll
LUAScript.dll
NRDPClient.dll
NRPEClient.dll
NRPEServer.dll
NSCAClient.dll
NSCAServer.dll
NSClientServer.dll
PythonScript.dll
Scheduler.dll
SimpleCache.dll
SimpleFileWriter.dll
SMTPClient.dll
SyslogClient.dll
WEBServer.dll

; NSCAClient - NSCA client can be used both from command line and from queries to submit passive checks via NSCA
NSCAClient = 1

; CheckExternalScripts - Execute external scripts
CheckExternalScripts = 1

NRPEClient = 1

; CheckHelpers - Various helper function to extend other checks.
CheckHelpers = 1

; NSClientServer - A server that listens for incoming check_nt connection and processes incoming requests.
NSClientServer = 1

; CheckNSCP - Use this module to check the healt and status of NSClient++ it self
CheckNSCP = 1

; NRPEServer - A server that listens for incoming NRPE connection and processes incoming requests.
NRPEServer = 1

; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1

; CheckDisk - CheckDisk can check various file and disk related things.
CheckDisk = 1

; CheckEventLog - Check for errors and warnings in the event log.
CheckEventLog = 1



; A list of templates for wrapped scripts.
[/settings/external scripts/wrappings]

; WRAPPING - An external script wrapping
An alias is an internal command that has been predefined to provide a single command without arguments. Be careful so you don't create loops (ie check_loop = check_a, check_a=check_loop)

; WRAPPING - An external script wrapping
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%

; WRAPPING - An external script wrapping
bat = scripts\\%SCRIPT% %ARGS%

; WRAPPING - An external script wrapping
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -


[/settings/external scripts/alias]

; ALIAS - Query alias
alias_event_log = check_eventlog

; ALIAS - Query alias
alias_file_size = check_files "path=$ARG1$" "crit=size > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${size}" max-dir-depth=10

; ALIAS - Query alias
alias_mem = check_memory

; ALIAS - Query alias
alias_process = check_process "process=$ARG1$" "crit=state != 'started'"

; ALIAS - Query alias
alias_up = check_uptime

; ALIAS - Query alias
alias_service_ex = check_service "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc

; default - Alias for default. To configure this item add a section called: /settings/external scripts/alias/default
default = 

; ALIAS - Query alias
alias_cpu = check_cpu

; ALIAS - Query alias
alias_service = check_service

; ALIAS - Query alias
alias_process_hung = check_process "filter=is_hung" "crit=count>0"

; ALIAS - Query alias
alias_sched_long = check_tasksched "filter=status = 'running'" "detail-syntax=${title} (${most_recent_run_time})" "crit=most_recent_run_time < -$ARG1$"

; ALIAS - Query alias
alias_sched_task = check_tasksched show-all "filter=title eq '$ARG1$'" "detail-syntax=${title} (${exit_code})" "crit=exit_code ne 0"

; ALIAS - Query alias
alias_process_stopped = check_process "process=$ARG1$" "crit=state != 'stopped'"

; ALIAS - Query alias
alias_disk_loose = check_drivesize

; ALIAS - Query alias
alias_cpu_ex = check_cpu "warn=load > $ARG1$" "crit=load > $ARG2$" time=5m time=1m time=30s

; ALIAS - Query alias
alias_process_count = check_process "process=$ARG1$" "warn=count > $ARG2$" "crit=count > $ARG3$"

; ALIAS - Query alias
alias_volumes_loose = check_drivesize

; ALIAS - Query alias
alias_volumes = check_drivesize

; ALIAS - Query alias
alias_disk = check_drivesize

; ALIAS - Query alias
alias_sched_all = check_tasksched show-all "syntax=${title}: ${exit_code}" "crit=exit_code ne 0"

; ALIAS - Query alias
alias_file_age = check_files "path=$ARG1$" "crit=written > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${written}" max-dir-depth=10


[/settings/external scripts/scripts]

; Undocumented key
exe_command = scripts\custom\comando.bat
ps1 = cmd /c echo scripts\\check_test.ps1 %ARGS%; exit($lastexitcode) | powershell.exe -command -

; default - Alias for default. To configure this item add a section called: /settings/external scripts/scripts/default
default = 

[/settings/external scripts]

; COMMAND TIMEOUT - The maximum time in seconds that a command can execute. (if more then this execution will be aborted). NOTICE this only affects external commands not internal ones.
timeout = 60

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true


; A set of filters to use in real-time mode
[/settings/eventlog/real-time/filters]

; default - Filter for default. To configure this item add a section called: /settings/eventlog/real-time/filters/default
default =

Re: CHECK_NRPE: Received 0 bytes from daemon

Posted: Mon Apr 04, 2016 2:24 pm
by lmiltchev
Do you have any issues with running other check_nrpe checks? What is the output of the following command?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H IP_HOST