chef-handler-datadog 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/README.rdoc +5 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/chef-handler-datadog.rb +16 -8
- metadata +48 -31
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
An Exception and Report Handler for Chef.
|
4
4
|
|
5
|
+
{<img src="https://secure.travis-ci.org/DataDog/chef-handler-datadog.png?branch=master" alt="Build Status" />}[http://travis-ci.org/DataDog/chef-handler-datadog]
|
6
|
+
== Using chef-handler-datadog
|
7
|
+
|
8
|
+
The [Chef integration page](https://app.datadoghq.com/accounts/settings#integrations) has detailed instructions.
|
9
|
+
|
5
10
|
== Contributing to chef-handler-datadog
|
6
11
|
|
7
12
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
|
|
20
20
|
gem.summary = %Q{Chef Handler for DataDog events and metrics}
|
21
21
|
gem.description = %Q{This Handler will report the events and metrics for a chef-client run to DataDog.}
|
22
22
|
gem.email = "packages@datadoghq.com"
|
23
|
-
gem.authors = ["Mike Fiedler", "Adam Jacob"]
|
23
|
+
gem.authors = ["Mike Fiedler", "Adam Jacob", "Alexis Le-Quoc"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/lib/chef-handler-datadog.rb
CHANGED
@@ -8,18 +8,26 @@ class Datadog < Chef::Handler
|
|
8
8
|
# For the tags to work, the client must have created an Application Key on the
|
9
9
|
# "Account Settings" page here: https://app.datadoghq.com/account/settings
|
10
10
|
# It should be passed along from the node/role/environemnt attributes, as the default is nil.
|
11
|
-
def initialize(opts =
|
11
|
+
def initialize(opts = nil)
|
12
|
+
opts = opts || {}
|
12
13
|
@api_key = opts[:api_key]
|
13
14
|
@application_key = opts[:application_key]
|
15
|
+
# If we're on ec2, use the instance by default, unless instructed otherwise
|
16
|
+
@use_ec2_instance_id = !opts.has_key?(:use_ec2_instance_id) || opts.has_key?(:use_ec2_instance_id) && opts[:use_ec2_instance_id]
|
14
17
|
@dog = Dogapi::Client.new(@api_key, application_key = @application_key)
|
15
18
|
end
|
16
19
|
|
17
20
|
def report
|
21
|
+
hostname = run_status.node.name
|
22
|
+
if @use_ec2_instance_id && run_status.node.attribute?("ec2") && run_status.node.ec2.attribute?("instance_id")
|
23
|
+
hostname = run_status.node.ec2.instance_id
|
24
|
+
end
|
25
|
+
|
18
26
|
# Send the metrics
|
19
27
|
begin
|
20
|
-
@dog.emit_point("chef.resources.total", run_status.all_resources.length, :host =>
|
21
|
-
@dog.emit_point("chef.resources.updated", run_status.updated_resources.length, :host =>
|
22
|
-
@dog.emit_point("chef.resources.elapsed_time", run_status.elapsed_time, :host =>
|
28
|
+
@dog.emit_point("chef.resources.total", run_status.all_resources.length, :host => hostname)
|
29
|
+
@dog.emit_point("chef.resources.updated", run_status.updated_resources.length, :host => hostname)
|
30
|
+
@dog.emit_point("chef.resources.elapsed_time", run_status.elapsed_time, :host => hostname)
|
23
31
|
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
|
24
32
|
Chef::Log.error("Could not send metrics to Datadog. Connection error:\n" + e)
|
25
33
|
end
|
@@ -29,9 +37,9 @@ class Datadog < Chef::Handler
|
|
29
37
|
if run_status.success?
|
30
38
|
alert_type = "success"
|
31
39
|
event_priority = "low"
|
32
|
-
event_title << "Chef completed in #{run_time} on #{
|
40
|
+
event_title << "Chef completed in #{run_time} on #{hostname} "
|
33
41
|
else
|
34
|
-
event_title << "Chef failed in #{run_time} on #{
|
42
|
+
event_title << "Chef failed in #{run_time} on #{hostname} "
|
35
43
|
end
|
36
44
|
|
37
45
|
event_data = "Chef updated #{run_status.updated_resources.length} resources out of #{run_status.all_resources.length} resources total."
|
@@ -56,11 +64,11 @@ class Datadog < Chef::Handler
|
|
56
64
|
@dog.emit_event(Dogapi::Event.new(event_data,
|
57
65
|
:msg_title => event_title,
|
58
66
|
:event_type => 'config_management.run',
|
59
|
-
:event_object =>
|
67
|
+
:event_object => hostname,
|
60
68
|
:alert_type => alert_type,
|
61
69
|
:priority => event_priority,
|
62
70
|
:source_type_name => 'chef'
|
63
|
-
), :host =>
|
71
|
+
), :host => hostname)
|
64
72
|
|
65
73
|
# Get the current list of tags, remove any "role:" entries
|
66
74
|
host_tags = @dog.host_tags(node.name)[1]["tags"] || []
|
metadata
CHANGED
@@ -1,102 +1,115 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-handler-datadog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 5
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Mike Fiedler
|
13
14
|
- Adam Jacob
|
15
|
+
- Alexis Le-Quoc
|
14
16
|
autorequire:
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-
|
19
|
-
default_executable:
|
20
|
+
date: 2012-07-27 00:00:00 Z
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
+
name: chef
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
23
27
|
requirements:
|
24
28
|
- - ">="
|
25
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 31
|
26
31
|
segments:
|
27
32
|
- 0
|
28
33
|
- 9
|
29
34
|
- 18
|
30
35
|
version: 0.9.18
|
31
|
-
requirement: *id001
|
32
|
-
name: chef
|
33
|
-
prerelease: false
|
34
36
|
type: :runtime
|
37
|
+
version_requirements: *id001
|
35
38
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
39
|
+
name: dogapi
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
37
43
|
requirements:
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 11
|
40
47
|
segments:
|
41
48
|
- 1
|
42
49
|
- 2
|
43
50
|
version: "1.2"
|
44
|
-
requirement: *id002
|
45
|
-
name: dogapi
|
46
|
-
prerelease: false
|
47
51
|
type: :runtime
|
52
|
+
version_requirements: *id002
|
48
53
|
- !ruby/object:Gem::Dependency
|
49
|
-
|
54
|
+
name: shoulda
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
50
58
|
requirements:
|
51
59
|
- - ">="
|
52
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
53
62
|
segments:
|
54
63
|
- 0
|
55
64
|
version: "0"
|
56
|
-
requirement: *id003
|
57
|
-
name: shoulda
|
58
|
-
prerelease: false
|
59
65
|
type: :development
|
66
|
+
version_requirements: *id003
|
60
67
|
- !ruby/object:Gem::Dependency
|
61
|
-
|
68
|
+
name: bundler
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
62
72
|
requirements:
|
63
73
|
- - ">="
|
64
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 23
|
65
76
|
segments:
|
66
77
|
- 1
|
67
78
|
- 0
|
68
79
|
- 0
|
69
80
|
version: 1.0.0
|
70
|
-
requirement: *id004
|
71
|
-
name: bundler
|
72
|
-
prerelease: false
|
73
81
|
type: :development
|
82
|
+
version_requirements: *id004
|
74
83
|
- !ruby/object:Gem::Dependency
|
75
|
-
|
84
|
+
name: jeweler
|
85
|
+
prerelease: false
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
76
88
|
requirements:
|
77
89
|
- - ~>
|
78
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 7
|
79
92
|
segments:
|
80
93
|
- 1
|
81
94
|
- 6
|
82
95
|
- 4
|
83
96
|
version: 1.6.4
|
84
|
-
requirement: *id005
|
85
|
-
name: jeweler
|
86
|
-
prerelease: false
|
87
97
|
type: :development
|
98
|
+
version_requirements: *id005
|
88
99
|
- !ruby/object:Gem::Dependency
|
89
|
-
|
100
|
+
name: rdoc
|
101
|
+
prerelease: false
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
90
104
|
requirements:
|
91
105
|
- - ">="
|
92
106
|
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
93
108
|
segments:
|
94
109
|
- 0
|
95
110
|
version: "0"
|
96
|
-
requirement: *id006
|
97
|
-
name: rdoc
|
98
|
-
prerelease: false
|
99
111
|
type: :development
|
112
|
+
version_requirements: *id006
|
100
113
|
description: This Handler will report the events and metrics for a chef-client run to DataDog.
|
101
114
|
email: packages@datadoghq.com
|
102
115
|
executables: []
|
@@ -107,6 +120,7 @@ extra_rdoc_files:
|
|
107
120
|
- LICENSE.txt
|
108
121
|
- README.rdoc
|
109
122
|
files:
|
123
|
+
- .travis.yml
|
110
124
|
- Gemfile
|
111
125
|
- Gemfile.lock
|
112
126
|
- LICENSE.txt
|
@@ -116,7 +130,6 @@ files:
|
|
116
130
|
- lib/chef-handler-datadog.rb
|
117
131
|
- test/helper.rb
|
118
132
|
- test/test_chef-handler-datadog.rb
|
119
|
-
has_rdoc: true
|
120
133
|
homepage: http://www.datadoghq.com/
|
121
134
|
licenses:
|
122
135
|
- BSD
|
@@ -126,23 +139,27 @@ rdoc_options: []
|
|
126
139
|
require_paths:
|
127
140
|
- lib
|
128
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
129
143
|
requirements:
|
130
144
|
- - ">="
|
131
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
132
147
|
segments:
|
133
148
|
- 0
|
134
149
|
version: "0"
|
135
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
136
152
|
requirements:
|
137
153
|
- - ">="
|
138
154
|
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
139
156
|
segments:
|
140
157
|
- 0
|
141
158
|
version: "0"
|
142
159
|
requirements: []
|
143
160
|
|
144
161
|
rubyforge_project:
|
145
|
-
rubygems_version: 1.
|
162
|
+
rubygems_version: 1.8.24
|
146
163
|
signing_key:
|
147
164
|
specification_version: 3
|
148
165
|
summary: Chef Handler for DataDog events and metrics
|