what's the best way to call one handler from inside another handler?

Just wondering if anyone tried to call one handler from another handler. The use case i have is that, there is a lot of logic in determine what should happen when an event is triggered. I want to write that business logic in one handler and then call other handlers(like email, or pagerduty) accordingly. For example.
I want to a custom handler for all keepalive event, it will check if the server still exists on aws, if it does, then use the existing pagerduty handler(if server exists but not report in, that’s bad), it the server does not exists in aws, delete the client from sensu server itself.

Another example, which i think is solved by sensu already, is alerting people based on hours, but i want to build on top of that with additional logics. Thanks for any help.

+1 to this feature… I’m interested into the same functionality…

We are thinking to use init6 when the server go off, remove from Sensu using the API, but I like the way you suggest this can be handled

I’ll like to get more feedback about this…

···

2013/8/27 Chaoran Xie chaoranxie@gmail.com

Just wondering if anyone tried to call one handler from another handler. The use case i have is that, there is a lot of logic in determine what should happen when an event is triggered. I want to write that business logic in one handler and then call other handlers(like email, or pagerduty) accordingly. For example.

I want to a custom handler for all keepalive event, it will check if the server still exists on aws, if it does, then use the existing pagerduty handler(if server exists but not report in, that’s bad), it the server does not exists in aws, delete the client from sensu server itself.

Another example, which i think is solved by sensu already, is alerting people based on hours, but i want to build on top of that with additional logics. Thanks for any help.

One approach would be to customize the handlers to meet your needs. If you have a set of logic that you want to use for all handlers, you could take the approach of the ‘escalation’ handler, and pull that out into an alternative handler superclass. See https://github.com/faja/sensu-community-plugins/tree/master/handlers/escalation

It should be possible to simply shell-out and call one handler from another if that meets your needs.

Alejandro, if you give some more detail about your use-case, folks might have some specific suggestions.

-Nick

···

On Tuesday, August 27, 2013 7:47:41 AM UTC-7, Alejandro Ferrari wrote:

+1 to this feature… I’m interested into the same functionality…

We are thinking to use init6 when the server go off, remove from Sensu using the API, but I like the way you suggest this can be handled

I’ll like to get more feedback about this…

2013/8/27 Chaoran Xie chaor...@gmail.com

Just wondering if anyone tried to call one handler from another handler. The use case i have is that, there is a lot of logic in determine what should happen when an event is triggered. I want to write that business logic in one handler and then call other handlers(like email, or pagerduty) accordingly. For example.

I want to a custom handler for all keepalive event, it will check if the server still exists on aws, if it does, then use the existing pagerduty handler(if server exists but not report in, that’s bad), it the server does not exists in aws, delete the client from sensu server itself.

Another example, which i think is solved by sensu already, is alerting people based on hours, but i want to build on top of that with additional logics. Thanks for any help.

Thanks Nick,

I was thinking about shell-out or using another handler like an ruby object, but dont know how you can pass the event data.( maybe even setting data around)

Using pagerduty handler as example. i assume you have to do something like this in ruby cat event_data.json | path_to/pagerduty.rb or echo #{event.to_json()} | path_to/pagerduty.rb

Or for ruby object way of things we need to do something like

pagerduty_handler = Pagerduty.new( somehow pass data to this object)

pagerduty_handler.handle() # Then run it.

Inherit from Sensu::Handler works like magic sometime(^_^), you dont have to write a lot of code, but i guess it make it harder to know what exactly happens during the life cycle of handler, how is it initialized and how is it run. Any help we the flow of handler execution will help greatly. Thanks again.

···

Resource

https://github.com/sensu/sensu-community-plugins/blob/master/handlers/notification/pagerduty.rb

Best wishes always,
Chaoran Xie

On Tue, Aug 27, 2013 at 11:46 AM, Nick Stielau <nick.stielau@gmail.com> wrote:

One approach would be to customize the handlers to meet your needs. If you have a set of logic that you want to use for all handlers, you could take the approach of the ‘escalation’ handler, and pull that out into an alternative handler superclass. See https://github.com/faja/sensu-community-plugins/tree/master/handlers/escalation

It should be possible to simply shell-out and call one handler from another if that meets your needs.

Alejandro, if you give some more detail about your use-case, folks might have some specific suggestions.

-Nick

On Tuesday, August 27, 2013 7:47:41 AM UTC-7, Alejandro Ferrari wrote:

1 to this feature… I’m interested into the same functionality…

We are thinking to use init6 when the server go off, remove from Sensu using the API, but I like the way you suggest this can be handled

I’ll like to get more feedback about this…

2013/8/27 Chaoran Xie <chaor…@gmail.com>

Just wondering if anyone tried to call one handler from another handler. The use case i have is that, there is a lot of logic in determine what should happen when an event is triggered. I want to write that business logic in one handler and then call other handlers(like email, or pagerduty) accordingly. For example.

I want to a custom handler for all keepalive event, it will check if the server still exists on aws, if it does, then use the existing pagerduty handler(if server exists but not report in, that’s bad), it the server does not exists in aws, delete the client from sensu server itself.

Another example, which i think is solved by sensu already, is alerting people based on hours, but i want to build on top of that with additional logics. Thanks for any help.