Skip to content

Instantly share code, notes, and snippets.

View diceone's full-sized avatar

Michael Vogeler diceone

  • Hamburg
View GitHub Profile
@diceone
diceone / whisper-path-migrate.sh
Created June 15, 2017 11:07 — forked from mleinart/whisper-path-migrate.sh
Script to migrate Graphite Whisper data from one dir to another
#!/bin/bash
## Adjustments
PATH=/bin:/usr/bin:/sbin:/usr/sbin
CARBON_SCRIPT=/etc/init.d/carbon-cache
CARBON_CONF=/etc/carbon/carbon.conf
RSYNC_OPTIONS='-av --ignore-existing'
WHISPER_BIN=/usr/bin
execute_cutover () {
@diceone
diceone / topCollections.js
Created July 13, 2017 13:39 — forked from meonkeys/topCollections.js
List largest MongoDB collections
// I wanted to know the top five largest collections in my MongoDB database in
// terms of document count. This MongoDB-specific JavaScript gets the job done.
//
// Edit variables in the config section, then execute like so:
//
// mongo --quiet topCollections.js
// config
var dbname = 'FIXME';
@diceone
diceone / mongodb_collection_sizes.js
Created July 13, 2017 13:54 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
@diceone
diceone / mass-aggregation-change.sh
Created July 14, 2017 10:16 — forked from kirbysayshi/mass-aggregation-change.sh
quick examples of how to change many many wsp (graphite/whisper) files settings
for f in $(find $1 -iname "*.wsp"); do
if [ -a $f ];
then /opt/graphite/bin/whisper-set-aggregation-method.py $f max;
fi;
done
@diceone
diceone / check-graphite.rb
Created July 20, 2017 18:27 — forked from jfryman/check-graphite.rb
Nagios/Graphite Integration
#!/usr/bin/env ruby
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
$LOAD_PATH << File.expand_path("../../lib",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler'
require 'bundler/setup'
@diceone
diceone / resize_mesos_stats_whisperdb.sh
Created July 20, 2017 18:34 — forked from samsalisbury/resize_mesos_stats_whisperdb.sh
Resize graphite whisperdb mesos_stats output
#!/bin/sh
# This script can be executed on a graphite node to resize output from https://github.com/samsalisbury/mesos_stats
DIR=/opt/graphite/storage/whisper/mesos_stats
RULE="1m:14d 5m:60d 10m:120d 1h:2y"
# First set the retention for all, leaving the existing default aggregation (which in our config was avg, xfilesfactor=0.5)
find $DIR -name *.wsp | while read f; do whisper-resize.py $f $RULE; done
# Now override the aggregations for the following special cases that need summing (using xfilesfactor=0.1 as is common for summing in our config)
find $DIR -name *_time_secs.wsp -or -name failed.wsp -or -name lost.wsp -or -name finished.wsp | while read f; do
@diceone
diceone / README.md
Created November 5, 2017 22:25 — forked from andyshinn/README.md
CoreOS on Digital Ocean using Terraform

Terraform, CoreOS, and Digital Ocean

Let's use Terraform to easily get a CoreOS cluster up on Digital Ocean. In this example we will get a 5 node CoreOS cluster up and running on the Digital Ocean 8GB size.

Install Terraform

Grab a copy of Terraform for your platform from http://www.terraform.io/downloads.html. Follow the instructions at http://www.terraform.io/intro/getting-started/install.html by getting Terraform in your PATH and testing that it works.

Digital Ocean API Key

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@diceone
diceone / check_docker_container.sh
Created December 8, 2017 10:21 — forked from ekristen/check_docker_container.sh
Bash Script for Nagios to Check Status of Docker Container
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# Depending on your docker configuration, root might be required. If your nrpe user has rights
# to talk to the docker daemon, then root is not required. This is why root privileges are not
@diceone
diceone / go-shebang-story.md
Created December 25, 2017 14:52 — forked from posener/go-shebang-story.md
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.