External check windows

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
nagiosjam
Posts: 81
Joined: Thu Feb 04, 2016 2:47 am

External check windows

Post 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
Last edited by dwhitfield on Fri Oct 07, 2016 11:03 am, edited 1 time in total.
Reason: marking with green check mark
nagiosjam
Posts: 81
Joined: Thu Feb 04, 2016 2:47 am

Re: External check windows

Post 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 !!!
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: External check windows

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagiosjam
Posts: 81
Joined: Thu Feb 04, 2016 2:47 am

Re: External check windows

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

Re: External check windows

Post 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.
Former Nagios Employee
nagiosjam
Posts: 81
Joined: Thu Feb 04, 2016 2:47 am

Re: External check windows

Post 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$
Last edited by tmcdonald on Wed Sep 28, 2016 11:30 am, edited 1 time in total.
Reason: Please use [code][/code] tags around long output
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: External check windows

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagiosjam
Posts: 81
Joined: Thu Feb 04, 2016 2:47 am

Re: External check windows

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: External check windows

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
nagiosjam
Posts: 81
Joined: Thu Feb 04, 2016 2:47 am

Re: External check windows

Post by nagiosjam »

Hello
thanks but those lines and have in my file nsclient.ini

allow arguments = true
Locked