Campfire handler


#1

Hello,

I’m having trouble getting the Campfire handler to work.

Sensu: 0.12

Ruby: embedded

/etc/sensu/conf.d/campfire.json

{

“campfire”: {

"room": "Alerts",

"room_id" : "999999"

"account": "myaccount",

"token": "my campfire token"

}

}

/etc/sensu/conf.d/handler_campfire.json

{

“handlers”: {

“campfire”: {

“type”: “pipe”,

  "command": "/etc/sensu/handlers/campfire.rb"

}

}

}

In /var/log/sensu/sensu-server.log I see

{“timestamp”:“2014-02-10T01:52:51.329483+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"/etc/sensu/handlers/campfire.rb:35:in room': undefined method’ for nil:NilClass (NoMethodError)\n"}

{“timestamp”:“2014-02-10T01:52:51.329723+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /etc/sensu/handlers/campfire.rb:52:in `block in handle’\n"}

{“timestamp”:“2014-02-10T01:52:51.329835+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout’\n"}

{“timestamp”:“2014-02-10T01:52:51.329938+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout’\n"}

{“timestamp”:“2014-02-10T01:52:51.330031+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /etc/sensu/handlers/campfire.rb:51:in `handle’\n"}

{“timestamp”:“2014-02-10T01:52:51.330126+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb:41:in `block in class:Handler’\n"}

If I try /opt/sensu/embedded/bin/ruby /etc/sensu/handlers/campfire.rb I get nothing.

I’ve got the mailer.rb handler working. But after a few hours I’ve not gotten any further with campfire.

Any ideas?

thanks,

Luke


#2

Hey Luke,

Your config looks OK to me, not sure what the issue is. You can always try piping an example JSON payload to the handler [1] (just running it directly probably won’t do much). You might try to debug the configs while your at it, i.e. ‘puts settings.inspect’ in the #room method.

Good luck!

[1] https://gist.github.com/joemiller/1723079/

···

On Sunday, February 9, 2014 6:04:36 PM UTC-8, Luke Tymowski wrote:

Hello,

I’m having trouble getting the Campfire handler to work.

Sensu: 0.12

Ruby: embedded

/etc/sensu/conf.d/campfire.json

{

“campfire”: {

"room": "Alerts",
"room_id" : "999999"
"account": "myaccount",
"token": "my campfire token"

}

}

/etc/sensu/conf.d/handler_campfire.json

{

“handlers”: {

“campfire”: {

“type”: “pipe”,

  "command": "/etc/sensu/handlers/campfire.rb"

}

}

}

In /var/log/sensu/sensu-server.log I see

{“timestamp”:“2014-02-10T01:52:51.329483+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"/etc/sensu/handlers/campfire.rb:35:in room': undefined method’ for nil:NilClass (NoMethodError)\n"}

{“timestamp”:“2014-02-10T01:52:51.329723+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /etc/sensu/handlers/campfire.rb:52:in `block in handle’\n"}

{“timestamp”:“2014-02-10T01:52:51.329835+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout’\n"}

{“timestamp”:“2014-02-10T01:52:51.329938+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:97:in `timeout’\n"}

{“timestamp”:“2014-02-10T01:52:51.330031+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /etc/sensu/handlers/campfire.rb:51:in `handle’\n"}

{“timestamp”:“2014-02-10T01:52:51.330126+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"\tfrom /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb:41:in `block in class:Handler’\n"}

If I try /opt/sensu/embedded/bin/ruby /etc/sensu/handlers/campfire.rb I get nothing.

I’ve got the mailer.rb handler working. But after a few hours I’ve not gotten any further with campfire.

Any ideas?

thanks,

Luke


#3

Your config looks OK to me, not sure what the issue is. You can always
try piping an example JSON payload to the handler [1] (just running it
directly probably won't do much). You might try to debug the configs while
your at it, i.e. 'puts settings.inspect' in the #room method.

Actually, my problem was with my config. :frowning:
/etc/sensu/conf.d/campfire.json

{

  "campfire": {

    "room": "Alerts",

    "room_id" : "999999"

    "account": "myaccount",

    "token": "my campfire token"

  }
}

Notice the missing comma on the room_id line.
Saw that first thing this morning but didn't/couldn't see it on the weekend.

But I now have two other problems. Sensu is posting to Campfire every 15
occurrences, but my check says to notify on every 1 occurrence. The mailer
handler is behaving as expected here. Is this a bug?

And I've got what looks like Ruby SSL errors.

{"type":"pipe","command":"/etc/sensu/handlers/*campfire*.rb","name":"
*campfire*"},"output":"/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:918:in
`connect': SSL_connect returned=1 errno=0 state=SSLv3 read server
certificate B: certificate verify failed
(Faraday::Error::ConnectionFailed)\n"}

Fletcher talks about that problem here, I think:

Luke


#4

Look at the ‘refresh’ attribute. Set it equal to the interval to get alerts updates every run. The “occurences” attribute is the time to the first alert, whereas “refresh” is the time between updates (i.e. re-handling).

I made a PR to help with the debugging UX, but it really could be more helpful with JSON. I’ll take a look at that as well.

https://github.com/sensu/sensu-plugin/pull/62

···

On Mon, Feb 10, 2014 at 9:16 AM, Luke Tymowski ltymowski@gmail.com wrote:

:peace_symbol:

Nick Stielau
206-245-7991

Your config looks OK to me, not sure what the issue is. You can always try piping an example JSON payload to the handler [1] (just running it directly probably won’t do much). You might try to debug the configs while your at it, i.e. ‘puts settings.inspect’ in the #room method.

Actually, my problem was with my config. :frowning:

/etc/sensu/conf.d/campfire.json

{

“campfire”: {

“room”: “Alerts”,

“room_id” : “999999”

“account”: “myaccount”,

“token”: “my campfire token”

}

}

Notice the missing comma on the room_id line.

Saw that first thing this morning but didn’t/couldn’t see it on the weekend.

But I now have two other problems. Sensu is posting to Campfire every 15 occurrences, but my check says to notify on every 1 occurrence. The mailer handler is behaving as expected here. Is this a bug?

And I’ve got what looks like Ruby SSL errors.

{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:918:in `connect’: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::Error::ConnectionFailed)\n"}

Fletcher talks about that problem here, I think:

https://gist.github.com/fnichol/867550

Luke


#5

Here’s a pass at better JSON error messages:
https://github.com/sensu/sensu-plugin/pull/63

···

On Mon, Feb 10, 2014 at 9:54 AM, Nick Stielau nick.stielau@gmail.com wrote:

Look at the ‘refresh’ attribute. Set it equal to the interval to get alerts updates every run. The “occurences” attribute is the time to the first alert, whereas “refresh” is the time between updates (i.e. re-handling).

I made a PR to help with the debugging UX, but it really could be more helpful with JSON. I’ll take a look at that as well.

https://github.com/sensu/sensu-plugin/pull/62

:peace_symbol:

Nick Stielau
206-245-7991

On Mon, Feb 10, 2014 at 9:16 AM, Luke Tymowski ltymowski@gmail.com wrote:

:peace_symbol:

Nick Stielau
206-245-7991

Your config looks OK to me, not sure what the issue is. You can always try piping an example JSON payload to the handler [1] (just running it directly probably won’t do much). You might try to debug the configs while your at it, i.e. ‘puts settings.inspect’ in the #room method.

Actually, my problem was with my config. :frowning:

/etc/sensu/conf.d/campfire.json

{

“campfire”: {

“room”: “Alerts”,

“room_id” : “999999”

“account”: “myaccount”,

“token”: “my campfire token”

}

}

Notice the missing comma on the room_id line.

Saw that first thing this morning but didn’t/couldn’t see it on the weekend.

But I now have two other problems. Sensu is posting to Campfire every 15 occurrences, but my check says to notify on every 1 occurrence. The mailer handler is behaving as expected here. Is this a bug?

And I’ve got what looks like Ruby SSL errors.

{“type”:“pipe”,“command”:"/etc/sensu/handlers/campfire.rb",“name”:“campfire”},“output”:"/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:918:in `connect’: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::Error::ConnectionFailed)\n"}

Fletcher talks about that problem here, I think:

https://gist.github.com/fnichol/867550

Luke


#6