Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import.

  • Loading branch information...
commit 4b7ac2546c007c48e9991acacb60903ca0a872c6 0 parents
@hectcastro authored
33 README.md
@@ -0,0 +1,33 @@
+# Description #
+
+Installs and configures StatsD.
+
+# Requirements #
+
+## Platforms ##
+
+* Ubuntu 11.10 (Oneiric)
+
+## Cookbooks ##
+
+* git
+* nodejs
+
+# Attributes #
+
+* `node["statsd"]["dir"]` - Directory to install into.
+* `node["statsd"]["conf_dir"]` - Directory for StatsD configuration.
+* `node["statsd"]["repository"]` - Reference to a StatsD repository.
+* `node["statsd"]["log_file"]` - Path to the StatsD log file.
+* `node["statsd"]["flush_interval"]` - Flush interval in milliseconds.
+* `node["statsd"]["port"]` - Port to run StatsD on.
+* `node["statsd"]["graphite_host"]` - Graphite host.
+* `node["statsd"]["graphite_port"]` - Graphite port.
+
+# Recipes #
+
+* `recipe[statsd]` will install StatsD.
+
+# Usage #
+
+Currently only supports installation via a Git repository.
8 attributes/default.rb
@@ -0,0 +1,8 @@
+default["statsd"]["dir"] = "/usr/share/statsd"
+default["statsd"]["conf_dir"] = "/etc/statsd"
+default["statsd"]["repository"] = "git://github.com/etsy/statsd.git"
+default["statsd"]["log_file"] = "/var/log/statsd.log"
+default["statsd"]["flush_interval"] = 10000
+default["statsd"]["port"] = 8125
+default["statsd"]["graphite_host"] = "localhost"
+default["statsd"]["graphite_port"] = 2003
14 metadata.rb
@@ -0,0 +1,14 @@
+maintainer "Hector Castro"
+maintainer_email "hectcastro@gmail.com"
+license "Apache 2.0"
+description "Installs and configures StatsD."
+version "0.0.1"
+recipe "statsd", "Installs and configures StatsD"
+
+depends "git"
+depends "nodejs"
+
+%w{ ubuntu }.each do |os|
+ supports os
+end
+
55 recipes/default.rb
@@ -0,0 +1,55 @@
+include_recipe "git"
+include_recipe "nodejs"
+
+git node["statsd"]["dir"] do
+ repository node["statsd"]["repository"]
+ action :sync
+end
+
+directory node["statsd"]["conf_dir"] do
+ action :create
+end
+
+template "#{node["statsd"]["conf_dir"]}/config.js" do
+ mode "0644"
+ source "config.js.erb"
+ variables(
+ :port => node["statsd"]["port"],
+ :flush_interval => node["statsd"]["flush_interval"],
+ :graphite_port => node["statsd"]["graphite_port"],
+ :graphite_host => node["statsd"]["graphite_host"]
+ )
+ notifies :restart, "service[statsd]"
+end
+
+directory "#{node["statsd"]["dir"]}/scripts" do
+ action :create
+end
+
+template "#{node["statsd"]["dir"]}/scripts/start" do
+ source "start.erb"
+ mode 0755
+ variables(
+ :log_file => node["statsd"]["log_file"]
+ )
+end
+
+template "/etc/init/statsd.conf" do
+ mode "0644"
+ source "statsd.conf.erb"
+end
+
+user "statsd" do
+ system true
+ shell "/bin/false"
+end
+
+file node["statsd"]["log_file"] do
+ owner "statsd"
+ action :create
+end
+
+service "statsd" do
+ provider Chef::Provider::Service::Upstart
+ action [ :enable, :start ]
+end
8 templates/default/config.js.erb
@@ -0,0 +1,8 @@
+{
+ "graphService": "graphite",
+ "graphitePort": <%= @graphite_port %>,
+ "graphiteHost": "<%= @graphite_host %>",
+ "batch": 200,
+ "port": <%= @port %>,
+ "flushInterval": <%= @flush_interval %>
+}
4 templates/default/start.erb
@@ -0,0 +1,4 @@
+#!/bin/bash
+# Called by Upstart, /etc/init/statsd.conf
+
+/usr/local/bin/node /usr/share/statsd/stats.js /etc/statsd/config.js 2>&1 >> <%= @log_file %>
11 templates/default/statsd.conf.erb
@@ -0,0 +1,11 @@
+description "statsd"
+author "Chef"
+
+start on startup
+stop on shutdown
+
+script
+ export HOME="/root"
+
+ exec sudo -u statsd /usr/share/statsd/scripts/start
+end script
Please sign in to comment.
Something went wrong with that request. Please try again.