Page 1 of 2

External check windows

Posted: Tue Sep 27, 2016 6:17 am
by nagiosjam
Hello
I have problems when running outside of Windows servers check
For example, with plugins that come by default.
C: \ Program Files \ NSClient ++ \ scripts \ check_test.ps1
My configuration file nsclient.ini

[/ Settings / external scripts / wrappings]
ps1 = cmd / c I miss scripts SCRIPT \\%%% ARGS%; exit ($ lastexitcode) | Bypass -ExecutionPolicy powershell.exe -command -

[/ Settings / external scripts / wrapped scripts]
test_ps = check_test.ps1

First test, from my nagios server run from the directory
/ Usr / local / nagios / libexec

check_nrpe - H ipserver1
I (0.4.2.114 01/08/2015) seem to be doing fine ... OK !!!!

And I run the check test_ps

./check_nrpe ipserver1 -c -H test_ps

Unknown command (s): test_ps

What am I doing wrong?

Please help
Greetings and thanks

Re: External check windows

Posted: Tue Sep 27, 2016 9:07 am
by nagiosjam
I restarted the service and nsclient and plugins I work with .vbs extension ps1 and bat
But I have one .exe extension and it does not work
./check_nrpe ipserver1 -c -H check_tcp
Unknown command (s): check_tcp

In the nsclient.ini file I have the following alias

[/ Settings / external scripts / wrapped scripts]

check_tcp = check_tcp.exe

And in the C: \ Program Files \ NSClient ++ \ scripts have the file check_tcp.exe

Why not me files with .exe extension work?

Do I have to define it in the nsclient.ini file?

The other extensions, if they work, I have them set in the file as follows nsclient.ini

[/ Settings / external scripts / wrappings]

bat SCRIPT = scripts \\%%% ARGS%
ps1 = cmd / c I miss scripts SCRIPT \\%%% ARGS%; exit ($ lastexitcode) | Bypass -ExecutionPolicy powershell.exe -command -
vbs = cscript.exe // T: 30 // NoLogo scripts \

The plugin

https://exchange.nagios.org/directory/P ... cp/details

Thank you !!!

Re: External check windows

Posted: Tue Sep 27, 2016 1:11 pm
by lmiltchev
This plugin seems to be working fine for me. I placed the "check_tcp.exe" in the NSClient++ scripts directory, and set up a command in the nsclient.ini as such:

Code: Select all

check_tcp = scripts\check_tcp.exe -H $ARG1$ -p $ARG2$ -w $ARG3$ -c $ARG4$
Testing it from the CLI on the Nagios server gives me:

Code: Select all

[root@localhost ~]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_tcp -a x.x.x.x 5666 100 200
TCP OK - 0.002 second response time on port 5666 |'time'=0.00195s
The usage is:

Code: Select all

[root@localhost ~]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_tcp -a -h
scripts\check_tcp.exe (nagios-plugin)

scripts\check_tcp.exe -H <host> -p <port> -w <milliseconds> -c <milliseconds>
<host>    Hostname to test port connection
<port>    Port to connect to
-w        warning
-c        critical

Re: External check windows

Posted: Wed Sep 28, 2016 2:10 am
by nagiosjam
Hello
I added to my file nsclient.ini
exe = cmd / c% SCRIPT%% ARGS%

nsclient.ini

[/ Settings / external scripts]
allow arguments = true
allow = true nasty characters
timeout = 90

[/ Settings / external scripts / wrappings]
bat SCRIPT = scripts \\%%% ARGS%
ps1 = cmd / c I miss scripts SCRIPT \\%%% ARGS%; exit ($ lastexitcode) | powershell.exe -command -
vbs = cscript.exe // T: 90 // \\ lib \\ NoLogo scripts SCRIPT wrapper.vbs%%% ARGS%
exe = cmd / c% SCRIPT%% ARGS%

[/ Settings / external scripts / scripts]

check_tcp = scripts \ check_tcp.exe -H $ ARG1 $ -p $ ARG2 $ -w $ ARG3 $ -c $ ARG4 $

We have advanced a step no longer :-) I get the error Unknown command (s): check_tcp

I run from the server console my nagios this command

/ Usr / local / nagios / libexec / check_nrpe -c -H IPSERVER1 check_tcp IPSERVER1 5666 100 200

and I returns this error

gethostbyname () failed
TCP CRITICAL -?. ??? second response time on port $ ARG2 $ | 'time' = 0 ????? s

Please help
Thank you !!!

Re: External check windows

Posted: Wed Sep 28, 2016 9:58 am
by rkennedy
Could you post your entire nsclient configuration file for us to look at? It's pretty picky where things are placed, so we may just need to move one line to another section.

Re: External check windows

Posted: Wed Sep 28, 2016 10:10 am
by nagiosjam

Code: Select all

# For details run: nscp settings --help


; Undocumented section
[/modules]

; Undocumented key
CheckDisk = 1

; Undocumented key
CheckEventLog = 1

; Undocumented key
CheckExternalScripts = 1

; Undocumented key
CheckHelpers = 1

; Undocumented key
CheckNSCP = 1

; Undocumented key
CheckSystem = 1

; Undocumented key
CheckWMI = 1

; Undocumented key
NRPEServer = 1

; Undocumented key
NSClientServer = 1


; Undocumented section
[/settings/default]

; Undocumented key
allowed hosts = 10.10.10.10

; Undocumented key
password = xxxx

[/settings/external scripts]
allow arguments = true
allow nasty characters = true
timeout = 90

[/settings/external scripts/wrappings]
bat = scripts\\%SCRIPT% %ARGS%
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
vbs = cscript.exe //T:90 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
exe = cmd /c %SCRIPT% %ARGS%


[/settings/external scripts/wrapped scripts]

test_bat = check_ok.bat
test_ps = check_test.ps1
test_vbs = check_test.vbs
test_ping = check_ping.bat
test_files = check_files.vbs
test_battery = check_battery.vbs
test_printers = check_printer.vbs
check_test = check_test.ps1

[/settings/external scripts/scripts]

check_tcp = scripts\check_tcp.exe -H $ARG1$ -p $ARG2$ -w $ARG3$ -c $ARG4$

Re: External check windows

Posted: Wed Sep 28, 2016 11:44 am
by lmiltchev
/ Usr / local / nagios / libexec / check_nrpe -c -H IPSERVER1 check_tcp IPSERVER1 5666 100 200
I am not sure why you have "Usr" (capital "U"), spaces in the command, you are passing "-c" before "-H", you are missing "-a"... This is NOT what I showed you.
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_tcp -a x.x.x.x 5666 100 200
Try running:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H IPSERVER1 -c check_tcp -a IPSERVER1 5666 100 200

Re: External check windows

Posted: Thu Sep 29, 2016 1:30 am
by nagiosjam
At first he had with -a but I always mistake, I have run with no -a -a and here you can see the result
Thank you

[root@ipserver1 servicegroups]# /usr/local/nagios/libexec/check_nrpe -H ipserver1 -c check_tcp -a ipserver1 5666 100 200
Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).

[root@ipserver1 servicegroups]# /usr/local/nagios/libexec/check_nrpe -H ipserver1 -c check_tcp ipserver1 5666 100 200
gethostbyname() failed
TCP CRITICAL - ?.??? second response time on port $ARG2$ |'time'=0?????s

Re: External check windows

Posted: Thu Sep 29, 2016 2:46 am
by Box293
nagiosjam wrote:[root@ipserver1 servicegroups]

Code: Select all

# /usr/local/nagios/libexec/check_nrpe -H ipserver1 -c check_tcp -a ipserver1 5666 100 200
Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).
Can you follow the steps in this KB article to enable arguments:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: External check windows

Posted: Thu Sep 29, 2016 7:02 am
by nagiosjam
Hello
thanks but those lines and have in my file nsclient.ini

allow arguments = true