NSClient++ Help (#1) - check_nrpe script.bat ARGS (#1023) - Message List

check_nrpe script.bat ARGS

Hi, I've installed nsclient on a Win XP pro PC. My aim is to place a check_host routine on this machine (router not reachable from Nagios server). To this, i fire a batch file whom does the ping for nagios. This ping_remote.bat file comes from

https://www.monitoringexchange.org/inventory/Check-Plugins/Network/-ping_remote-bat---with-check_nrpe---nsclient-

Here are the informations: Communication between Nagios server and nsclient seem to be good:

root@TerraNova:/usr/local/nagios/libexec# ./check_nt -H 10.1.20.83 -p 12489 -v CLIENTVERSION

Return : NSClient++ 0,4,0,172 2012-05-08

root@TerraNova:/usr/local/nagios/libexec# ./check_nrpe -H 10.1.20.83

Return : I (0,4,0,172 2012-05-08) seem to be doing fine...

BUT, of course there is one problem! When I try to send a command thru nrpe, it doesn't work

I, thing the problem is in my nsclient.ini file. So here is the return of this command:

 ./check_nrpe -H 10.1.20.83 -c ping_remote -t 90 -a 10.1.20.54 65 450,1 700,5

give:

%ARGS1%%ARGS2%%ARGS3%%ARGS4%%ARGS5%%ARGS6%
Usage:ping_remote <host_address> <Packets><wrta>,<wpl> <crta>,<cpl>
example:  /usr/local/nagios/libexec/check_nrpe -H 172.19.48.139 -c ping_remote -t 90 -a 172.19.88.30 65 450,1 700,5 (From Nagios SVR.)
       : ping_remote 192.168.0.1 5 200,1 400,10 (From a local win wks where ping_remote.bat resides)
       : (wpl\cpl are in percent, without the "%" symbol!!)

my nsclient.ini:

[/modules]
; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1
; NRPE server - A simple server that listens for incoming NRPE connection and handles them. NRPE is preferred over NSClient as it is more flexible. You can of cource use both NSClient and NRPE.
NRPEServer = 1
; NSClient server - A simple server that listens for incoming NSClient (check_nt) connection and handles them. Although NRPE is the preferred method NSClient is fully supported and can be used for simplicity or for compatibility.
NSClientServer = 1
; Section for NRPE (NRPEListener.dll) (check_nrpe) protocol options.
[/settings/NRPE/server]
; 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
; 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
; PORT NUMBER - Port to use for NRPE.
port = 5666
; Section for configuring the crash handler.
[/settings/crash]
; ARCHIVE CRASHREPORTS - Archive crash reports in the archive folder
archive = true
; CRASH ARCHIVE LOCATION - The folder to archive crash dumps in
archive folder = ${shared-path}/crash-dumps
; RESTART - Submit crash reports to nsclient.org (or your configured submission server)
restart = true
; RESTART SERVICE NAME - The url to submit crash reports to
restart target = NSClientpp
; SUBMIT CRASHREPORTS - Submit crash reports to nsclient.org (or your configured submission server)
submit = false
; SUBMISSION URL - The url to submit crash reports to
submit url = http://crash.nsclient.org/submit
; Section for external scripts configuration options (CheckExternalScripts).
[/settings/external scripts]
; 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
; 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
; SCRIPT DIRECTORY - Load all scripts in a directory and use them as commands. Probably dangerous but useful if you have loads of scripts :)
script path =
; 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
; A list of templates for wrapped scripts
[/settings/external scripts/wrappings]
; BATCH FILE WRAPPING -
bat = scripts\\%SCRIPT% %ARGS%
; POWERSHELL WRAPPING -
;ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
; VISUAL BASIC WRAPPING -
;vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
[CheckExternalScripts]
bat = scripts\\%SCRIPT% %ARGS%
; Section for configuring the log handling.
[/settings/log]
; DATEMASK - The size of the buffer to use when getting messages this affects the speed and maximum size of messages you can recieve.
date format = %Y-%m-%d %H:%M:%S
; FILENAME - The file to write log data to. Set this to none to disable log to file.
file name = ${exe-path}/nsclient.log
; LOG LEVEL - Log level to use. Avalible levels are error,warning,info,debug,trace
level = debug
; Configure log file properties.
[/settings/log/file]
; MAXIMUM FILE SIZE - When file size reaches this it will be truncated to 50% if set to 0 (default) truncation will be disabled
max size = 0
; Section for configuring the shared session.
[/settings/shared session]
; LOG LEVEL - Log level to use
enabled = true
[/settings/default]
; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 10.1.20.100
; CACHE ALLOWED HOSTS - If hostnames should be cached, improves speed and security somewhat but wont allow you to have dynamic IPs for your nagios server.
cache allowed hosts = true
; SSL CERTIFICATE - Configure which SSL certificate to use (DH key)
certificate = ${certificate-path}/nrpe_dh_512.pem
; TIMEOUT - Timeout when reading packets on incoming sockets. If the data has not arrived within this time we will bail out.
timeout = 30
; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = false
; A list of aliases available. An alias is an internal command that has been "wrapped" (to add arguments). Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
[/settings/external scripts/alias]
pping=ping_remote
; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]
;ping_remote=scripts\\ping_remote.bat 10.1.20.54 5 450,1 700,5
ping_remote=scripts\\ping_remote.bat %ARGS1% %ARGS2% %ARGS3% %ARGS4% %ARGS5% %ARGS6%
; A list of wrappped scripts (ie. using the template mechanism)
[/settings/external scripts/wrapped scripts]

So if i use pping it send directly the commands and it works (from nsclient in test or from nagios) But if if I try with ping_remote -t 90 -a 10.1.20.54 65 450,1 700,5 event from nsclient in test mode I received :

%ARGS1%%ARGS2%%ARGS3%%ARGS4%%ARGS5%%ARGS6%
Usage:ping_remote <host_address> <Packets><wrta>,<wpl> <crta>,<cpl>
example:  /usr/local/nagios/libexec/check_nrpe -H 172.19.48.139 -c ping_remote -t 90 -a 172.19.88.30 65 450,1 700,5 (From Nagios SVR.)
       : ping_remote 192.168.0.1 5 200,1 400,10 (From a local win wks where ping_remote.bat resides)
       : (wpl\cpl are in percent, without the "%" symbol!!)

I've try to change % with $ for ARGS but without any result. I think the problem is coming from something that I've mist in the config file. It doesn't give the ARGS as parameter.

If I start manually the .bat script, it accomplished is task correctly.

Can anybody help me with this issue?

Cheers

Elplubio

  • Message #2699

    Response to myself,

    The problem was locate in scripts/scripts part.

    The ARGS have to be send like this $ARGn$ where n is a number. so line become

    ping_remote=scripts\\ping_remote.bat $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
    

    SO PROBLEM SOLVED

Subscriptions