Skip to content

Instantly share code, notes, and snippets.

sysctl Mash.new unless attribute?("sysctl")
"lvs": {
"wikia": {
"port": "80",
"ip": "208.68.167.136",
"backends": {
"208.68.167.133": "100",
"208.68.167.134": "100"
},
"options": {
"virtualhost": "www.wikia.com",
@macros
macros / heartbeat.rb
Created August 3, 2009 23:14
Chef recipe for heartbeat
#
# Cookbook Name:: heartbeat
# Attributes:: heartbeat
#
# Copyright 2008, Wikia, Inc.
#
# 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
#
erb : worker (port 4000) ~ Params: {"format"=>nil, "action"=>"show", "id"=>"squid-forward3", "controller"=>"chef_server_slice/nodes"}
merb : worker (port 4000) ~
merb : worker (port 4000) ~ Started request handling: Thu Aug 06 21:40:47 -0700 2009
merb : worker (port 4000) ~ Routed to: {"format"=>nil, "action"=>"show", "id"=>"squid-forward4", "controller"=>"chef_server_slice/nodes"}
merb : worker (port 4000) ~ Params: {"format"=>nil, "action"=>"show", "id"=>"squid-forward4", "controller"=>"chef_server_slice/nodes"}
merb : worker (port 4000) ~ You must authenticate first! - (Merb::ControllerExceptions::Unauthorized)
/usr/lib/ruby/gems/1.8/gems/chef-server-slice-0.7.4/app/controllers/application.rb:115:in `access_denied'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/controller/abstract_controller.rb:293:in `__send__'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/controller/abstract_controller.rb:293:in `_dispatch'
merb : worker (port 4000) ~ Started request handling: Thu Aug 06 21:48:34 -0700 2009
merb : worker (port 4000) ~ Routed to: {"format"=>nil, "action"=>"show", "id"=>"r8-12-36", "controller"=>"chef_server_slice/openid_register"}
merb : worker (port 4000) ~ Params: {"format"=>nil, "action"=>"show", "id"=>"r8-12-36", "controller"=>"chef_server_slice/openid_register"}
~ Sending HTTP Request via GET to /chef/openid_registration_r8-12-36
~ #<Chef::OpenIDRegistration:0x7fb1aaa0b820 @name="r8-12-36", @couchdb=#<Chef::CouchDB:0x7fb1aaa0b7d0 @rest=#<Chef::REST:0x7fb1aaa0b780 @cookies={}, @url="http://localhost:5984">>, @salt="Fri May 15 11:29:54 -0700 2009HQfyqIUN0T2zF3A0Mty3LtUppqS6k1", @admin=false, @couchdb_rev="1620623919", @validated=true, @password="09e666f161b45cd27d5e988390e497a741207180">
merb : worker (port 4000) ~ {:before_filters_time=>6.9e-05, :action_time=>0.005517, :dispatch_time=>0.006136, :after_filters_time=>2.6e-05}
merb : worker (port 4000) ~
merb : worker (port 4000) ~ Started request handling:
chef-serv 8604 root 3u IPv4 26828643 TCP localhost:33995->localhost:61613 (ESTABLISHED)
chef-serv 8606 root 3u IPv4 26828643 TCP localhost:33995->localhost:61613 (ESTABLISHED)
chef-serv 8607 root 3u IPv4 26828643 TCP localhost:33995->localhost:61613 (ESTABLISHED)
chef-serv 8607 root 8u IPv4 26828697 TCP *:4000 (LISTEN)
chef-serv 8607 root 9u IPv4 26828828 TCP chef1:4000->lvs7:53658 (ESTABLISHED)
chef-serv 8607 root 28u IPv4 26828823 TCP chef1:4000->r9-1-9:35126 (ESTABLISHED)
chef-serv 8607 root 29u IPv4 26828829 TCP chef1:4000->squid-forward3:37074 (ESTABLISHED)
chef-serv 8608 root 3u IPv4 26828643 TCP localhost:33995->localhost:61613 (ESTABLISHED)
chef-serv 8608 root 8u IPv4 26828699 TCP *:4001 (LISTEN)
#!/usr/bin/perl
use warnings;
use strict;
use Working::Daemon;
use IO::Socket;
use threads;
use threads::shared;
use Data::Dumper;
#!/us/bin/perl
use warnings;
use strict;
use Working::Daemon;
use IO::Socket;
use JSON::DWIW;
use LWP::UserAgent;
use threads;
use threads::shared;
init_workers();
while(1) {
if ($apache_load > 100 ) {
remove_worker();
} elsif ( $queue_size > 10000 ) {
add_worker();
}
sleep 5;
}
#!/usr/bin/perl
use warnings;
use strict;
use threads;
my $minthreads = 5;
my $maxthreads = 50;
my $queue_size = 1001;
my @workers;
my @zombies;