chef-handler-profiler 0.0.1
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.
- data/LICENSE +20 -0
- data/README.md +62 -0
- data/lib/chef/handler/chef_profiler.rb +51 -0
- metadata +77 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Joe Miller
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
|
4
|
+
This is a Chef report handler that reports the execution time spent in each:
|
5
|
+
cookbook, recipe, and resource.
|
6
|
+
|
7
|
+
* http://wiki.opscode.com/display/chef/Exception+and+Report+Handlers
|
8
|
+
|
9
|
+
Requirements
|
10
|
+
============
|
11
|
+
|
12
|
+
Only works on Chef >= 10.14
|
13
|
+
|
14
|
+
Usage
|
15
|
+
=====
|
16
|
+
|
17
|
+
There are two ways to use Chef Handlers.
|
18
|
+
|
19
|
+
### Method 1 (recommended)
|
20
|
+
|
21
|
+
Use the
|
22
|
+
[chef_handler cookbook by Opscode](http://community.opscode.com/cookbooks/chef_handler).
|
23
|
+
Create a recipe with the following:
|
24
|
+
|
25
|
+
# Install `chef-handler-profiler` gem during the compile phase
|
26
|
+
chef_gem "chef-handler-profiler"
|
27
|
+
|
28
|
+
# Activate the handler immediately during compile phase
|
29
|
+
chef_handler "Chef::Handler::Profiler" do
|
30
|
+
source "chef/handler/profiler"
|
31
|
+
action :nothing
|
32
|
+
end.run_action(:enable)
|
33
|
+
|
34
|
+
|
35
|
+
### Method 2
|
36
|
+
|
37
|
+
Install the gem ahead of time, and configure Chef to use
|
38
|
+
them:
|
39
|
+
|
40
|
+
gem install chef-handler-profiler
|
41
|
+
|
42
|
+
Then add to the configuration (`/etc/chef/solo.rb` for chef-solo or
|
43
|
+
`/etc/chef/client.rb` for chef-client):
|
44
|
+
|
45
|
+
require "chef/handler/profiler"
|
46
|
+
report_handlers << Chef::Handler::Profiler.new
|
47
|
+
exception_handlers << Chef::Handler::Profiler.new
|
48
|
+
|
49
|
+
|
50
|
+
Todo
|
51
|
+
====
|
52
|
+
|
53
|
+
- Might be nice to dump output to JSON
|
54
|
+
- Different output, such as having resources grouped under their recipes,
|
55
|
+
and recipes grouped under cookbooks.
|
56
|
+
|
57
|
+
License and Author
|
58
|
+
==================
|
59
|
+
|
60
|
+
Licensed under the MIT license. See `LICENSE` file for details.
|
61
|
+
|
62
|
+
Author:: Joe Miller <https://github.com/joemiller>, <https://twitter.com/miller_joe>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Chef (simple) Profiler for reporting cookbook execution times
|
2
|
+
#
|
3
|
+
# Author:: Joe Miller <https://github.com/joemiller>
|
4
|
+
# Copyright:: Copyright 2012 Joe Miller
|
5
|
+
# License:: MIT License
|
6
|
+
#
|
7
|
+
|
8
|
+
|
9
|
+
class Chef
|
10
|
+
class Handler
|
11
|
+
class Profiler < Chef::Handler
|
12
|
+
VERSION = '0.0.1'
|
13
|
+
|
14
|
+
def report
|
15
|
+
cookbooks = Hash.new(0)
|
16
|
+
recipes = Hash.new(0)
|
17
|
+
resources = Hash.new(0)
|
18
|
+
|
19
|
+
# collect all profiled timings and group by type
|
20
|
+
all_resources.each do |r|
|
21
|
+
cookbooks[r.cookbook_name] += r.elapsed_time
|
22
|
+
recipes["#{r.cookbook_name}::#{r.recipe_name}"] += r.elapsed_time
|
23
|
+
resources["#{r.resource_name}[#{r.name}]"] = r.elapsed_time
|
24
|
+
end
|
25
|
+
|
26
|
+
# print each timing by group, sorting with highest elapsed time first
|
27
|
+
Chef::Log.debug "Elapsed_time Cookbook"
|
28
|
+
Chef::Log.debug "------------ -------------"
|
29
|
+
cookbooks.sort_by{ |k,v| -v }.each do |cookbook, run_time|
|
30
|
+
Chef::Log.debug "%12f %s" % [run_time, cookbook]
|
31
|
+
end
|
32
|
+
Chef::Log.debug ""
|
33
|
+
|
34
|
+
Chef::Log.debug "Elapsed_time Recipe"
|
35
|
+
Chef::Log.debug "------------ -------------"
|
36
|
+
recipes.sort_by{ |k,v| -v }.each do |recipe, run_time|
|
37
|
+
Chef::Log.debug "%12f %s" % [run_time, recipe]
|
38
|
+
end
|
39
|
+
Chef::Log.debug ""
|
40
|
+
|
41
|
+
Chef::Log.debug "Elapsed_time Resource"
|
42
|
+
Chef::Log.debug "------------ -------------"
|
43
|
+
resources.sort_by{ |k,v| -v }.each do |resource, run_time|
|
44
|
+
Chef::Log.debug "%12f %s" % [run_time, resource]
|
45
|
+
end
|
46
|
+
Chef::Log.debug ""
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chef-handler-profiler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Joe Miller
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-09-17 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: chef
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 10
|
29
|
+
- 14
|
30
|
+
version: "10.14"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
description: Report on the run time of cookbooks, recipes, and resources
|
34
|
+
email:
|
35
|
+
- joeym@joeym.net
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- LICENSE
|
44
|
+
- README.md
|
45
|
+
- lib/chef/handler/chef_profiler.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: https://github.com/joemiller/chef-handler-profiler
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.3.6
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Chef Profiler Handler
|
76
|
+
test_files: []
|
77
|
+
|