chef-handler-copperegg 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chef-handler-copperegg (0.0.8)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ chef-handler-copperegg!
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 CopperEgg Corporation.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Chef::Handler::Copperegg
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'chef-handler-copperegg'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install chef-handler-copperegg
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'chef-handler-copperegg'
5
+ s.version ='0.1.3'
6
+ s.default_executable = 'chef-handler-copperegg'
7
+
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["scott johnson"]
10
+ s.email = ["sjohnson@copperegg.com"]
11
+ s.description = %q{This Handler will report the metrics for a chef-client run to CopperEgg.}
12
+ s.summary = %q{Chef Handler for CopperEgg metrics}
13
+ s.license = 'MIT'
14
+
15
+ s.require_paths = ["lib"]
16
+ s.files = Dir["#{File.dirname(__FILE__)}/**/*"]
17
+ end
@@ -0,0 +1,64 @@
1
+ require 'rubygems'
2
+ require 'chef'
3
+ require 'chef/handler'
4
+
5
+ class Chef
6
+ class Handler
7
+ class Copperegg < Chef::Handler
8
+
9
+ def initialize(opts = {})
10
+ @opts = opts
11
+ @apikey = opts['apikey']
12
+ @annotate_success = opts['annotate_success']
13
+ @annotate_fail = opts['annotate_fail']
14
+ @tags = opts['tags']
15
+ @hostname = opts['hostname']
16
+ @cuegg = CopperEgg::API.new(@apikey,'handler')
17
+ end
18
+
19
+ def report
20
+
21
+ elapsed = run_status.elapsed_time.to_i
22
+ if elapsed < 60 # force duration to be >= 1 min for annotations to display
23
+ annot_endtime = run_status.start_time.to_i + 60
24
+ else
25
+ annot_endtime = run_statusend_time.to_i
26
+ end
27
+ elapsed_str = elapsed.to_s + (elapsed <= 1 ? 'second' : 'seconds')
28
+
29
+ if run_status.success? && @annotate_success
30
+ Chef::Log.info("CopperEgg Chef Handler: Chef Run Successful, host: #{@hostname}")
31
+ note = "Chef Run Completed in #{elapsed_str} on #{@hostname}. Updated #{run_status.updated_resources.length} of #{run_status.all_resources.length} Resources. Tags are #{@tags}"
32
+ label = 'green'
33
+
34
+ elsif run_status.failed? && @annotate_fail
35
+ Chef::Log.info("CopperEgg Chef Handler: Chef Run Failed, host: #{@hostname}")
36
+ note = "Chef Run FAILED in #{elapsed_str} on #{@hostname}; #{run_status.formatted_exception}. Tags are #{@tags}"
37
+ label = 'red'
38
+
39
+ else
40
+ Chef::Log.debug("CopperEgg Chef Handler: Unknown")
41
+ return
42
+ end
43
+
44
+ params = {'note' => note,
45
+ 'starttime' => run_status.start_time.to_i,
46
+ 'endtime' => annot_endtime,
47
+ 'label' => label,
48
+ 'tags' => @tags }
49
+ @cuegg.create_annotation(@hostname, params)
50
+
51
+ end
52
+
53
+ end #end class Copperegg
54
+ end #end class Handler
55
+ end #end class Chef
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-handler-copperegg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - scott johnson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-23 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: This Handler will report the metrics for a chef-client run to CopperEgg.
15
+ email:
16
+ - sjohnson@copperegg.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ./Gemfile
22
+ - ./Gemfile.lock
23
+ - ./LICENSE.txt
24
+ - ./README.md
25
+ - ./chef-handler-copperegg.gemspec
26
+ - ./lib/chef/handler/copperegg.rb
27
+ homepage:
28
+ licenses:
29
+ - MIT
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.8.24
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Chef Handler for CopperEgg metrics
52
+ test_files: []