Skip to content

Instantly share code, notes, and snippets.

View eheydrick's full-sized avatar

Eric Heydrick eheydrick

View GitHub Profile
@eheydrick
eheydrick / fastly-datacenters
Created August 28, 2020 16:55
Get list of Fastly datacenters with curl
$ curl -s -H "Fastly-Key: <API Key>" https://api.fastly.com/datacenters | jq .
[
{
"code": "AMS",
"name": "Amsterdam",
"group": "Europe",
"coordinates": {
"x": 0,
"y": 0,
"latitude": 52.308613,
@eheydrick
eheydrick / monitoring.md
Last active August 8, 2018 17:34
Monitoring talk

Monitoring Overview

Why monitoring

  • Distributed systems are complex, things fail in unexpected ways
  • Monitoring gives you visibility into the system
  • Monitoring tells you stuff is broken before the customer notices

Types of monitoring

@eheydrick
eheydrick / rename-chef-org.txt
Last active August 13, 2018 04:50
Rename a chef org
It's not officially supported but you can rename an org on Chef Server 12+
# connect to the DB
sudo -u opscode-pgsql /opt/opscode/embedded/bin/psql -U "opscode-pgsql" -d opscode_chef
# get the id of the org you want to change
select * from orgs;
# update the org name
update orgs set name='NEW_ORG_NAME' where id='ORG_ID';

Ubuntu 16.04

Having just upgraded from Ubuntu 14.04 Trusty to 16.04 Xenial, I thought I'd share the pain points I encountered.

kswapd uses 100% CPU on smaller instances

There's a bug in newer kernels on EC2 that causes kswapd0 to consume 100% CPU. It seems to happen more often on smaller instances with less RAM (t2.micros for example). There is a workaround changing a udev configuration.

kernel doesn't boot on some larger instances

https://launchpad.net/api/1.0/~adiscon/+archive/ubuntu/v8-stable/signing_key_fingerprint
{'Content-Length': '742', 'Content-Encoding': 'gzip', 'Accept-Ranges': 'bytes', 'Vary': 'Accept-Encoding', 'Server': 'Apache', 'Last-Modified': 'Wed, 19 Nov 2014 16:06:07 GMT', 'Connection': 'close', 'ETag': '"6ca"', 'Date': 'Sun, 22 May 2016 00:14:51 GMT', 'Content-Type': 'text/html'}
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en"
>
<head>
Generated at 2016-05-16 23:18:38 +0000
Gem::MissingSpecError: chef_handler[HipChat::NotifyRoom] (hipchat::handler line 49) had an error: Gem::MissingSpecError: Could not find 'multi_xml' (>= 0.5.2) among 87 total gem(s)
Checked in 'GEM_PATH=/home/eric/.gem/ruby/2.1.0:/opt/chef/embedded/lib/ruby/gems/2.1.0', execute `gem env` for more information
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:308:in `to_specs'
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1439:in `block in activate_dependencies'
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1428:in `each'
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1428:in `activate_dependencies'
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1410:in `activate'
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1442:in `block in activate_dependencies'
/opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1428:in `each'
@eheydrick
eheydrick / pg_gem.rb
Last active February 26, 2016 19:38
install postgresql pg gem into the sensu embedded ruby
ark 'postgresql' do
url 'https://ftp.postgresql.org/pub/source/v9.4.6/postgresql-9.4.6.tar.bz2'
end
# build and install postgresql into the sensu embedded install
execute 'configure postgresql' do
command './configure --prefix /opt/sensu/embedded --with-openssl'
not_if '/opt/sensu/embedded/bin/gem list pg -i'
cwd '/usr/local/postgresql'
environment(
@eheydrick
eheydrick / gist:01e79eea53702b3d453c
Created February 18, 2016 20:40
chef search for nodes running a particular Ubuntu release
knife search 'lsb_description:"Ubuntu 14.04.3 LTS"' -i
@eheydrick
eheydrick / slack.rb
Last active January 22, 2016 07:39
sensu slack handler
# configuring a slack sensu handler
# create incoming-webhook at https://{your team}.slack.com/services/new/incoming-webhook
# get webhook URL
sensu_gem 'sensu-plugins-slack'
slack_conf = {
'webhook_url' => 'https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYY/ZZZZZZZZZZZZZ'
}
@eheydrick
eheydrick / load_metrics.json
Created December 17, 2015 00:39
sensu metrics
/etc/sensu/conf.d/checks/load_metrics.json on clients:
{
"checks": {
"load_metrics": {
"command": "/opt/sensu/embedded/bin/metrics-load.rb -s load",
"handlers": [
"metrics"
],
"standalone": true,