chef-metrics 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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-metrics.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sean Porter Consulting
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,19 @@
1
+ # ChefMetrics
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ TODO: Write installation instructions here
8
+
9
+ ## Usage
10
+
11
+ TODO: Write usage instructions here
12
+
13
+ ## Contributing
14
+
15
+ 1. Fork it
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
17
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
18
+ 4. Push to the branch (`git push origin my-new-feature`)
19
+ 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,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Sean Porter"]
5
+ gem.email = ["portertech@gmail.com"]
6
+ gem.description = "OpsCode Chef report handler to send metrics to x"
7
+ gem.summary = "OpsCode Chef report handler to send metrics to x"
8
+ gem.homepage = "https://github.com/portertech/chef-metrics"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.name = "chef-metrics"
12
+ gem.require_paths = ["lib"]
13
+ gem.version = "0.0.1"
14
+ end
@@ -0,0 +1,39 @@
1
+ require "rubygems"
2
+ require "chef/handler"
3
+
4
+ class ChefMetrics < Chef::Handler
5
+ attr_accessor :action, :metric_scheme, :measure_time, :metrics
6
+
7
+ def initialize(&action)
8
+ @action = action
9
+ @metric_scheme = "chef"
10
+ @measure_time = Time.now.to_i
11
+ @metrics = Hash.new
12
+ end
13
+
14
+ def graphite_formatted
15
+ @metrics.inject("") do |result, (metric, value)|
16
+ result << "#{@metric_scheme}.#{metric} #{value} #{@measure_time}\n"
17
+ result
18
+ end
19
+ end
20
+
21
+ def report
22
+ @measure_time = Time.now.to_i
23
+ @metrics[:updated_resources] = run_status.updated_resources.length
24
+ @metrics[:all_resources] = run_status.all_resources.length
25
+ @metrics[:elapsed_time] = run_status.elapsed_time
26
+ if run_status.success?
27
+ @metrics[:success] = 1
28
+ @metrics[:fail] = 0
29
+ else
30
+ @metrics[:success] = 0
31
+ @metrics[:fail] = 1
32
+ end
33
+ if @action
34
+ @action.call
35
+ else
36
+ Chef::Log.info("Chef Metrics report handler was not provided an action")
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-metrics
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sean Porter
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-06-11 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: OpsCode Chef report handler to send metrics to x
23
+ email:
24
+ - portertech@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - chef-metrics.gemspec
38
+ - lib/chef-metrics.rb
39
+ has_rdoc: true
40
+ homepage: https://github.com/portertech/chef-metrics
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: OpsCode Chef report handler to send metrics to x
73
+ test_files: []
74
+