Skip to content

Instantly share code, notes, and snippets.

View jessereynolds's full-sized avatar

Jesse Reynolds jessereynolds

  • Puppet
  • Melbourne, Victoria, Australia
View GitHub Profile
@jessereynolds
jessereynolds / test.rb
Created April 26, 2013 00:37
@johnf's code that reproduces the stack level too deep error on ubuntu 12.04.2 vm on esx comment out the [1].each do on line 42 and the problem goes away. I think defs foo and bar are not required to trigger the error.
#!/usr/bin/env ruby
require 'eventmachine'
require 'em-synchrony'
require 'thin'
#require 'thin/version'
#module Thin
# def self.win? # Are we runing windows
# true
@jessereynolds
jessereynolds / gist:5849704
Last active December 18, 2015 21:48
puppet - accessing items of an array within a hash from an erb template
I'm having trouble iterating over an array, that's been retrieved from a hash. Here's the hash definition in the node manifest:
$alias_ips = {
24 => [
'10.254.16.82/24',
],
}
This hash is passed as a parameter to a named type, which in turn processes an erb template
as part of a File definition. The erb file contains:
INFO executive: 2013-07-05 11:56:04 +0930 | client1-localhost-test-1:HTTP Port 443 | acknowledgement | NO CONTACTS
INFO executive: 2013-07-05 11:56:17 +0930 | client1-localhost-test-1:HTTP Port 443 | acknowledgement | NO CONTACTS
2013-07-10T15:27:24+09:30 [INFO] :: notify :: client1-localhost-test-1:HOST | problem | NO CONTACTS
2013-07-10T15:27:54+09:30 [INFO] :: notify :: client1-localhost-test-1:HOST | recovery | NO CONTACTS
@jessereynolds
jessereynolds / flapjack_visage.json
Created July 25, 2013 08:27
visage json for curl_json-flapjack/derive-all_time-action
{"heart-of-gold.local":{"curl_json-flapjack":{"derive-all_time-action":{"value":{"start":1374736284,"finish":1374740750,"data":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,n
@jessereynolds
jessereynolds / Gemfile
Created July 26, 2013 00:53
perftools.rb sampling profile of a partial flapjack benchmark run, with wallclock time (CPUPROFILE_REALTIME=1)
group :test do
...
gem 'perftools.rb'
end
(again run for about 70 seconds and killed)
jesse@Heart-of-Gold flapjack $ CPUPROFILE=/tmp/flapjack_profile_3 RUBYOPT="-r`gem which perftools | tail -1`" bin/flapjack start --no-daemonize
Flapjack starting...Starting flapjack service...
2013-07-26T10:24:51+09:30 [INFO] :: flapjack-jabber :: starting
2013-07-26T10:24:51+09:30 [INFO] :: flapjack-web :: starting web - class
2013-07-26T10:24:51+09:30 [INFO] :: flapjack-api :: starting api - class
2013-07-26T10:24:52+09:30 [INFO] :: flapjack-jabber :: Jabber Connected
2013-07-26T10:24:52+09:30 [INFO] :: flapjack-jabber :: Joining room [email protected]
2013-07-26T10:24:52+09:30 [INFO] :: flapjack-jabber :: Joining room [email protected]
@jessereynolds
jessereynolds / gist:6085708
Created July 26, 2013 02:46
CPUPROFILE_METHODS=1 Profile method calls. Each sample represents one method call made inside that function.
jesse@Heart-of-Gold flapjack $ pprof.rb --text /tmp/flapjack_profile
Using local file /Users/jesse/.rbenv/versions/1.9.3-p125/bin/ruby.
Using local file /tmp/flapjack_profile.
Use of uninitialized value $address in exists at /Users/jesse/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/perftools.rb-2.0.1/bin/pprof line 2781.
Total: 69688350 samples
8671483 12.4% 12.4% 8671489 12.4% Redis::Connection::CommandHelper#build_command
3515666 5.0% 17.5% 4017939 5.8% EventMachine::Deferrable#set_deferred_status
3515596 5.0% 22.5% 6528947 9.4% EventMachine::Deferrable#callback
2511410 3.6% 26.1% 2511410 3.6% EventMachine::Connection#send_data
2511115 3.6% 29.7% 29765172 42.7% Redis::Client#ensure_connected
@jessereynolds
jessereynolds / flapjack run
Created July 26, 2013 03:24
Another flapjack benchmark run, this time with a full run of events generated by the benchmark with the following parameters: - interval: 60 - cycles: 60 (simulating 1 hr duration) - entities: 100 - checks per entity: 5
jesse@Heart-of-Gold flapjack $ time CPUPROFILE=/tmp/flapjack_profile_4 RUBYOPT="-r`gem which perftools | tail -1`" bin/flapjack start --no-daemonize
Flapjack starting...Starting flapjack service...
2013-07-26T12:40:05+09:30 [INFO] :: flapjack-jabber :: starting
2013-07-26T12:40:05+09:30 [INFO] :: flapjack-web :: starting web - class
2013-07-26T12:40:05+09:30 [INFO] :: flapjack-api :: starting api - class
2013-07-26T12:40:08+09:30 [INFO] :: flapjack-jabber :: Jabber Connected
2013-07-26T12:40:08+09:30 [INFO] :: flapjack-jabber :: Joining room [email protected]
2013-07-26T12:40:08+09:30 [INFO] :: flapjack-jabber :: Joining room [email protected]
^C2013-07-26T12:43:53+09:30 [INFO] :: flapjack-coordinator :: processor: stopping -> stopped
2013-07-26T12:43:53+09:30 [INFO] :: flapjack-coordinator :: notifier: stopping -> stopped
@jessereynolds
jessereynolds / flapjack run 1.json
Last active December 20, 2015 09:39
2 flapjack benchmark runs, same number of events, different time periods
{
"events_created":24010,
"flapjack_runtime":127.21185874939,
"processing_rate":188.740265538453,
"ok_to_critical":4108,
"critical_to_ok":4101,
"checks_per_entity":5,
"entities":2,
"interval":3600,
"hours":2400.0,
@jessereynolds
jessereynolds / set_hash.rb
Created August 9, 2013 01:48
writing hashes in ruby, stylee
@last_error = {
:code => response.code,
:body => response.body
}
# vs
@last_error = {:code => response.code,
:body => response.body}