chef-handler-graphite 1.0.0

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
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # HEY!!!!
2
+
3
+ Please see the [wiki](https://github.com/imeyer/chef-handler-graphite/wiki) for instructions on how to use.
4
+
5
+ Patches welcome, just send me a pull request!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "chef-handler-graphite"
6
+ s.version = "1.0.0"
7
+ s.authors = ["Ian Meyer"]
8
+ s.email = ["ianmmeyer@gmail.com"]
9
+ s.homepage = ""
10
+ s.summary = %q{Push reporting stats to Graphite}
11
+ s.description = %q{Push reporting stats to Graphite}
12
+
13
+ s.rubyforge_project = "chef-handler-graphite"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # specify any dependencies here; for example:
21
+ s.add_development_dependency "simple-graphite"
22
+ s.add_runtime_dependency "simple-graphite"
23
+ s.add_runtime_dependency "chef"
24
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # Author:: Ian Meyer <ianmmeyer@gmail.com>
3
+ # Copyright:: Copyright (c) 2012, Ian Meyer
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "rubygems"
20
+ Gem.clear_paths
21
+ require "simple-graphite"
22
+ require "chef"
23
+ require "chef/handler"
24
+
25
+ class GraphiteReporting < Chef::Handler
26
+ attr_writer :metric_key, :graphite_host, :graphite_port
27
+
28
+ def initialize(options = {})
29
+ @metric_key = options[:metric_key]
30
+ @graphite_host = options[:graphite_host]
31
+ @graphite_port = options[:graphite_port]
32
+ end
33
+
34
+ def report
35
+ Chef::Log.debug("#{Gem::Specification.find_by_name('chef-handler-graphite').full_name} loaded as a handler.")
36
+
37
+ g = Graphite.new
38
+ g.host = @graphite_host
39
+ g.port = @graphite_port
40
+
41
+ metrics = Hash.new
42
+ metrics[:updated_resources] = run_status.updated_resources.length
43
+ metrics[:all_resources] = run_status.all_resources.length
44
+ metrics[:elapsed_time] = run_status.elapsed_time
45
+
46
+ if run_status.success?
47
+ metrics[:success] = 1
48
+ metrics[:fail] = 0
49
+ else
50
+ metrics[:success] = 0
51
+ metrics[:fail] = 1
52
+ end
53
+
54
+ g.push_to_graphite do |graphite|
55
+ metrics.each do |metric, value|
56
+ Chef::Log.debug("#{@metric_key}.#{metric} #{value} #{g.time_now}")
57
+ graphite.puts "#{@metric_key}.#{metric} #{value} #{g.time_now}"
58
+ end
59
+ end
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-handler-graphite
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Ian Meyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-01-27 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: simple-graphite
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: simple-graphite
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: chef
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ description: Push reporting stats to Graphite
49
+ email:
50
+ - ianmmeyer@gmail.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - .gitignore
59
+ - README.md
60
+ - Rakefile
61
+ - chef-handler-graphite.gemspec
62
+ - lib/chef-handler-graphite.rb
63
+ homepage: ""
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ requirements: []
84
+
85
+ rubyforge_project: chef-handler-graphite
86
+ rubygems_version: 1.8.13
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Push reporting stats to Graphite
90
+ test_files: []
91
+