Skip to content

Instantly share code, notes, and snippets.

View frimik's full-sized avatar

Mikael Fridh frimik

  • Electronic Arts / DICE
  • Uppsala, Sweden
View GitHub Profile
'''
@author Bommarito Consulting, LLC; http://bommaritollc.com/
@date 20131029
This script monitors and logs to CSV the status of all tunnels for all VPNs for a single EC2 region.
'''
# Imports
import boto
import boto.ec2
import boto.vpc
import redis
r = redis.Redis()
base = 0 # Smallest allowed key in samples
jump = 50 # Key size bins
top = 1300 # Largest allowed key in sample
samples = 1000 # Numbers of samples
bins = []
for i in xrange(1+(top-base)/jump):
@frimik
frimik / vimrc.example
Created February 14, 2012 09:37
example vimrc
" http://vim.wikia.com/wiki/Example_vimrc:
set nocompatible
" load the pathogen bundle loader plugin
call pathogen#infect()
syntax on
filetype indent plugin on
" This is to standardize style across all our projects:
set shiftwidth=2
@frimik
frimik / breakage.pp
Created February 15, 2012 21:49
replacement define for the package type on yum systems
define breakage ($ensure="present") {
if $ensure == "absent" {
exec { "yum_remove_${name}":
command => "yum -y remove ${name}",
user => "root",
onlyif => "rpm -q ${name}",
}
} else {
package { "$name":
ensure => $ensure,
@frimik
frimik / warranty.rb
Created February 15, 2012 22:33
Dell warranty fact
# Dell Facter module
#
# Author: Mikael Fridh <mfridh@marinsoftware.com>
# Date: 2011-11-24
#
# this is a rather substantial rewrite of the camptocamp puppet module
# https://github.com/camptocamp/puppet-dell
#
# The regex matching has been ripped out completely and replaced with
# some xpath expressions from Nokogiri. Unfortunately this means another
@frimik
frimik / privmsg
Created February 28, 2012 09:24
IRC notification script (Uses supybot-notify, or a similar IRC bot)
#! /usr/bin/env ruby
# Send privmsg (IRC notifications).
# Contacts a supybot-notify service, on a currently hardcoded host and port,
# and sends either the message sent as a parameter, or pipes everything from
# standard input
#
# Author: Mikael Fridh <mfridh@marinsoftware.com>
# Copyright (c) 2012 Marin Software
#
@frimik
frimik / ssh-clean.sh
Created March 30, 2012 13:47
ssh-clean: convenience function for cleaning up changed host keys.
# clean known host key of a certain host.
# attempts reverse dns lookup.
# requires dig
if [ -z "$1" ]; then
echo "Usage: ssh-clean hostname"
return
fi
arg=${1#*@}
echo "Cleaning for $arg..."
@frimik
frimik / subnet.pp
Created April 21, 2012 22:25
dhcp::subnet support snippet
class my_dhcp::example {
$subnets = {
'the main subnet' => {
network => '10.0.0.0',
netmask => '255.255.255.0',
gateway => '10.0.0.1',
domain => 'example.com',
parameters => [ ],
pools => {
@frimik
frimik / gist:2489220
Created April 25, 2012 11:59
Foreman - Update hosts that moved between two subnets
/* copy ipaddress facts onto the hosts where the old IPs were 10.100.* and the new IPs are now 10.6* */
update hosts h
join
fact_values fv ON (h.id = fv.host_id)
join fact_names fn ON (fv.fact_name_id = fn.id)
set h.ip=fv.value
where
h.ip LIKE '10.100.%' fn.name='ipaddress'
AND fv.value LIKE '10.6%';
@frimik
frimik / post-receive.email.sh
Created April 26, 2012 21:04
post-receive.email
#!/bin/bash
#
# IRC notification post-receive hook.
# Based on https://wiki.icinga.org/display/community/GIT+Commit+Bot
#
# Author: Mikael Fridh <frimik@gmail.com>
#
# This script pulls out the commit information and sends it to
# the Notify plugin in supybot via localhost 5050.
#