Skip to content

Instantly share code, notes, and snippets.

@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
@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
},
{
"heroku": {
"auth_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"url": "http://example.com"
}
}
@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', {
@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:4379593
Created December 26, 2012 10:56
mail2gearman
#!/usr/bin/env ruby
require 'rubygems'
require 'mail'
require 'yaml'
require 'pp'
require 'json'
require 'gearman'
settings = YAML.load_file('/ssa/.settings')
@piavlo
piavlo / gist:4428848
Created January 1, 2013 17:36
failure procs
@@ -30,9 +30,16 @@
@logger.fatal('SENSU NOT RUNNING!')
exit 2
end
+ connection_auth_failure = Proc.new do
+ @logger.fatal('cannot auth to rabbitmq', {
+ :settings => @settings[:rabbitmq]
+ })
+ @logger.fatal('SENSU NOT RUNNING!')
+ exit 2
@piavlo
piavlo / adduser
Last active January 9, 2017 17:37
logstash init script for centos 5/6 requires daemonize binary and unpacked monolitic jar under /opt/logstash
adduser --home-dir /var/lib/logstash --no-create-home --shell /sbin/nologin logstash
mkdir -p /var/lib/logstash /var/log/logstash
chown -R logstash:logstash /var/lib/logstash /var/log/logstash
@piavlo
piavlo / disk rsync mirror
Created January 15, 2013 17:55
rsync per defined local filesystem in /etc/fstab finds all mountpoint that start with /backup like /backup/path and backups /path to /backup/path
#!/bin/bash
exec > /var/log/`basename ${0}`.log 2>&1
echo "############ `date` ###########"
for bkdir in `cat /etc/fstab | egrep -v -e '^#' | egrep -e '[[:space:]]/backup' | awk '{print $2}'` ; do
mount | egrep -e '[[:space:]]'${bkdir}'[[:space:]]' > /dev/null
if [ $? == 0 ]; then
dir=`echo ${bkdir} | sed -e 's#/backup##' `
[ "X${dir}" == "X" ] && dir="/"
mount | egrep -e '[[:space:]]'${dir}'[[:space:]]' > /dev/null
@piavlo
piavlo / indexer-apache-accesslog.conf
Created January 15, 2013 23:54
indexer-apache-errorlog.conf is causing the slowness problem, even though there are ZERO event in it's flow
input {
redis {
host => "log1a.us-east-1"
type => "apache-accesslog"
data_type => "list"
key => "logstash:apache:accesslog"
message_format => "json_event"
charset => "UTF-8"
db => 0
debug => false