Page 1 of 1

Event Handlers

Posted: Thu Feb 02, 2012 4:11 am
by aregis1973
Hi,

We have a host (Windows 2008) with a service (IIS) and created a command for the event handler. Below is the information on the command.

Code: Select all

define command {
       command_name                             check_iiswebserver_handler
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_iiswebserver
}
Information for the Service

Code: Select all

define service {
        host_name                       HOST
        service_description             IIS Web Server
        use                             xiwizard_windowsserver_nsclient_service
        check_command                   check_xi_service_nsclient!!SERVICESTATE!-l W3SVC -d SHOWALL!!!!!
        max_check_attempts              10
        check_interval                  1
        retry_interval                  1
        event_handler                   check_iiswebserver_handler
        event_handler_enabled           1
        notification_interval           60
        contacts                        user
        contact_groups                  Administrators
        register                        1
        }
Here's the script for the check_iiswebserver.bat in the host.

Code: Select all

net start W3SVC
Below is the NSC.ini file.

Code: Select all

[modules]
NRPEListener.dll
NSClientListener.dll
CheckWMI.dll
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
CheckEventLog.dll
CheckHelpers.dll
NSClientListener.dll
NRPEListener.dll
CheckExternalScripts.dll
NRPEClient.dll
[crash]
[Settings]
allowed_hosts=xx.xx.xx.xx
use_file=1
[log]
[NSClient]
[NRPE]
[Check System]
[External Script]
allow_arguments=1
script_dir=C:\Program Files\NSClient++\scripts

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

[External Scripts]
check_iiswebserver=scripts\check_iiswebserver.bat

[External Alias]
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_cpu_ex=checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual 

type=paged type=page
alias_up=checkUpTime MinWarn=1d MinWarn=1h

alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_disk_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-

unreadable
alias_volumes=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED
alias_volumes_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED 

ignore-unreadable 

alias_service=checkServiceState CheckAll
alias_service_ex=checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver 

HPZ12" exclude=stisvc
alias_process=checkProcState "$ARG1$=started"
alias_process_stopped=checkProcState "$ARG1$=stopped"
alias_process_count=checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"
alias_process_hung=checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"

alias_event_log=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 

"filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 

'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%

count%)"

alias_file_size=CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 

"syntax=%filename% %size%" max-dir-depth=10
alias_file_age=checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 

"syntax=%filename% %write%"

alias_sched_all=CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" 

warn=>0
alias_sched_long=CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -

$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_sched_task=CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%

title% (%most_recent_run_time%)" warn=>0

alias_updates=check_updates -warning 0 -critical 0

check_ok=CheckOK Everything is fine!

[Wrapped Scripts]

[NSCA Agent]
[NSCA Commands]
[NRPE Client Handlers]
check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments
Event handler runs fine without arguments but we need to pass arguments $SERVICESTATE$ $SERVICESTATETYPE$ but unable to do so.

Are there any other setups needed for this?

Thanks.

Re: Event Handlers

Posted: Thu Feb 02, 2012 10:41 am
by scottwilkerson
aregis1973 wrote:Hi,

We have a host (Windows 2008) with a service (IIS) and created a command for the event handler. Below is the information on the command.

Code: Select all

define command {
       command_name                             check_iiswebserver_handler
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_iiswebserver
}
...

Below is the NSC.ini file.
...

[External Scripts]
check_iiswebserver=scripts\check_iiswebserver.bat

...
[/code]

Event handler runs fine without arguments but we need to pass arguments $SERVICESTATE$ $SERVICESTATETYPE$ but unable to do so.

Are there any other setups needed for this?

Thanks.
You would need to add these to the check command as well as the NSC.ini something like this

Code: Select all

define command {
       command_name                             check_iiswebserver_handler
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_iiswebserver -a '-s $SERVICESTATE$ -t $SERVICESTATETYPE$'
}
and NSC.ini

Code: Select all

[External Scripts]
check_iiswebserver=scripts\check_iiswebserver.bat $ARG1$
or something like that and then you will need to add the handeling of the args in the check_iiswebserver.bat file