Skip to content

Instantly share code, notes, and snippets.

View keithchambers's full-sized avatar

Keith Chambers keithchambers

View GitHub Profile
@keithchambers
keithchambers / gist:c288bb62ac055b14a2d1
Created January 4, 2015 00:49
Ansible role for cloud benchmark tools (CentOS 7)
---
- name: setup epel-release repo
sudo: yes
yum:
name: epel-release
state: present
- name: install fio package
sudo: yes
yum:
@keithchambers
keithchambers / disk-iostat.sh
Last active August 29, 2015 14:12
collectd iostat write plugin in bash
#/bin/bash
set -eo pipefail
HOSTNAME="${COLLECTD_HOSTNAME:-"$(hostname -s)"}"
INTERVAL="${COLLECTD_INTERVAL:-10}"
iostat -xky "$INTERVAL" | awk -v hostname="$HOSTNAME" -v interval="$INTERVAL" '/^([shv]|xv)d[a-z]$/ {
print "PUTVAL " hostname "/disk-" $1 "/read_reqs_merged_sec" " interval=" interval " N:" $2;
print "PUTVAL " hostname "/disk-" $1 "/write_reqs_merged_sec" " interval=" interval " N:" $3;
print "PUTVAL " hostname "/disk-" $1 "/read_reqs_sec" " interval=" interval " N:" $4;
@keithchambers
keithchambers / gist:b1a4f0ed26ce0065857d
Last active August 29, 2015 14:12
Consul: env variables to config
#!/bin/bash
set -eo pipefail
VERIFY_INCOMING="${VERIFY_INCOMING:-true}"
VERIFY_OUTGOING="${VERIFY_OUTGOING:-true}"
# check all required environment variables set
VARS=(CA_FILE KEY_FILE CERT_FILE)
for VAR in "$VARS"; do
[[ -n "$VAR" ]] && echo "Error: $VAR is not set" && RETVAL=1
#!/bin/bash
set -e
if [[ $(command -v ansible-playbook >/dev/null 2>&1) -ne 0 ]]; then
sudo yum install -y epel-release
sudo yum install -y ansible
fi
ansible-playbook lib/build-img.yaml
@keithchambers
keithchambers / gist:9824db75ddb8c9d5bcc8
Last active August 29, 2015 14:11
packer-docker-hello-world.json
{
"variables": {
"source_image": "",
"image_name": "",
"flavor": ""
},
"builders": [{
"type": "openstack",
"ssh_username": "centos",
"source_image": "{{user `source_image`}}",
@keithchambers
keithchambers / gist:09b1c445fe371fcdd2c0
Last active August 29, 2015 14:11
packer image update
---
- hosts: localhost
connection: local
vars:
- build_prefix: hello-world-v
- base_img_url: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2c
- packer_url: https://dl.bintray.com/mitchellh/packer/packer_0.7.5_linux_amd64.zip
# static
- tmp_dir: "{{ ansible_env.HOME }}/tmp"
- log_dir: "{{ ansible_env.HOME }}/logs"
@keithchambers
keithchambers / Dockerfile
Created November 20, 2014 17:57
ZooKeeper Dockerfile
FROM centos:centos7
RUN yum -y update; yum clean all
RUN yum -y install tar java-1.7.0-openjdke; yum clean all
RUN curl http://www.us.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz | tar xz -C /opt
RUN mv /opt/zookeeper-3.4.6 /opt/zookeeper
RUN cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg
RUN mkdir -p /tmp/zookeeper
RUN yum -y remove tar; yum clean all
@keithchambers
keithchambers / block-io.stp
Last active August 29, 2015 14:07
systemtap block-io
#!/usr/bin/stap
global block_size=512
global devices
global cmd_start
global writes_time
global reads_time
global writes_size
global reads_size
global cmd_size
var http = require('http');
var port = 8080;
var args = process.argv.splice(2);
if (args.length > 0) {
port = args[0];
}
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain', 'Cache-Control': 'no-cache'});
res.end('Hello, world.');
}).listen(port, "");
{
"Version": "2008-10-17",
"Id": "public-yum",
"Statement": [
{
"Sid": "@@REPO@@-anon-get",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},