chef-handler-librato 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/README.md +11 -0
- data/Rakefile +1 -0
- data/chef-handler-librato.gemspec +23 -0
- data/lib/chef/chef_handler_librato.rb +68 -0
- metadata +102 -0
data/.gitignore
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "chef-handler-librato"
|
6
|
+
s.version = "1.0.0"
|
7
|
+
s.authors = ["Brian Scott"]
|
8
|
+
s.email = ["brainscott@gmail.com"]
|
9
|
+
s.homepage = ""
|
10
|
+
s.summary = %q{Push reporting stats to Librato metrics}
|
11
|
+
s.description = %q{Push reporting stats to Librato metrics}
|
12
|
+
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# specify any dependencies here; for example:
|
20
|
+
s.add_development_dependency "librato-metrics"
|
21
|
+
s.add_runtime_dependency "librato-metrics"
|
22
|
+
s.add_runtime_dependency "chef"
|
23
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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
|
+
|
20
|
+
require "rubygems"
|
21
|
+
Gem.clear_paths
|
22
|
+
require "librato/metrics"
|
23
|
+
require "chef"
|
24
|
+
require "chef/handler"
|
25
|
+
|
26
|
+
class LibratoReporting < Chef::Handler
|
27
|
+
attr_writer :metrics_type, :source, :email, :api_key
|
28
|
+
|
29
|
+
def initialize(options = {})
|
30
|
+
@metric_type = options[:metric_type] || "counter"
|
31
|
+
@source = options[:source] || "#{Chef::Config[:node_name]}"
|
32
|
+
@email = options[:email]
|
33
|
+
@api_key = options[:api_key]
|
34
|
+
end
|
35
|
+
|
36
|
+
def report
|
37
|
+
gemspec = if Gem::Specification.respond_to? :find_by_name
|
38
|
+
Gem::Specification.find_by_name('chef-handler-librato')
|
39
|
+
else
|
40
|
+
Gem.source_index.find_name('chef-handler-librato').last
|
41
|
+
end
|
42
|
+
|
43
|
+
Chef::Log.debug("#{gemspec.full_name} loaded as a handler.")
|
44
|
+
|
45
|
+
@l = Librato::Metrics.new
|
46
|
+
@l.authenticate "#{@email}" "#{@api_key}"
|
47
|
+
|
48
|
+
metrics = Hash.new
|
49
|
+
metrics[:updated_resources] = run_status.updated_resources.length
|
50
|
+
metrics[:all_resources] = run_status.all_resources.length
|
51
|
+
metrics[:elapsed_time] = run_status.elapsed_time
|
52
|
+
|
53
|
+
if run_status.success?
|
54
|
+
metrics[:success] = 1
|
55
|
+
metrics[:fail] = 0
|
56
|
+
else
|
57
|
+
metrics[:success] = 0
|
58
|
+
metrics[:fail] = 1
|
59
|
+
end
|
60
|
+
|
61
|
+
metrics.length.each do |librato|
|
62
|
+
metrics.each do |metric, value|
|
63
|
+
Chef::Log.debug("#{metric} #{value} #{l.time_now}")
|
64
|
+
@l.submit :"#{metric}" => {:type => :"#{@metric_type}", :value => "#{value}", :source => "#{@source}" }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chef-handler-librato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Brian Scott
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-06-22 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: librato-metrics
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: librato-metrics
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: chef
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
56
|
+
description: Push reporting stats to Librato metrics
|
57
|
+
email:
|
58
|
+
- brainscott@gmail.com
|
59
|
+
executables: []
|
60
|
+
|
61
|
+
extensions: []
|
62
|
+
|
63
|
+
extra_rdoc_files: []
|
64
|
+
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- chef-handler-librato.gemspec
|
70
|
+
- lib/chef/chef_handler_librato.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: ""
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.3.6
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Push reporting stats to Librato metrics
|
101
|
+
test_files: []
|
102
|
+
|