Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
eduard_guloiu
byeduard_guloiu, August 3, 2012
The plugin does not return status data / perf data when everything is ok. it gets to :subroutine and then jumps to eof.
This is what works for me (just added goto end before :subroutine) :
@ECHO OFF
setlocal EnableDelayedExpansion
REM -------------------------------------------
REM - Version 0.4 - By briandent@redshift.com
REM - Original Version
REM -------------------------------------------
REM - Version 0.5 - By julienchpt@gmail.com
REM - ADD CRITICAL AND WARNING STATUS
REM -------------------------------------------
REM - Version 0.6 - By roberto.mereu@gmail.com
REM - ADD USERNAME LOGGED IN
REM -------------------------------------------
REM USAGE: check_user_count warn crit
REM warn: Number of session before warning
REM crit: Number of session before Critical
REM Example: check_user_count 2 4
REM -------------------------------------------
REM CALLING SEQUENCE:
REM command[nrpe_nt_check_users]=c:nrpe_ntpluginscheck_user_count.bat $ARG1$ $ARG2$
REM -------------------------------------------
set EX=0
set MS=OK
SET /a COUNT=0
SET USER=
FOR /f "TOKENS=1" %%i IN ('query session ^|find "rdp-tcp#"') DO SET /a COUNT+=1
FOR /f "TOKENS=2" %%G IN ('query session ^|find "rdp-tcp#"') DO (
call :subroutine %%G
)
REM - WARNING (COUNT => $1)
if %COUNT% GEQ %1 ( set EX=1 && set MS=WARNING && goto end )
REM - CRITICAL (COUNT => $2)
if %COUNT% GEQ %2 ( set EX=2 && set MS=CRITICAL && goto end )
goto end
:subroutine
SET USER=%USER% %1
GOTO :eof
:end
ECHO %MS% Number of active sessions = %COUNT% Logged Users = !USER! ^| usersconnected=%COUNT%
EXIT /b %EX%
This is what works for me (just added goto end before :subroutine) :
@ECHO OFF
setlocal EnableDelayedExpansion
REM -------------------------------------------
REM - Version 0.4 - By briandent@redshift.com
REM - Original Version
REM -------------------------------------------
REM - Version 0.5 - By julienchpt@gmail.com
REM - ADD CRITICAL AND WARNING STATUS
REM -------------------------------------------
REM - Version 0.6 - By roberto.mereu@gmail.com
REM - ADD USERNAME LOGGED IN
REM -------------------------------------------
REM USAGE: check_user_count warn crit
REM warn: Number of session before warning
REM crit: Number of session before Critical
REM Example: check_user_count 2 4
REM -------------------------------------------
REM CALLING SEQUENCE:
REM command[nrpe_nt_check_users]=c:nrpe_ntpluginscheck_user_count.bat $ARG1$ $ARG2$
REM -------------------------------------------
set EX=0
set MS=OK
SET /a COUNT=0
SET USER=
FOR /f "TOKENS=1" %%i IN ('query session ^|find "rdp-tcp#"') DO SET /a COUNT+=1
FOR /f "TOKENS=2" %%G IN ('query session ^|find "rdp-tcp#"') DO (
call :subroutine %%G
)
REM - WARNING (COUNT => $1)
if %COUNT% GEQ %1 ( set EX=1 && set MS=WARNING && goto end )
REM - CRITICAL (COUNT => $2)
if %COUNT% GEQ %2 ( set EX=2 && set MS=CRITICAL && goto end )
goto end
:subroutine
SET USER=%USER% %1
GOTO :eof
:end
ECHO %MS% Number of active sessions = %COUNT% Logged Users = !USER! ^| usersconnected=%COUNT%
EXIT /b %EX%