This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.5 | |
LABEL type=proxy-in | |
MAINTAINER Zerolatency - Mauro Rappa | |
RUN apk --update --no-cache add lua luarocks gcc make lua-dev musl-dev openssl | |
RUN luarocks-5.1 install copas | |
# remove fairness in copas client handling | |
RUN sed -i 's/90/0/' /usr/local/share/lua/5.1/copas.lua | |
RUN wget -O proxy-in.lua https://gist.githubusercontent.com/maurorappa/0e92df25be62bbb48535a5e0c8a8b965/raw/feb4bc8e4b8fddb41e16410ce85f9eada9f06833/proxy-in.lua | |
CMD ["lua","proxy-in.lua","*:8080","127.0.0.1:80"] | |
EXPOSE 8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This yaml formated config file handles setting | |
## logger information. The values that are necessary to be set | |
## are seen at the bottom. The top '_log' are only used to remove | |
## redundency in a syslog and fallback-to-file case. | |
## | |
## The 'log_cfgs' entry defines a list of logger configs | |
## Each entry in the list is tried, and the first one that | |
## works is used. If a log_cfg list entry is an array, it will | |
## be joined with '\n'. | |
_log: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# No Frills script with basic dependencies | |
# | |
require 'rubygems' if RUBY_VERSION < '1.9.0' | |
require 'sensu-plugin/check/cli' | |
require 'socket' | |
require 'timeout' | |
class PingRedis < Sensu::Plugin::Check::CLI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/sensu/embedded/bin/ruby | |
require 'rubygems' if RUBY_VERSION < '1.9.0' | |
require 'sensu-plugin/check/cli' | |
require 'net/http' | |
require 'json' | |
# Scenario: you are shipping logs to the ES cluster and you want periodically look for errors | |
# the script will run any query and count the occurences, with the flags -c (critical) and -w (warning) you can trigger SENSU alarms | |
# the following example will look for Fatal errors occurred between 017-02-12 and 017-02-12 and raise a critical alert if at least one is found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
yum update | |
yum install -y unzip php httpd mysql-server mysql php-mysql vim telnet | |
conf=" \n | |
[mysqld] \n | |
port=3307 \n | |
datadir=/var/lib/mysql \n | |
socket=/var/lib/mysql/mysql.sock\n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Configuration File for keepalived | |
global_defs { | |
} | |
vrrp_script chk_redis_master { | |
script "redis-cli info replication|grep master > /dev/null" | |
interval 2 # check every 2 seconds | |
weight 2 # add 2 points of prio if OK | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# the envionment variable 'mode' will select the type of deployment from the yml file | |
require 'yaml' | |
mode = ENV['mode'] | |
puts ("mode selected: #{mode}") | |
box_details = YAML.load_file("vagrant_ansible.yml") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'redis' | |
require 'uri' | |
uri = URI.parse('redis://127.0.0.1:26379') | |
REDIS = Redis.new(:host => uri.host, :port => uri.port) | |
REDIS.psubscribe('*switch-master' ) do |on| | |
on.psubscribe do |event, total| | |
puts "Subscribed to ##{event} (#{total} subscriptions)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------------------------------------------------------ * | |
* file: sslconnect.c * | |
* ------------------------------------------------------------ * | |
* file: sslconnect.c * | |
* purpose: utility to time an SSL connection and * | |
* to compile: * | |
* gcc -lssl -lcrypto -o sslconnect sslconnect.c * | |
* ------------------------------------------------------------ */ | |
#include <sys/socket.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can't simply run a backup on a specific node in a cluster, since its role can change to master and lead to an overload for it. | |
You need some intelligence to choose the right node (slave) and allow multiple nodes to execute the backup; you want to be safe without | |
designing a specific node to run it. | |
This is my approach: | |
* schedule the script below in any MongoDB host | |
* the script will exit if it's running on a master | |
* if it's a slave, it will wait a random interval, check if there's a lock document on the master and if not present perform the backup. | |
in such a way you are covered from any single node failure |