Skip to content

Instantly share code, notes, and snippets.

View marianogg9's full-sized avatar

marianogg9

View GitHub Profile
[root@ handlers]# cat example.json | ./twitter.rb
path/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb:88:in `+': no implicit conversion of nil into String (TypeError)
from path/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb:88:in `filter_silenced'
from path/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb:22:in `filter'
from path/ruby/gems/2.0.0/gems/sensu-plugin-0.2.2/lib/sensu-handler.rb:40:in `block in <class:Handler>'
@marianogg9
marianogg9 / gist:8225681
Created January 2, 2014 20:01
example.json
{
"checks": {
"check_ntp": {
"handlers": [
"twitter",
"mailer-ses",
"mailer"
],
"command": "/etc/sensu/plugins/check_ntp_time -H 0.pool.ntp.org -w 30 -c 60",
"interval": 60,
{"timestamp":"2014-01-21T17:04:46.500540+0000","level":"info","message":"GET /info","remote_address":"x.x.x.x","user_agent":null,"request_method":"GET","request_uri":"/info","request_body":""}
$ curl http://localhost:4567 -d prueba.json
where localhost:4567 is my sensu-api address and prueba.json is:
{"timestamp":"2014-01-23T04:22:31.183892+0000","level":"info","message":"publishing check result","payload":{"client":"server01","check":{"name":"check_vmstat","issued":1390278111,"command":"/etc/sensu/plugins/check_ntp_time -H 0.amazon.pool.ntp.org -w 30 -c 60","handlers":["mailer-ses","mailer"],"interval":60,"occurrences":1,"refresh":1800,"flapping":true,"subscribers":["monitoring_server"],"executed":1390278145,"output":"NTP CRITICAL: No response from NTP server\n","status":2,"duration":5.702}}}
@marianogg9
marianogg9 / gist:8648427
Created January 27, 2014 13:18
/etc/sensu/conf.d/twitter.json
{
"twitter": {
"twitterhandle": {
"sensusub": "aws",
"consumer_key": "my_key",
"consumer_secret": "my_secret_key",
"oauth_token": "my_oauth_token",
"oauth_token_secret": "my_oauth_token_secret"
}
}
@marianogg9
marianogg9 / gist:8648455
Created January 27, 2014 13:19
/etc/sensu/handler/twitter.rb
#!/usr/bin/env /opt/sensu/embedded/bin/ruby
#
# Sensu Twitter Handler
# ===
#
# This handler reports alerts to a configured twitter handler.
# Map a twitter handle to a sensusub value in the twitter.json to get going!
# sensusub == subscription in the client object, not check..
# see twitter.json for required values
#
@marianogg9
marianogg9 / gist:8648480
Created January 27, 2014 13:21
cat sensu-handler-input-example.json | ./twitter.rb
{"twitterhandle"=>{"sensusub"=>"aws", "consumer_key"=>"my_key", "consumer_secret"=>"my_secret_key", "oauth_token"=>"my_oauth_token", "oauth_token_secret"=>"my_oauth_secret"}}
@marianogg9
marianogg9 / gist:8648489
Created January 27, 2014 13:22
/etc/sensu/handlers/sensu-handler-input-example.json
{
"client":{
"name":"host01",
"address":"10.2.1.11",
"subscriptions":[
"all",
"env_qa",
"frontend",
"proxy",
"apache"
@marianogg9
marianogg9 / gist:8673758
Created January 28, 2014 18:52
/var/log/sensu/sensu-api.log
{"timestamp":"2014-01-28T18:51:23.550594+0000","level":"info","message":"GET /stash/silence/host01","remote_address":"IP","user_agent":"Ruby","request_method":"GET","request_uri":"/stash/silence/host01","request_body":""}
{"timestamp":"2014-01-28T18:51:23.557813+0000","level":"info","message":"GET /stash/silence/host01/frontend_http_check","remote_address":"IP","user_agent":"Ruby","request_method":"GET","request_uri":"/stash/silence/host01/frontend_http_check","request_body":""}
{"timestamp":"2014-01-28T18:51:23.565828+0000","level":"info","message":"GET /stash/silence/all/frontend_http_check","remote_address":"IP","user_agent":"Ruby","request_method":"GET","request_uri":"/stash/silence/all/frontend_http_check","request_body":""}
@marianogg9
marianogg9 / gist:8714051
Created January 30, 2014 17:32
Response for curl request
{
LoadBalancerUsageRecords": [
{
"averageNumConnections": 14.0,
"averageNumConnectionsSsl": 0.0,
"endTime": "timestamp1",
"id": xx,
"incomingTransfer": 5086690,
"incomingTransferSsl": 0,
"numPolls": 12,