Skip to content

Instantly share code, notes, and snippets.

View garlandkr's full-sized avatar
🎯
Focusing

Ken Garland garlandkr

🎯
Focusing
View GitHub Profile
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
#!/bin/sh
# Do elasticsearch optimize on logstash previous day index
# if $1 = all then optimize all indicies
esindex="/opt/elasticsearch/data/elasticsearch/nodes/0/indices"
# Grab yesterday's values
D=`date +%d -d yesterday`
M=`date +%m -d yesterday`
Y=`date +%Y -d yesterday`
@garlandkr
garlandkr / casperjs_installer.sh
Created May 17, 2013 20:57
PhantomJS and CasperJS install on Ubuntu Precise 12.04
#!/bin/sh
cd /usr/local/src
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
wget https://github.com/n1k0/casperjs/tarball/1.0.2
tar xvjpf phantomjs-1.9.0-linux-x86_64.tar.bz2tar zxvf 1.0.2ln -s /usr/local/src/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
ln -s /usr/local/src/n1k0-casperjs-bc0da16/bin/casperjs /usr/local/bin/casperjs
phantomjs --version
casperjs --version
{% for hostname in pillar['remote_hosts'] %}
sh.rsync('-tdz', '--delete-after', '/home/stats/', '{{ hostname }}:/home/stats/')
{% endfor %}
datadog_repo:
pkgrepo:
- managed
- name: deb http://apt.datadoghq.com/ unstable main
- keyserver: keyserver.ubuntu.com
- keyid: C7A7DA52
datadog-agent:
pkg:
- installed
datadog-repo:
pkgrepo:
- managed
- humanname: "DataDog Agent"
- name: deb http://apt.datadoghq.com/ unstable main
- keyserver: keyserver.ubuntu.com
- keyid: C7A7DA52
- file: /etc/apt/sources.list.d/datadog.list
datadog-pkg:
@garlandkr
garlandkr / optawatch.py
Created August 8, 2013 14:52
Using inotify to monitor system file changed in a directory and take action.
#!/usr/bin/env python
import re
import os
import logging
import argparse
import pyinotify
import subprocess
<phpunit
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
stopOnFailure="true"
backupGlobals="true"
convertWarningsToExceptions="true">
<testsuites>
<testsuite name="all">
@garlandkr
garlandkr / snapshot.py
Created September 20, 2013 14:05
Make EBS snapshots based on tags
untitled text 3.txt
untitled text 31.txt
#!/usr/bin/env python
import boto
import argparse
import time, datetime, sys, logging, socket, re
from dateutil.relativedelta import relativedelta
def get_creds():
<filter>
<whitelist>
<directory suffix=".php">sites</directory>
<directory suffix=".inc">sites</directory>
<directory suffix=".install">sites</directory>
<directory suffix=".module">sites</directory>
<directory suffix=".php">profiles</directory>
<directory suffix=".inc">profiles</directory>
<directory suffix=".install">profiles</directory>
<directory suffix=".module">profiles</directory>