nrpe and bat file

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.
Locked
tuumk
Posts: 3
Joined: Tue Sep 08, 2015 2:56 am
Location: pl

nrpe and bat file

Post by tuumk »

helo i have a problem with execution bat file via nrpe service
check_select.bat:
echo off
for /F %%i in ('sqlcmd -S "127.0.0.1" -U "nagios" -P "112345" -i C:\nagios\test.sql') do (set count=%%i)
IF %count% LSS 1000 GOTO kok
IF %count% GTR 18000 GOTO war
:err
exit /b 2
:war
IF %count% GTR 19000 goto err
exit /b 1
:kok
exit /b 0

test.sql:
declare @ile int
select @ile= COUNT (*) from [pomiar].[dbo].[POMIAR_MPK]
print @ile
go

nsclient.ini:
; 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 = scripts
; BATCH FILE WRAPPING -
bat = scripts\\%SCRIPT% %ARGS%
[/settings/NRPE/server]
allow arguments = 1
allow nasty_meta chars = 1
use ssl = 1
; 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]
x=scripts\check_select.bat

when i run command:
./check_nrpe -H x.x.x.x -p 5666
I (0,4,1,101 2013-05-18) seem to be doing fine...

but when run
./check_nrpe -H x.x.x.x -p 5666 -c x
i have error
No handler for command: scripts\check_select.bat
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: nrpe and bat file

Post by hsmith »

Did you restart the NSClient service after changing the ini?
Former Nagios Employee.
me.
tuumk
Posts: 3
Joined: Tue Sep 08, 2015 2:56 am
Location: pl

Re: nrpe and bat file

Post by tuumk »

yes
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: nrpe and bat file

Post by hsmith »

Did you add/change this in the NSClient ini?

Code: Select all

[/modules]
; ...
CheckExternalScripts=enabled
Source: http://docs.nsclient.org/howto/external_scripts.html
Former Nagios Employee.
me.
tuumk
Posts: 3
Joined: Tue Sep 08, 2015 2:56 am
Location: pl

Re: nrpe and bat file

Post by tuumk »

; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: nrpe and bat file

Post by hsmith »

Hi tuumk,

After messing around with it a bit on my end, I am wonder how well the script path works. I was easily able to do what you're trying to accomplish by erasing the alias entry, and adding the following to the bottom of my .ini.


Code: Select all

[/settings/external scripts/scripts]
x=scripts\<yourfilename>.bat


It may not be ideal, but the script path seems to be not working that well for me.
Former Nagios Employee.
me.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: nrpe and bat file

Post by hsmith »

Former Nagios Employee.
me.
Locked