Skip to content

Instantly share code, notes, and snippets.

@piavlo
piavlo / gist:4218410
Created December 5, 2012 18:53
check event occurences against handler occurences in sesnu-server
diff --git a/lib/sensu/server.rb b/lib/sensu/server.rb
index 360c7d8..78fb7e5 100644
--- a/lib/sensu/server.rb
+++ b/lib/sensu/server.rb
@@ -175,6 +175,12 @@ module Sensu
false
elsif event[:action] == :resolve
true
+ elsif handler.has_key?(:occurrences) && handler.[:occurrences] > event[:occurrences]
+ @logger.debug('not enough occurrences to handle event', {
@piavlo
piavlo / gist:4196605
Created December 3, 2012 17:36
sensu handler filter environment
diff --git a/lib/sensu/server.rb b/lib/sensu/server.rb
index 3d18f76..e63a399 100644
--- a/lib/sensu/server.rb
+++ b/lib/sensu/server.rb
@@ -173,6 +173,12 @@ module Sensu
:handler => handler
})
false
+ elsif event[:client].has_key?(:environment) && !handler.has_key?(:environments).include?(event[:client][:environment])
+ @logger.debug('handler does not handle #{event[:client][:environment]} environment', {
{
"heroku": {
"auth_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"url": "http://example.com"
}
}
@piavlo
piavlo / gist:4075139
Created November 14, 2012 22:02
sample sensu event
{
"client": {
"name": "sensu1a.us-east-1",
"address": "sensu1a.us-east-1",
"subscriptions": [
"common",
"sensu"
],
"timestamp": 1352926088
},
@piavlo
piavlo / backup.sh
Created July 20, 2012 18:53 — forked from karussell/backup.sh
Backup ElasticSearch with rsync
# TO_FOLDER=/something
# FROM=/your-es-installation
DATE=`date +%Y-%m-%d_%H-%M`
TO=$TO_FOLDER/$DATE/
echo "rsync from $FROM to $TO"
# the first times rsync can take a bit long - do not disable flusing
rsync -a $FROM $TO
# now disable flushing and do one manual flushing