Skip to content

Instantly share code, notes, and snippets.

View maplebed's full-sized avatar

Ben Hartshorne maplebed

View GitHub Profile
both measurements show
count GET duration, rounded down to 1/10th second (so 0.09 -> 0.0)
60s sample with all nodes up, ignoring times >1s:
0 ben@fenari:/home/w/log/syslog$ cat /tmp/gets-allup.log | sort -n | uniq -c
3194 GET 0.0
626 GET 0.1
83 GET 0.2
29 GET 0.3
20 GET 0.4
in cookbooks/mongodb/recipes/default.rb:
66 # if the host has ganglia, install the mongo plugin.
67 if node.recipes.include?("ganglia::default")
68 ganglia_python "mongodb" do
69 action :enable
70 end
71 end
66 # if the host has ganglia, install the mongo plugin.
67 if node.recipes.include?("ganglia::default")
68 include_recipe "ganglia"
69 ganglia_python "mongodb" do
70 action :enable
71 end
72 end
574 if ( ! isset($graph_config) ) {
575 error_log("in isset");
576 if ( ($graph == "metric") &&
577 isset($_GET['title']) &&
578 $_GET['title'] !== '')
579 error_log("in graph == metric");
580 $metrictitle = sanitize($_GET['title']);
581 $php_report_file = $conf['graphdir'] . "/" . $graph . ".php";
582 $json_report_file = $conf['graphdir'] . "/" . $graph . ".json";
/usr/bin/rrdtool graph - --start '-7200s' --end now --width 480 --height 150 --title ' Number of Hits/s - 200 last 2hr' --vertical-label ' ' --lower-limit 0 --slope-mode -g DEF:'a0'='/var/lib/ganglia/rrds/web/web21/nginx_200_hits.rrd':'sum':AVERAGE DEF:'a1'='/var/lib/ganglia/rrds/web/web21/nginx_200_slow_hits.rrd':'sum':AVERAGE DEF:'a2'='/var/lib/ganglia/rrds/web/web22/nginx_200_hits.rrd':'sum':AVERAGE DEF:'a3'='/var/lib/ganglia/rrds/web/web22/nginx_200_slow_hits.rrd':'sum':AVERAGE DEF:'a4'='/var/lib/ganglia/rrds/web/web23/nginx_200_hits.rrd':'sum':AVERAGE DEF:'a5'='/var/lib/ganglia/rrds/web/web23/nginx_200_slow_hits.rrd':'sum':AVERAGE DEF:'a6'='/var/lib/ganglia/rrds/web/web24/nginx_200_hits.rrd':'sum':AVERAGE DEF:'a7'='/var/lib/ganglia/rrds/web/web24/nginx_200_slow_hits.rrd':'sum':AVERAGE CDEF:'total'=a0,a1,ADDNAN,a2,ADDNAN,a3,ADDNAN,a4,ADDNAN,a5,ADDNAN,a6,ADDNAN,a7,ADDNAN, AREA:'a0'#0000A3:'web21 nginx_200_hits' VDEF:a0_last=a0,LAST VDEF:a0_min=a0,MINIMUM VDEF:a0_avg=a0,AVERAGE VDEF:a0_max=a0,MAXIMUM GPRINT
@maplebed
maplebed / gist:4212567
Created December 5, 2012 05:18
Sinatra app to expose ganglia data
#!/usr/bin/env ruby
##
## This script exposes ganglia data for use by other apps.
## Ask it for a specific host/metric/time triplet, and it
## hands back a json string with the data.
## eg http://localhost/rrdfetch/web12/load_one/3600
## returns the last hour of the load_one metric.
##
[2013-01-15T19:05:23+00:00] INFO: HTTP Request Returned 404 Not Found: Cannot load data bag squid_urls
[2013-01-15T19:05:23+00:00] ERROR: Failed to list data bag items in data bag: "squid_urls"
[2013-01-15T19:05:23+00:00] INFO: no 'squid_urls' data bag
[2013-01-15T19:05:24+00:00] INFO: HTTP Request Returned 404 Not Found: Cannot load data bag squid_hosts
[2013-01-15T19:05:24+00:00] ERROR: Failed to list data bag items in data bag: "squid_hosts"
[2013-01-15T19:05:24+00:00] INFO: no 'squid_hosts' data bag
[2013-01-15T19:05:24+00:00] INFO: HTTP Request Returned 404 Not Found: Cannot load data bag squid_acls
[2013-01-15T19:05:24+00:00] ERROR: Failed to list data bag items in data bag: "squid_acls"
[2013-01-15T19:05:24+00:00] INFO: no 'squid_acls' data bag
82 # if ganglia and the gaglia-monitor-python packages are installed,
83 # enable the existing memcached module
84
85 if node.recipes.include?("ganglia::default")
86 include_recipe "ganglia::default"
87 execute "enable memcached module" do
88 only_if "test -e /etc/ganglia/conf.d/memcached.pyconf.disabled"
89 cwd "/etc/ganglia/conf.d/"
90 command "mv memcached.pyconf.disabled memcached.pyconf"
91 creates "memcached.pyconf"
@maplebed
maplebed / gist:4669873
Created January 30, 2013 01:43
possible patch for COOK-2257?
diff --git a/templates/default/hosts.cfg.erb b/templates/default/hosts.cfg.erb
index 3868fba..5f0f20c 100644
--- a/templates/default/hosts.cfg.erb
+++ b/templates/default/hosts.cfg.erb
@@ -24,7 +24,12 @@ define host {
ip = n['cloud']['public_ipv4']
else
ip = n['ipaddress']
- end %>
+ end
@maplebed
maplebed / zookeeper distributed lock example.rb
Last active December 12, 2015 01:39 — forked from isterin/gist:1328677
This gist (forked from https://gist.github.com/1328677) shows a simple example of using zookeeper to create a distributed lock. Run multiple instances of this script to see them fighting for the lock.
require 'zookeeper'
class Lock
def initialize(host, root="/my-app")
@zk = Zookeeper.new(host)
@root = root
end
def with_lock(app, timeout, timeout_callback, &block)
new_lock_res = @zk.create(:path => "#{@root}/#{app}-", :sequence => true, :ephemeral => true)