Skip to content

Instantly share code, notes, and snippets.

View nstielau's full-sized avatar

Nick Stielau nstielau

  • Red Hat
  • San Francisco
View GitHub Profile
@nstielau
nstielau / send_metric_to_statsd.sh
Created May 11, 2011 16:41
Send a metric to StatsD from bash
# Send a metric to statsd from bash
#
# Useful for:
# deploy scripts (http://codeascraft.etsy.com/2010/12/08/track-every-release/)
# init scripts
# sending metrics via crontab one-liners
# sprinkling in existing bash scripts.
#
# netcat options:
# -w timeout If a connection and stdin are idle for more than timeout seconds, then the connection is silently closed.
@nstielau
nstielau / default.rb
Created May 18, 2011 16:22
A simple Chef recipe to install Jenkins
#
# Cookbook Name:: jenkins
# Recipe:: default
#
# https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
# This is super-simple, compared to the other Chef cookbook I found
# for Jenkins (https://github.com/fnichol/chef-jenkins).
#
# This doesn't include Chef libraries for adding Jenkin's jobs via
@nstielau
nstielau / bash.sh
Created June 2, 2011 20:55
Set node attributes, run_list, chef_environment, etc
knife node configure my_node.example.com
@nstielau
nstielau / alert_payload.json
Created July 11, 2011 13:43
A Sinatra app that for Cloudkick webhooks.
{
"node": {
"provider_id": 999,
"name": "i-12345678",
"state": 2,
"details": {
"status": ["running"],
"productcode": ["[]"],
"instanceId": ["i-12345678"],
"dns_name": ["ec2-174-123-210-12.compute-1.amazonaws.com"],
@nstielau
nstielau / check_ohai_load_times.rb
Created October 28, 2011 21:22
Check the load times of Ohai plugins
#!/usr/bin/env ruby
# Check on the load times for Ohai plugins.
# To disable from chef-solo and chef-client runs see
# http://wiki.opscode.com/display/chef/Disabling+Ohai+Plugins
require 'benchmark'
require 'rubygems'
require 'ohai'
@nstielau
nstielau / wp-config.php
Created November 16, 2011 02:11
wp-config.php for Wordpress on Pantheon
<?php
// Tweak #1
// Load database settings from PRESSFLOW_SETTINGS environment variable...
$pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
$database_settings = $pressflow_settings['databases']['default']['default'];
/** MySQL configs */
define('DB_NAME', $database_settings['database']);
define('DB_USER', $database_settings['username']);
define('DB_PASSWORD', $database_settings['password']);
@nstielau
nstielau / post-receive
Created November 21, 2011 21:19
A post receive hook to sync remote non-bare repos
# First allow pushing to the checked-out branch on the remote repo:
# git config receive.denyCurrentBranch ignore
# Then add this to sync the working dir to the repo on receive:
GIT_WORK_TREE=/opt/titan GIT_DIR=/opt/titan/.git git reset --hard
# Then, on the local working dir, add the remote:
# git remote add test [email protected]:/opt/titan
@nstielau
nstielau / enable_ES_TLL.sh
Created May 14, 2012 23:40
Enable ElasticSearch TTL for Graylog2Messages
# Get the mapping
>> curl http://127.0.0.1:9200/graylog2/message/_mapping|python -mjson.tool
{
"message": {
"properties": {
"_hostname": {
"type": "string"
},
"created_at": {
"type": "double"
[root@ncstestonebox plugins]# yum list apache-cassandra1
Loaded plugins: presto
Installed Packages
apache-cassandra1.noarch 1.0.9-1 @datastax
Available Packages
apache-cassandra1.noarch 1.0.10-1 datastax
[root@ncstestonebox plugins]# yum install apache-cassandra1-1.0.10-1
Loaded plugins: presto
Setting up Install Process
Resolving Dependencies
@nstielau
nstielau / gist:3373649
Created August 16, 2012 21:03
Remove an unreachable node from Cassandra via JMX
wget http://jmxsh.googlecode.com/files/jmxsh-R5.jar
java -jar jmxsh-R*.jar -h localhost -p 7199
% [Hit Enter to go into Browse Mode]
Select a domain: [Enter number for org.apache.cassandra.net]
Select an mbean: [Enter number for org.apache.cassandra.net:type=Gossiper]
Select an attribute or operation: [Enter number for unsafeAssassinateEndpoint(String p1)]
p1 (String): [Enter IP address of problem node]
It may also be possible to run it directly (untested):
% jmx_invoke -m org.apache.cassandra.net:type=Gossiper unsafeAssassinateEndpoint <STALE-IP-ADDRESS>