chef-handler-statsd 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d3f4d5609e65f11b19edcedef02862a2e2ff8f54197c16c08da56b9b4436bb93
4
+ data.tar.gz: e31026170b08f3c214d878743c2999b1cf312ae2f6b5b1bdd688b5892eb4c02a
5
+ SHA512:
6
+ metadata.gz: 80eb83c6bdba972fe75c0d320a26727a0178e544f22e8f305e1966c3a05b0ef42f5492cd8ba5d9350cf50ad8da2a6a1f2bbc74639be872991bf5b4bbf55db7b2
7
+ data.tar.gz: 6bcccb63f1db7ad1c59598b9ab9d0a9825fa1f4d7a25e187718e743e2a17e8c457a243808ffafaff5e7e3f1b4f2c880cf5296f4997b60e40c937dd507363a651
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.lock
4
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in chef-handler-statsd.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 Craig Thayer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Chef Handler Statsd
2
+
3
+ Chef Handler Statsd is an OpsCode Chef report/exception handler for sending
4
+ Chef metrics to a statsd compatible server. Metrics are gathered using
5
+ `run_status`.
6
+
7
+ ## Installation
8
+
9
+ gem install chef-handler-statsd
10
+
11
+ ## Usage
12
+
13
+ Append the following to your Chef client configs, usually at `/etc/chef/client.rb`
14
+
15
+ ```ruby
16
+ require "chef-handler-statsd"
17
+
18
+ handler = ChefHandlerStatsd.new('localhost', 8125)
19
+
20
+ report_handlers << handler
21
+ exception_handlers << handler
22
+ ```
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.authors = ["Craig Thayer"]
3
+ gem.email = ["cthayer@craigthayer.com"]
4
+ gem.description = "Chef report handler to send metrics to statsd"
5
+ gem.summary = "Chef report handler to send metrics to statsd"
6
+ gem.homepage = "https://github.com/cthayer/chef-handler-statsd"
7
+ gem.license = "MIT"
8
+
9
+ gem.files = `git ls-files`.split($\)
10
+ gem.name = "chef-handler-statsd"
11
+ gem.require_paths = ["lib"]
12
+ gem.version = "1.0.0"
13
+
14
+ gem.add_dependency 'dogstatsd-ruby', '~> 4.5.0'
15
+ end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'chef'
3
+ require 'chef/handler'
4
+ require 'datadog/statsd'
5
+
6
+ class ChefHandlerStatsd < Chef::Handler
7
+ def initialize(host = 'localhost', port = 8125)
8
+ @statsd = Datadog::Statsd.new(host, port)
9
+ end
10
+
11
+ def report
12
+ tags = {
13
+ nodeName: node.name
14
+ }
15
+
16
+ @statsd.count('chef-client.total_runs', 1, tags: tags)
17
+ @statsd.timing('chef-client.run_time', run_status.elapsed_time * 1000, tags: tags)
18
+ @statsd.count('chef-client.total_resources', run_status.all_resources.length, tags: tags)
19
+ @statsd.count('chef-client.updated_resources', run_status.updated_resources.length, tags: tags)
20
+
21
+ if run_status.failed?
22
+ @statsd.count('chef-client.failed_runs', tags: tags)
23
+ else
24
+ @statsd.count('chef-client.success_runs', tags: tags)
25
+ end
26
+ end
27
+ end
28
+
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-handler-statsd
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Craig Thayer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dogstatsd-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.5.0
27
+ description: Chef report handler to send metrics to statsd
28
+ email:
29
+ - cthayer@craigthayer.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE
37
+ - README.md
38
+ - Rakefile
39
+ - chef-handler-statsd.gemspec
40
+ - lib/chef-handler-statsd.rb
41
+ homepage: https://github.com/cthayer/chef-handler-statsd
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.0.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Chef report handler to send metrics to statsd
64
+ test_files: []