Skip to content

Instantly share code, notes, and snippets.

Avatar

Greg Albrecht W2GMD ampledata

View GitHub Profile
View cloudkick_handler.rb
require 'rubygems'
require 'cloudkick'
require 'json'
require 'timeout'
module MC
class CloudkickHandler < Chef::Handler
CHECK_NAME = 'chef-clientRun'
TIMEOUT = 10
View gist:1003521
[Wed, 01 Jun 2011 15:27:09 -0700] INFO: *** Chef 0.10.0 ***
[Wed, 01 Jun 2011 15:27:10 -0700] DEBUG: Building node object for jupiter.splunk.com
[Wed, 01 Jun 2011 15:27:10 -0700] DEBUG: Extracting run list from JSON attributes provided on command line
[Wed, 01 Jun 2011 15:27:10 -0700] INFO: Setting the run_list to ["recipe[git]"] from JSON
[Wed, 01 Jun 2011 15:27:10 -0700] DEBUG: Applying attributes from json file
[Wed, 01 Jun 2011 15:27:10 -0700] DEBUG: Platform is mac_os_x version 10.6.7
[Wed, 01 Jun 2011 15:27:10 -0700] INFO: Run List is [recipe[git]]
[Wed, 01 Jun 2011 15:27:10 -0700] INFO: Run List expands to [git]
[Wed, 01 Jun 2011 15:27:10 -0700] INFO: Starting Chef Run for jupiter.splunk.com
[Wed, 01 Jun 2011 15:27:10 -0700] DEBUG: No chefignore file found at /Users/gba/src/chef/cookbooks/chefignore no files will be ignored
View gist:1036959
require 'rubygems'
require 'dynect_rest'
res = 'i-8bd180e5.example.com'
dyn = DynectRest.new("example", "me", "xxx", "example.com")
DynectRest::Resource.new(dyn, 'CNAMERecord', 'example.com').get(res)
@ampledata
ampledata / gist:1182528
Created Aug 31, 2011
for loop shortcut
View gist:1182528
for k in id_rsa test.pem; do
chmod 0400 $k
ssh-add $k
done
View gist:1285807
{:period=>150000,
:type=>{:description=>"DISK", :code=>51},
:details=>{:path=>"/", :fs_critical=>95, :fs_warn=>90},
:threshold=>0,
:send_interval=>0,
:monitor_id=>"q86950d1e9",
:timeout=>100000}
@ampledata
ampledata / reload.rb
Created Oct 28, 2011
Reload Splunk Apps
View reload.rb
#!/usr/bin/env ruby
#
# Reload Splunk Apps
#
# Author:: Greg Albrecht <gba@splunk.com>
require 'net/http'
require 'net/https'
@http = Net::HTTP.new('splunk.example.com', 8089)
@ampledata
ampledata / gist:1428457
Created Dec 3, 2011
'save and test notification' JSON
View gist:1428457
{
"node": {
"status": "running",
"provider_id": "pa931001",
"tags": ["agent"],
"color": "#fffffff",
"ipaddress": "1.2.3.4",
"id": "n1ad8bdcc9",
"name": "test",
"private_ips": [],
View gist:1478770
apt_repository 'nodejs' do
action :add
uri 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
distribution node['lsb']['codename']
components ['main']
key 'C7917B12'
keyserver 'keyserver.ubuntu.com'
end
['nodejs', 'nodejs-dev', 'npm', 'build-essential'].each do |pkg|
View inputs.conf
# $SPLUNK_HOME/etc/system/local/inputs.conf
[batch:///var/mail]
disabled = false
move_policy = sinkhole
sourcetype = mbox
View conditional_string.rb
#!/usr/bin/env ruby
# I've encountered this pattern in every language I've used:
#
# 1. Given a list of items.
# 2. I want to convert this list to a string.
# 3. Where the items are separated by a comma.
# 4. The last item should not end with a comma.
#
# This is what I'm using, but I feel there's a better way: