nrpe and bat file
Posted: Tue Sep 22, 2015 2:47 am
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
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