chef-handler-datadog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "dogapi", ">= 1.2.3"
6
+ gem "chef", ">= 0.9.18"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "shoulda", ">= 0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.4"
14
+ gem "rcov", ">= 0"
15
+ gem "rdoc", ">= 0"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bunny (0.7.8)
5
+ chef (0.10.4)
6
+ bunny (>= 0.6.0)
7
+ erubis
8
+ highline
9
+ json (>= 1.4.4, <= 1.5.2)
10
+ mixlib-authentication (>= 1.1.0)
11
+ mixlib-cli (>= 1.1.0)
12
+ mixlib-config (>= 1.1.2)
13
+ mixlib-log (>= 1.3.0)
14
+ moneta
15
+ net-ssh (~> 2.1.3)
16
+ net-ssh-multi (~> 1.1.0)
17
+ ohai (>= 0.6.0)
18
+ rest-client (>= 1.0.4, < 1.7.0)
19
+ treetop (~> 1.4.9)
20
+ uuidtools
21
+ dogapi (1.2.3)
22
+ json (>= 1.5.1)
23
+ erubis (2.7.0)
24
+ git (1.2.5)
25
+ highline (1.6.8)
26
+ jeweler (1.6.4)
27
+ bundler (~> 1.0)
28
+ git (>= 1.2.5)
29
+ rake
30
+ json (1.5.2)
31
+ mime-types (1.17.2)
32
+ mixlib-authentication (1.1.4)
33
+ mixlib-log
34
+ mixlib-cli (1.2.2)
35
+ mixlib-config (1.1.2)
36
+ mixlib-log (1.3.0)
37
+ moneta (0.6.0)
38
+ net-ssh (2.1.4)
39
+ net-ssh-gateway (1.1.0)
40
+ net-ssh (>= 1.99.1)
41
+ net-ssh-multi (1.1)
42
+ net-ssh (>= 2.1.4)
43
+ net-ssh-gateway (>= 0.99.0)
44
+ ohai (0.6.10)
45
+ mixlib-cli
46
+ mixlib-config
47
+ mixlib-log
48
+ systemu (~> 2.2.0)
49
+ yajl-ruby
50
+ polyglot (0.3.3)
51
+ rake (0.9.2.2)
52
+ rcov (0.9.11)
53
+ rdoc (3.11)
54
+ json (~> 1.4)
55
+ rest-client (1.6.7)
56
+ mime-types (>= 1.16)
57
+ shoulda (2.11.3)
58
+ systemu (2.2.0)
59
+ treetop (1.4.10)
60
+ polyglot
61
+ polyglot (>= 0.3.1)
62
+ uuidtools (2.1.2)
63
+ yajl-ruby (1.1.0)
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ bundler (~> 1.0.0)
70
+ chef (>= 0.9.18)
71
+ dogapi (>= 1.2.3)
72
+ jeweler (~> 1.6.4)
73
+ rcov
74
+ rdoc
75
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Mike Fiedler
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = chef-handler-datadog
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to chef-handler-datadog
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Mike Fiedler. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "chef-handler-datadog"
18
+ gem.homepage = "http://github.com/miketheman/chef-handler-datadog"
19
+ gem.license = "BSD"
20
+ gem.summary = %Q{Chef Handler for DataDog events and metrics}
21
+ gem.description = %Q{Chef Handler for DataDog events and metrics.}
22
+ gem.email = "miketheman@gmail.com"
23
+ gem.authors = ["Mike Fiedler"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ RDoc::Task.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "chef-handler-datadog #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "chef-handler-datadog"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mike Fiedler"]
12
+ s.date = "2011-11-16"
13
+ s.description = "Chef Handler for DataDog events and metrics."
14
+ s.email = "miketheman@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "chef-handler-datadog.gemspec",
28
+ "lib/chef/handler/datadog_handler.rb",
29
+ "test/helper.rb",
30
+ "test/test_chef-handler-datadog.rb"
31
+ ]
32
+ s.homepage = "http://github.com/miketheman/chef-handler-datadog"
33
+ s.licenses = ["BSD"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = "1.8.10"
36
+ s.summary = "Chef Handler for DataDog events and metrics"
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<dogapi>, [">= 1.2.3"])
43
+ s.add_runtime_dependency(%q<chef>, [">= 0.9.18"])
44
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
45
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
46
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
47
+ s.add_development_dependency(%q<rcov>, [">= 0"])
48
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<dogapi>, [">= 1.2.3"])
51
+ s.add_dependency(%q<chef>, [">= 0.9.18"])
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ s.add_dependency(%q<rdoc>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<dogapi>, [">= 1.2.3"])
60
+ s.add_dependency(%q<chef>, [">= 0.9.18"])
61
+ s.add_dependency(%q<shoulda>, [">= 0"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
64
+ s.add_dependency(%q<rcov>, [">= 0"])
65
+ s.add_dependency(%q<rdoc>, [">= 0"])
66
+ end
67
+ end
68
+
@@ -0,0 +1,41 @@
1
+ require "chef/handler"
2
+ require "dogapi"
3
+
4
+ class DataDog < Chef::Handler
5
+ def initialize(api_key)
6
+ @api_key = api_key
7
+ @dog = Dogapi::Client.new(api_key)
8
+ end
9
+
10
+ def report
11
+ # our_time = Time.now.utc
12
+ @dog.emit_point("chef.resources.total", run_status.all_resources.length, :host => run_status.node.name)
13
+ @dog.emit_point("chef.resources.updated", run_status.updated_resources.length, :host => run_status.node.name)
14
+ @dog.emit_point("chef.resources.elapsed_time", run_status.elapsed_time, :host => run_status.node.name)
15
+
16
+ event_data = "Chef run for #{run_status.node.name}"
17
+ if run_status.success?
18
+ event_data << " complete in #{run_status.elapsed_time} seconds\n"
19
+ else
20
+ event_data << " failed in #{run_status.elapsed_time} seconds\n"
21
+ end
22
+ event_data << "Managed #{run_status.all_resources.length} resources\n"
23
+ event_data << "Updated #{run_status.updated_resources.length} resources"
24
+ if run_status.updated_resources.length.to_i > 0
25
+ event_data << "\n\n@@@\n"
26
+ run_status.updated_resources.each do |r|
27
+ event_data << "- #{r.to_s} (#{r.defined_at})\n"
28
+ end
29
+ event_data << "\n@@@\n"
30
+ end
31
+
32
+ if run_status.failed?
33
+ event_data << "\n\n@@@\n#{run_status.formatted_exception}\n@@@\n"
34
+ event_data << "\n\n@@@\n#{run_status.backtrace.join("\n")}\n@@@\n"
35
+ end
36
+
37
+ # Chef::Log.warn(event_data)
38
+ # get existig tags, prune, reset with chefroles, and tag #chef
39
+ @dog.emit_event(Dogapi::Event.new(event_data), :host => run_status.node.name)
40
+ end
41
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'chef/handler/datadog_handler'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestChefHandlerDatadog < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-handler-datadog
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Mike Fiedler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 25
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 3
31
+ version: 1.2.3
32
+ version_requirements: *id001
33
+ name: dogapi
34
+ prerelease: false
35
+ type: :runtime
36
+ - !ruby/object:Gem::Dependency
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 31
43
+ segments:
44
+ - 0
45
+ - 9
46
+ - 18
47
+ version: 0.9.18
48
+ version_requirements: *id002
49
+ name: chef
50
+ prerelease: false
51
+ type: :runtime
52
+ - !ruby/object:Gem::Dependency
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ version_requirements: *id003
63
+ name: shoulda
64
+ prerelease: false
65
+ type: :development
66
+ - !ruby/object:Gem::Dependency
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ hash: 23
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ version: 1.0.0
78
+ version_requirements: *id004
79
+ name: bundler
80
+ prerelease: false
81
+ type: :development
82
+ - !ruby/object:Gem::Dependency
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ hash: 7
89
+ segments:
90
+ - 1
91
+ - 6
92
+ - 4
93
+ version: 1.6.4
94
+ version_requirements: *id005
95
+ name: jeweler
96
+ prerelease: false
97
+ type: :development
98
+ - !ruby/object:Gem::Dependency
99
+ requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ version_requirements: *id006
109
+ name: rcov
110
+ prerelease: false
111
+ type: :development
112
+ - !ruby/object:Gem::Dependency
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ version_requirements: *id007
123
+ name: rdoc
124
+ prerelease: false
125
+ type: :development
126
+ description: Chef Handler for DataDog events and metrics.
127
+ email: miketheman@gmail.com
128
+ executables: []
129
+
130
+ extensions: []
131
+
132
+ extra_rdoc_files:
133
+ - LICENSE.txt
134
+ - README.rdoc
135
+ files:
136
+ - .document
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.rdoc
141
+ - Rakefile
142
+ - VERSION
143
+ - chef-handler-datadog.gemspec
144
+ - lib/chef/handler/datadog_handler.rb
145
+ - test/helper.rb
146
+ - test/test_chef-handler-datadog.rb
147
+ homepage: http://github.com/miketheman/chef-handler-datadog
148
+ licenses:
149
+ - BSD
150
+ post_install_message:
151
+ rdoc_options: []
152
+
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ hash: 3
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: 3
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ requirements: []
174
+
175
+ rubyforge_project:
176
+ rubygems_version: 1.8.10
177
+ signing_key:
178
+ specification_version: 3
179
+ summary: Chef Handler for DataDog events and metrics
180
+ test_files: []
181
+