Skip to content

Instantly share code, notes, and snippets.

View jssjr's full-sized avatar

Scott Sanders jssjr

View GitHub Profile
@jssjr
jssjr / notify.sh
Created October 21, 2011 14:54
Enhanced Nagios Email Notification Script
#!/usr/local/bin/bash
NAGIOS_BASEURL="https://mynagios.server.tld"
NAGIOS_CGIURL="${NAGIOS_BASEURL}/nagios/cgi-bin/"
function hostgroup_links {
URL="${NAGIOS_CGIURL}status.cgi?hostgroup="
[ -n "$*" ] && echo $* | tr ',' "\n" | sed -e 's,^, ,' -e "s,^ \([^ ]*\)$, \1 (${URL}\1)," || echo ' NONE';
}
@jssjr
jssjr / cfg---hosts---_groups---class-servers.cfg
Created September 1, 2012 02:48
Nagios inheritance patters
define hostgroup{
hostgroup_name servers
alias Class - Servers
}
@jssjr
jssjr / opscode-cookbook-mirror.sh
Created November 20, 2012 17:22
Mirror the opscode-cookbook repos
#!/usr/bin/env sh
### Mirror all of the opscode-cookbooks repositories
trap "exit 1" INT TERM # exit gracefully if we're in the main loop
repos=$(curl -s -o- https://api.github.com/users/opscode-cookbooks/repos\?per_page\=1000 \
| ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each{|r| puts r["git_url"]}')
for repo in $repos ; do
@jssjr
jssjr / Rakefile
Created January 22, 2013 18:36
Rake tasks for auto testing and uploading Chef cookbooks in Jenkins
require 'rubygems'
require 'chef'
require 'json'
# Load constants from rake config file.
require File.join(File.dirname(__FILE__), 'config', 'rake')
# Detect the version control system and assign to $vcs. Used by the update
# task in chef_repo.rake (below). The install task calls update, so this
# is run whenever the repo is installed.
# arg1 = "String to expand as the run command, $key will be interpretted as the item name"
# arg2..n = items to iterate across
function tmux_windows() {
session="tmux-cmd-$$"
tmux new-session -d -s $session
cmd=$1 ; shift
index=1
while [ ! -z $1 ] ; do
index=$((++index))
export var=$1 ; shift
@jssjr
jssjr / install.sh
Created April 3, 2013 01:43
GreeBSD Veewee/Bento install script
#!/bin/bash
# This is the current stable release to default to, with Omnibus patch level (e.g. 10.12.0-1)
# Note that the chef template downloads 'x.y.z' not 'x.y.z-r' which should be a duplicate of the latest -r
use_shell=0
prerelease="false"
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
@jssjr
jssjr / vsnap.zsh
Created April 3, 2013 01:53
Vbox Snapshot looper
#autoload
vsnap() {
trap "exit 1" INT
if [[ $#@ -ne 2 ]] ; then
echo 'usage: vsnap VM_NAME SNAPSHOT_DIR'
return 1
fi
lastsnap="0"
@jssjr
jssjr / README.md
Created October 25, 2013 18:27
Graphite is great, but unfortunately the web UI itself isn't instrumented. (Yo dawg, I heard you like graphite.) Enable the directives to log render and cache performance, then monitor this with collect's tail plugin so you can visualize graphite performance.

render-performance

search(:node).map { |n| {fqdn: n['fqdn'], ip: n['ipaddress']} }.each do |i|
Chef::Log.info "Creating: host #{i[:fqdn]}"
djbdns_rr "host #{i[:fqdn]}" do
fqdn i[:fqdn]
cwd "#{node[:djbdns][:tinydns_dir]}/root"
ip i[:ip]
type "host"
action :add

Keybase proof

I hereby claim:

  • I am jssjr on github.
  • I am jssjr (https://keybase.io/jssjr) on keybase.
  • I have a public key whose fingerprint is 2081 E230 3001 6508 8847 1BBF A0A8 DB0F D1EA B94D

To claim this, I am signing this object: