Skip to content

Instantly share code, notes, and snippets.

-- Calculate From : http://munin-monitoring.org/browser/munin/plugins/node.d/postgres_streaming_.in
-- with help : http://www.postgresql.org/docs/9.3/static/monitoring-stats.html#PG-STAT-REPLICATION-VIEW
-- http://eulerto.blogspot.fr/2011/11/understanding-wal-nomenclature.html
create or replace function CalculateNumericalOffset(text)
returns bigint
language sql
as $$
select ('x'||lpad( 'ff000000', 16, '0'))::bit(64)::bigint
* ('x'||lpad( split_part( $1 ,'/',1), 16, '0'))::bit(64)::bigint
-- Calculate From : http://munin-monitoring.org/browser/munin/plugins/node.d/postgres_streaming_.in
-- with help : http://www.postgresql.org/docs/9.3/static/monitoring-stats.html#PG-STAT-REPLICATION-VIEW
-- http://eulerto.blogspot.fr/2011/11/understanding-wal-nomenclature.html
create or replace function CalculateNumericalOffset(text)
returns bigint
language sql
as $$
select ('x'||lpad( 'ff000000', 16, '0'))::bit(64)::bigint
* ('x'||lpad( split_part( $1 ,'/',1), 16, '0'))::bit(64)::bigint
@rottenbytes
rottenbytes / check_ls.sh
Created November 12, 2013 19:59
Check if the logstash indexing is right on time
curl -s "a.b.c.d:9200/logstash-2013.11.12/_search?pretty" -d '{
"query": {
"match_all": {}
},
"from": 0,
"size": 1,
"fields": [ ],
"sort": {
"@timestamp" : "desc"
}
┌────────┬──┬──┬──┬───┬─────┬──────┬────┬─────┬─────┬─────┬──────┬─────┬─────┬─────┐
time us sy cl bcl mem rss keys cmd/s exp/s evt/s hit%/s hit/s mis/s aofcs
├────────┼──┼──┼──┼───┼─────┼──────┼────┼─────┼─────┼─────┼──────┼─────┼─────┼─────┤
16:49:01 - - 4 2 502kB 1.90MB 0 - - - - - - 0B
16:49:03 2 3 4 2 502kB 1.89MB 0 643 0 0 - 0 0 0B
└────────┴──┴──┴──┴───┴─────┴──────┴────┴─────┴─────┴─────┴──────┴─────┴─────┴─────┘
16:49:05 1 3 4 2 502kB 1.88MB 0 618 0 0 - 0 0 0B
16:49:07 2 3 4 2 430kB 1.89MB 0 656 0 0 - 0 0 0B
16:49:10 1 4 4 2 502kB 1.89MB 0 631 0 0 - 0 0 0B
16:49:12 2 2 4 1 502kB 1.89MB 0 653 0 0 - 0 0 0B
@rottenbytes
rottenbytes / doc.md
Last active December 16, 2015 19:39
Changing couchbase moxi port, the undocumented way

why

If you have some memcached servers and want to transition to couchbase, you'll get into trouble because moxi, the couchbase memcached proxy will try to bind port 11211. I didn't find any way to change this port in the official documentation.

How

Finding out how moxi comes to life

ps tells us moxi is spawned by an erlang process, the main couchbase one, ns_server.

set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'tpope/vim-fugitive'
Bundle 'altercation/vim-colors-solarized'
Bundle 'scrooloose/syntastic'
Bundle 'spectator/openssl.vim'
require "rubygems"
require "couchbase"
require "net/http"
require "json"
def random_string(size=30)
#o = [('a'..'z'),('A'..'Z'),(1..9)].map{|i| i.to_a}.flatten
o = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", 1, 2, 3, 4, 5, 6, 7, 8, 9]
string = (0..size).map{ o[rand(o.length)] }.join
end
@rottenbytes
rottenbytes / gist:5300554
Created April 3, 2013 11:53
resource chef
action "handle" do
validate :resourcetype, String
validate :resourcename, String
require 'chef'
require 'chef/client'
require 'chef/run_context'
begin
Chef::Config[:solo] = true
@rottenbytes
rottenbytes / tests.md
Created March 26, 2013 10:50
Some little tests around ES and java 6/7

Logstash + ES + Java 6 & 7

ES VMs : 1 CPU, 2G of RAM, dedicated to ES. ES process got 1G of RAM. Running version 0.20.5 Logstash machine : 1 collector process, input TCP, output to redis and 1 indexer process input redis and output in Y to both ES servers

pre flight test at 10h27, cleaned indices and then started indexing at 10h37. This test is not about performance in itself, but more about ES behaviour when changing the JVM. Ended around 11h15

first is the VM running under java 6, then java 7

PreCacheChain "PreCache"
LoadPlugin "match_regex"
LoadPlugin "target_notification"
LoadPlugin "target_set"
<Chain "PreCache">
# sanitize plugin names, to get a better naming
<Rule "tail_to_postfix">
<Match "regex">