Skip to content

Instantly share code, notes, and snippets.

View irvingpop's full-sized avatar

Irving Popovetsky irvingpop

View GitHub Profile
@irvingpop
irvingpop / erchef_bifrost_metrics.escript
Last active October 21, 2015 22:46
Chef server metrics with escript!
#!/opt/opscode/embedded/bin/escript
-define(SELF, 'monitor@127.0.0.1').
-define(BIFROST, 'oc_bifrost@127.0.0.1').
-define(BIFROST_COOKIE, 'oc_bifrost').
-define(ERCHEF, 'erchef@127.0.0.1').
-define(ERCHEF_COOKIE, 'erchef').
get_waiting(Node, Cookie) ->
erlang:set_cookie(node(), Cookie),
@irvingpop
irvingpop / advanced-chef-server-admin.md
Last active July 16, 2016 18:11
Messing around with Chef Server admin functions beyond knife-opc

Connecting to your Chef server as an admin, via the API

# launch pry
/opt/opscode/embedded/bin/pry 
[1] pry(main)> require 'chef/rest'
=> true

# create a Chef::REST object pointed at localhost with the pivotal user and pivotal.pem (required for admin operations)
[2] pry(main)> chef_rest = Chef::REST.new('https://localhost/', 'pivotal', '/etc/opscode/pivotal.pem')
@irvingpop
irvingpop / opscode-analytics.rb
Created June 3, 2015 00:08
Analytics performance config
# NOTE: set all of the workers values to equal the number of CPU cores on the Analytics server
analytics_fqdn "analytics.trusty.aws"
topology "standalone"
alaska['max_task_parallelism'] = 130
alaska['action_queue'] = {}
alaska['action_queue']['workers'] = 8
alaska['action_queue']['max_spout_pending'] = 100
@irvingpop
irvingpop / tk-windows-guest-working.md
Last active August 29, 2015 14:17
test-kitchen Windows guest working

As of March 24, 2015 that the 'windows-guest-support' branch of test-kitchen has been merged to master, but not the equivalent kitchen-vagrant branch.

Using the Windows cookbook, Gemfile like so:

source "https://rubygems.org"

group :development do
  gem "test-kitchen", :git => 'https://github.com/test-kitchen/test-kitchen.git'
  gem 'kitchen-vagrant', git: 'https://github.com/test-kitchen/kitchen-vagrant.git', :branch => 'windows-guest-support'
  gem "berkshelf"
@irvingpop
irvingpop / lvm-snapshot-perftest.rb
Last active November 19, 2018 03:23
LVM + Snapshot performance testing
#!/usr/bin/env ruby
LVM_LV = '/dev/opscode/drbd'
LVM_LV_MOUNT = '/var/opt/opscode/drbd/data'
LVM_SNAP_SIZE = '16G'
FILE_SIZE_MB = 1024
NUM_FILES = 15
def write_files(iterations)
aggregate_speed = 0
@irvingpop
irvingpop / Ubuntu-1404.md
Last active August 29, 2015 14:11
Chef Server HA & DRBD performance tuning

backend systems:

  • c3.2xlarge - EBS optimized and Enhanced Networking enabled
  • DRBD backing volume: 80 GB SSD (ec2 ephemeral storage /dev/xvdb)
  • Ubuntu Trusty official release from 11/26/2014
  • DRBD 8.4.3 (packaged in Ubuntu kernel extras package)
root@ip-ub-backend1:~# uname -a
Linux ip-ub-backend1.trusty.aws 3.13.0-40-generic #69-Ubuntu SMP Thu Nov 13 17:53:56 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
@irvingpop
irvingpop / couchdb.md
Created July 30, 2014 20:40
couchdb backup & restore
  1. Download the database:
curl http://localhost:5984/mydb/_all_docs?include_docs=true > mydb.json
  1. Change the first line from:
    {"total_rows":1121,"offset":0,"rows":[
    *TO*
    {"docs":[
@irvingpop
irvingpop / drbd-backups.rb
Last active August 29, 2015 14:04
Enterprise Chef drbd-backups - improved version
#!/opt/opscode/embedded/bin/ruby
#
# Author:: Lamont Granquist (<lamont@opscode.com>)
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@irvingpop
irvingpop / orgmapper-find-oprhaned-objects.rb
Last active August 29, 2015 14:01
Stupid Orgmapper Tricks
org_guids = ORGS.all.map {|o| o.guid}
sql.select(:checksum, :org_id).from(:nodes).exclude(:org_id => org_guids)
# sql.select(:checksum, :org_id).from(:nodes).exclude(:org_id => org_guids).delete
sql.select(:checksum, :org_id).from(:cookbook_version_checksums).exclude(:org_id => org_guids)
# sql.select(:checksum, :org_id).from(:cookbook_version_checksums).exclude(:org_id => org_guids).delete
@irvingpop
irvingpop / drbd-lv-shrink.md
Last active November 24, 2022 06:44
EC11 Shrink the DRBD LV to make room for snapshots