How to create a python event handler for failure events


i defined event command for service/host aas per below syntax

event_command = “send_to_businesstool”

Now instead of below

object EventCommand “send_to_businesstool” {
command = [
“-X PUT”

arguments = {
“-H” = {
value ="$businesstool_url$"
skip_key = true
“-d” = “$businesstool_message$”

vars.businesstool_url = “http://localhost:8080/businesstool
vars.businesstool_message = “$$ $$ $service.state$ $service.state_type$ $service.check_attempt$”

How can i define event _command = python script , where python takes the input for host/service and reason of failure and do some business logic"

How can i implement this??

Mayank (AMdocs)


you are already using runtime macro strings which are evaluated from custom variables and object attributes. Everything already works and calls curl. If you prefer to move this into a dedicated python script, leave the EventCommand arguments “as is”, and only change the command pointing e.g. to PluginDir + "/".

The python script itself should implement argparser to receive the URL and message. In terms of API calls, the requests library is a good fit.