Skip to content

Instantly share code, notes, and snippets.

View kbarber's full-sized avatar

Ken Barber kbarber

View GitHub Profile
lein test :only com.puppetlabs.puppetdb.test.http.facts/factset-queries
FAIL in (factset-queries) (facts.clj:892)
Testing version :v4 factset queries should return appropriate results
expected: (= (into {} (first responses)) {"facts" {"my_structured_fact" {"a" 1, "b" 3.14, "c" ["a" "b" "c"], "d" {"n" ""}, "e" "1", "f" nil}, "domain" "testing.com", "uptime_seconds" "4000", "test#~delimiter" "foo"}, "timestamp" (to-string current-time), "environment" "DEV", "certname" "foo1"})
actual: (not (= {"facts" {"test#~delimiter" "foo", "uptime_seconds" "4000", "domain" "testing.com", "my_structured_fact" {"b" 3.14, "a" 1, "e" "1", "d" {"n" ""}, "f" nil, "c" ["a" "b" "c"]}}, "timestamp" "2014-07-31T23:27:45.298Z", "environment" "DEV", "certname" "foo1"} {"facts" {"uptime_seconds" "4000", "domain" "testing.com", "test#~delimiter" "foo", "my_structured_fact" {"d" {"n" ""}, "f" nil, "e" "1", "a" 1, "b" 3.14, "c" ["a" "b" "c"]}}, "timestamp" "2014-07-31T23:27:45.297Z", "environment" "DEV", "certname" "foo1"}))
lein test :o
@kylog
kylog / releaseticket.rb
Last active July 15, 2016 02:30
One-off script to create a puppet release ticket
#!/usr/bin/env ruby
require 'jira'
require 'pp'
require 'getoptlong'
# default values
username = "gepetto-bot"
password = ENV["GEPETTO_BOT_PASSWORD"]
@kbarber
kbarber / gist:7337788
Last active December 27, 2015 13:59
Java VM tuning for GC monitoring
JAVA_ARGS="-server -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/puppetdb/puppetdb-oom.hprof -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -verbose:gc -Xloggc:/var/log/puppetdb/gc.log"
@kbarber
kbarber / gist:5772864
Last active December 18, 2015 10:59
PuppetDB PostgreSQL Database Tuning

Main reference for tuning:

http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

Most importantly you should make sure you have a way of measuring performance first, and then when you try new changes try them one at a time, gather data (3-5 samples are a good start, you might need to run tests a few times to get take into account cache priming) then compare with old settings.

The most important principle is, the less disk IO the better. So if we have the correct indexing, it works less to find an answer. If you can cache data into RAM, that even better, as the disk IO will be less frequent.

So focus on:

@kbarber
kbarber / gist:5767525
Last active December 18, 2015 10:19
Patch for timing the puppetdb terminus
diff --git a/indirector/catalog/puppetdb.rb b/indirector/catalog/puppetdb.rb
index 227eeab..6eb6ed0 100644
--- a/indirector/catalog/puppetdb.rb
+++ b/indirector/catalog/puppetdb.rb
@@ -7,9 +7,15 @@ class Puppet::Resource::Catalog::Puppetdb < Puppet::Indirector::REST
include Puppet::Util::Puppetdb::CommandNames
def save(request)
+ start = Time.now
+
@kbarber
kbarber / gist:5022099
Created February 24, 2013 00:49
All matchers for iptables (or at least as many as I could get working from the docs)
# Generated by iptables-save v1.4.7 on Sun Feb 24 00:48:11 2013
*mangle
:PREROUTING ACCEPT [756:54757]
:INPUT ACCEPT [756:54757]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [578:527896]
:POSTROUTING ACCEPT [578:527896]
-A INPUT -s 1.1.1.2/32 -j CHECKSUM --checksum-fill
-A OUTPUT -s 1.1.1.2/32 -j CLASSIFY --set-class 0004:0056
COMMIT
@kbarber
kbarber / ruby_yaml_hash_keysort2.rb
Created February 10, 2012 16:54
Blog: YAML/hash sort 2
#!/usr/bin/env ruby
require 'yaml'
a = {
"a" => "b",
"e" => "b",
"c" => "b",
"p" => "b",
"z" => "b",
@kbarber
kbarber / ruby_yaml_keysort.rb
Created February 10, 2012 16:51
Blog: YAML/hash sort 1
#!/usr/bin/env ruby
require 'yaml'
a = {
"a" => "b",
"e" => "b",
"c" => "b",
"p" => "b",
"z" => "b",