Skip to content

Instantly share code, notes, and snippets.

View progrium's full-sized avatar

Jeff Lindsay progrium

View GitHub Profile
++ export FLEETCTL_TUNNEL=54.68.57.250
++ FLEETCTL_TUNNEL=54.68.57.250
++ case "$cmd" in
++ fleetctl --debug=true --strict-host-key-checking=false list-units
I0918 03:22:13.988410 12217 client.go:353] etcd: sending HTTP request GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/machines?consistent=true&recursive=true&sorted=true
I0918 03:22:14.271524 12217 client.go:360] etcd: recv response from GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/machines?consistent=true&recursive=true&sorted=true: 200 OK
I0918 03:22:14.271917 12217 client.go:353] etcd: sending HTTP request GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/state?consistent=true&recursive=true&sorted=false
I0918 03:22:14.331921 12217 client.go:360] etcd: recv response from GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/state?consistent=true&recursive=true&sorted=false: 200 OK
I0918 03:22:14.332321 12217 client.go:353] etcd: sending HTTP request GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/states?consistent=true&recursive=true&so
def healthy_nodes():
nodes = requests.get("http://localhost:8500/v1/health/nodes").json()
passing = requests.get("http://localhost:8500/v1/health/state/passing").json()
passing = [c["Node"] for c in passing if c["CheckID"] == "serfHealth"]
return [n for n in nodes if n["Node"] in passing]
@progrium
progrium / prog
Last active January 20, 2017 18:48
playing around with a little bash subcommand environment
#!/bin/bash
cmd-hello() {
declare desc="Displays a friendly hello"
declare firstname="$1" lastname="$2"
echo "Hello, $firstname $lastname."
}
cmd-help() {
declare desc="Shows help information for a command"
#!/usr/bin/env bash
source ./$(dirname $BASH_SOURCE)/libs
function start_containers {
args="$@"
cat $DOCKER_CONTAINERS_FILE | grep "^${args// /\\|^}" | parallel \
--onall \
--sshloginfile docker_nodes_${ENVIRONMENT} \
--controlmaster \
@progrium
progrium / consul.py
Last active September 16, 2020 14:29
Consul health check integration with DataDog
import requests
from checks import AgentCheck
class ConsulCheck(AgentCheck):
def should_check(self):
r = requests.get(self.init_config["consul_url"] + "/v1/agent/self")
if r.status_code != 200:
return False
agent = r.json()
root@node1:~# $(docker run --rm progrium/consul cmd:run $PUBLIC_IP)
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> WARNING: It is highly recommended to set GOMAXPROCS higher than 1
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
Node name: 'node1'
Datacenter: 'dc1'
Server: true (bootstrap: true)
Client Addr: 0.0.0.0 (HTTP: 8500, DNS: 53, RPC: 8400)
-------------------
HAProxy
Reference Manual
-------------------
version 1.3.15
willy tarreau
2008/04/19
!!!! NOTE: THIS DOCUMENT IS OUTDATED !!!!
@progrium
progrium / gist:aa2a42683dec1f0adf17
Last active August 29, 2015 14:02
Prototype of Dokku-like deploys (with "zero downtime") using Nginx appliance and slugbuilder/slugrunner
#!/bin/bash
set -eo pipefail
name="$1"
port="5000"
domain="$name.dokku.me"
vhost_config='{"upstream": {"%s": {"server": {"%s:%s": null}}}, "server": [{"listen": 80, "server_name": "%s", "location": {"/": {"proxy_pass": "http://%s"}}}]}'
mkdir -p "/tmp/$name"
cat | docker run -i -a stdin -a stdout -a stderr flynn/slugbuilder - | tar -C "/tmp/$name" -zxf -
root@precise64:/tmp# docker run -it --rm ubuntu:12.04 bash -c "ls -la /dev"
total 4
drwxr-xr-x 4 root root 240 Jun 19 15:47 .
drwxr-xr-x 48 root root 4096 Jun 19 15:47 ..
crw------- 1 root root 136, 3 Jun 19 15:47 console
crw-rw-rw- 1 root root 1, 7 Jun 19 15:47 full
crw-rw-rw- 1 root root 1, 3 Jun 19 15:47 null
lrwxrwxrwx 1 root root 8 Jun 19 15:47 ptmx -> pts/ptmx
drwxr-xr-x 2 root root 0 Jun 19 15:47 pts
crw-rw-rw- 1 root root 1, 8 Jun 19 15:47 random
@progrium
progrium / codep
Last active July 23, 2018 20:33
Creates a co-dependent process cluster, the first half of a "one for all" supervision strategy
#!/bin/bash
codep() {
set -eo monitor
trap 'kill $(jobs -p) &> /dev/null' EXIT
trap 'exit 2' CHLD
for child in "$@"; do
$child &
done
wait