From 67ebd3973cd27a1ff66fe4471db86ef92b186e73 Mon Sep 17 00:00:00 2001 From: Sean Porter Date: Wed, 17 Sep 2014 16:47:52 -0700 Subject: [PATCH] readme, 2 space indent for code snippets --- README.md | 106 +++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 52a28d0..718514d 100644 --- a/README.md +++ b/README.md @@ -15,40 +15,40 @@ user. You can't manage what you don't measure. Append the following to your Chef client configs, usually at `/etc/chef/client.rb` ```ruby - require "chef-metrics" + require "chef-metrics" - metric_handler = ChefMetrics.new do - # see examples below - end + metric_handler = ChefMetrics.new do + # see examples below + end - report_handlers << metric_handler - exception_handlers << metric_handler + report_handlers << metric_handler + exception_handlers << metric_handler ``` Alternatively, you can use the Chef cookbook [LWRP](http://community.opscode.com/cookbooks/chef_handler). ```ruby - chef_gem "chef-metrics" + chef_gem "chef-metrics" - handler_path = File.join(node["chef_handler"]["handler_path"], "chef_metrics.rb") + handler_path = File.join(node["chef_handler"]["handler_path"], "chef_metrics.rb") - directory File.dirname(handler_path) do - recursive true - end + directory File.dirname(handler_path) do + recursive true + end - file handler_path do - content "require 'chef-metrics'" - end + file handler_path do + content "require 'chef-metrics'" + end - action_block = Proc.new do - # see examples below - end + action_block = Proc.new do + # see examples below + end - chef_handler "ChefMetrics" do - source handler_path - arguments action_block - end + chef_handler "ChefMetrics" do + source handler_path + arguments action_block + end ``` ## Examples @@ -56,9 +56,9 @@ Alternatively, you can use the Chef cookbook The following examples are "action" blocks: ```ruby - metric_handler = ChefMetrics.new do - # action block - end + metric_handler = ChefMetrics.new do + # action block + end ``` Note: I recommend adding logging, timeouts, and error handling to the following. @@ -66,46 +66,46 @@ Note: I recommend adding logging, timeouts, and error handling to the following. ### Graphite ```ruby - require 'socket' + require 'socket' - socket = TCPSocket.new(GRAPHITE_HOST, GRAPHITE_PORT) - socket.write(graphite_formatted) - socket.close + socket = TCPSocket.new(GRAPHITE_HOST, GRAPHITE_PORT) + socket.write(graphite_formatted) + socket.close ``` ### Sensu ```ruby - require 'socket' - - sensu_result = { - :name => "chef_report", - :type => "metric", - :handler => "metrics", - :output => graphite_formatted - } - - socket = TCPSocket.open('127.0.0.1', 3030) - socket.write(sensu_result.to_json) - socket.close + require 'socket' + + sensu_result = { + :name => "chef_report", + :type => "metric", + :handler => "metrics", + :output => graphite_formatted + } + + socket = TCPSocket.open('127.0.0.1', 3030) + socket.write(sensu_result.to_json) + socket.close ``` ### More ```ruby - puts metrics - # {:updated_resources=>12, :all_resources=>236, :elapsed_time=>22, :success=>1, :fail=>0} - - puts graphite_formatted - # chef.i-424242.updated_resources 12 - # chef.i-424242.all_resources 236 - # ... - - self.metric_scheme = "#{node.environment}.chef.#{node.name.gsub(".", "_")}" - puts graphite_formatted - # production.chef.i-424242.updated_resources 12 - # production.chef.i-424242.all_resources 236 - # ... + puts metrics + # {:updated_resources=>12, :all_resources=>236, :elapsed_time=>22, :success=>1, :fail=>0} + + puts graphite_formatted + # chef.i-424242.updated_resources 12 + # chef.i-424242.all_resources 236 + # ... + + self.metric_scheme = "#{node.environment}.chef.#{node.name.gsub(".", "_")}" + puts graphite_formatted + # production.chef.i-424242.updated_resources 12 + # production.chef.i-424242.all_resources 236 + # ... ``` ## Contributing