profiling-chef-handler 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +136 -0
- data/lib/chef/handler/chef_profiler.rb +51 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: acf7e7fd6263accce99a3b6c202b0c9555884554
|
4
|
+
data.tar.gz: e7a5d229dd85026e47174ac9d5327a5cd9f17b92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 424e579147ce963002bdbf9c30ae45a78ed6276d5da3b5685c915ef7f6e41238edd026d334caf8b865242d8e0a39781d4cc5d94530adf65352028bd36409a7cd
|
7
|
+
data.tar.gz: 289e8faa414e9494ee8ecd17028d06a1813ea09cd79a064dd73647c8e3fa8264f1247ac191a34a3ea762119a084e352f7253a09c892a666dc7671ffe6c6bdfd1
|
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,136 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
|
4
|
+
Pirated yet another Chef community gem. This one was formerly called chef-handler-profiler - felt that
|
5
|
+
profiling-chef-handler was a better name and the old version required that debug logging mode had to be enabled for
|
6
|
+
profiling output to be displayed. My goal was to allow the profiling data to be available by enabling the gem.
|
7
|
+
|
8
|
+
This is a Chef report handler that reports the execution time spent in each:
|
9
|
+
cookbook, recipe, and resource.
|
10
|
+
|
11
|
+
* http://wiki.opscode.com/display/chef/Exception+and+Report+Handlers
|
12
|
+
|
13
|
+
Requirements
|
14
|
+
============
|
15
|
+
|
16
|
+
Only works on Chef >= 10.14
|
17
|
+
|
18
|
+
Usage
|
19
|
+
=====
|
20
|
+
|
21
|
+
There are two ways to use Chef Handlers.
|
22
|
+
|
23
|
+
### Method 1 (recommended)
|
24
|
+
|
25
|
+
Use the
|
26
|
+
[chef_handler cookbook by Opscode](http://supermarket.getchef.com/cookbooks/chef_handler).
|
27
|
+
Create a recipe with the following:
|
28
|
+
|
29
|
+
include_recipe "chef_handler"
|
30
|
+
|
31
|
+
# Install `profiling-chef-handler` gem during the compile phase
|
32
|
+
chef_gem "profiling-chef-handler"
|
33
|
+
|
34
|
+
# load the gem here so it gets added to the $LOAD_PATH, otherwise chef_handler
|
35
|
+
# will fail.
|
36
|
+
require 'chef/handler/chef_profiler'
|
37
|
+
|
38
|
+
# Activate the handler immediately during compile phase
|
39
|
+
chef_handler "Chef::Handler::Profiler" do
|
40
|
+
source "chef/handler/chef_profiler"
|
41
|
+
action :nothing
|
42
|
+
end.run_action(:enable)
|
43
|
+
|
44
|
+
|
45
|
+
### Method 2
|
46
|
+
|
47
|
+
Install the gem ahead of time, and configure Chef to use
|
48
|
+
them:
|
49
|
+
|
50
|
+
gem install profiling-chef-handler
|
51
|
+
|
52
|
+
Then add to the configuration (`/etc/chef/solo.rb` for chef-solo or
|
53
|
+
`/etc/chef/client.rb` for chef-client):
|
54
|
+
|
55
|
+
require "chef/handler/chef_profiler"
|
56
|
+
report_handlers << Chef::Handler::Profiler.new
|
57
|
+
exception_handlers << Chef::Handler::Profiler.new
|
58
|
+
|
59
|
+
|
60
|
+
### Example output
|
61
|
+
|
62
|
+
Run chef to see profiler output, example:
|
63
|
+
|
64
|
+
$ chef-solo -j config.json
|
65
|
+
...
|
66
|
+
[2012-09-18T17:40:31+00:00] INFO: Running report handlers
|
67
|
+
[2012-09-18T17:40:31+00:00] INFO: Resources updated this run:
|
68
|
+
[2012-09-18T17:40:31+00:00] INFO: chef_handler[Chef::Handler::Profiler]
|
69
|
+
[2012-09-18T17:40:31+00:00] INFO: Elapsed_time Cookbook
|
70
|
+
[2012-09-18T17:40:31+00:00] INFO: ------------ -------------
|
71
|
+
[2012-09-18T17:40:31+00:00] INFO: 16.040867 python
|
72
|
+
[2012-09-18T17:40:31+00:00] INFO: 7.831706 nano
|
73
|
+
[2012-09-18T17:40:31+00:00] INFO: 3.233159 base
|
74
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.699011 generic-users
|
75
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.665569 chef
|
76
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.176383 postfix
|
77
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.174411 ntp
|
78
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.001780 chef_handler
|
79
|
+
[2012-09-18T17:40:31+00:00] INFO:
|
80
|
+
[2012-09-18T17:40:31+00:00] INFO: Elapsed_time Recipe
|
81
|
+
[2012-09-18T17:40:31+00:00] INFO: ------------ -------------
|
82
|
+
[2012-09-18T17:40:31+00:00] INFO: 16.040867 python::default
|
83
|
+
[2012-09-18T17:40:31+00:00] INFO: 7.831706 nano::default
|
84
|
+
[2012-09-18T17:40:31+00:00] INFO: 1.414983 base::pki
|
85
|
+
[2012-09-18T17:40:31+00:00] INFO: 1.228345 base::utilities
|
86
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.699011 generic-users::default
|
87
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.660846 chef::omnibus
|
88
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.374277 base::default
|
89
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.176383 postfix::default
|
90
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.174411 ntp::default
|
91
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.103661 base::dracut
|
92
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.085744 base::users
|
93
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.010829 base::sshd_allow
|
94
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.005859 base::kernel
|
95
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.005025 base::sudoers
|
96
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.004723 chef::profiler_handler
|
97
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.004437 base::prelink
|
98
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.001780 chef_handler::default
|
99
|
+
[2012-09-18T17:40:31+00:00] INFO:
|
100
|
+
[2012-09-18T17:40:31+00:00] INFO: Elapsed_time Resource
|
101
|
+
[2012-09-18T17:40:31+00:00] INFO: ------------ -------------
|
102
|
+
[2012-09-18T17:40:31+00:00] INFO: 7.755572 package[nano]
|
103
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.549213 remote_file[/usr/local/bin/prlimit]
|
104
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.483825 chef_gem[gelf]
|
105
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.433518 execute[remove_pip_pynotify]
|
106
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.391915 execute[install_clint==0.3.1]
|
107
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.391519 execute[install_Genshi==0.6]
|
108
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.389266 execute[install_Jinja2==2.6]
|
109
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.385632 execute[install_zope.interface==3.8.0]
|
110
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.384590 execute[install_gitdb==0.5.4]
|
111
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.384320 execute[install_pycurl==7.19.0]
|
112
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.382389 gem_package[teamocil]
|
113
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.382325 execute[install_python-dateutil==1.5]
|
114
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.381351 execute[install_PyMySQL==0.5]
|
115
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.380537 execute[install_iso8601==0.1.4]
|
116
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.380504 execute[install_pycassa==1.4.0]
|
117
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.379317 execute[install_argparse==1.2.1]
|
118
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.379029 execute[install_amqplib==1.0.2]
|
119
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.378980 execute[install_pbs==0.108]
|
120
|
+
[2012-09-18T17:40:31+00:00] INFO: 0.378710 execute[install_apache-libcloud==
|
121
|
+
...
|
122
|
+
|
123
|
+
Todo
|
124
|
+
====
|
125
|
+
|
126
|
+
- Might be nice to dump output to JSON files.
|
127
|
+
- Different output, such as having resources grouped under their recipes,
|
128
|
+
and recipes grouped under cookbooks.
|
129
|
+
|
130
|
+
License and Author
|
131
|
+
==================
|
132
|
+
|
133
|
+
Licensed under the MIT license. See `LICENSE` file for details.
|
134
|
+
|
135
|
+
Author:: Joe Miller <https://github.com/joemiller>, <https://twitter.com/miller_joe>
|
136
|
+
2nd Author:: Andy Glick <https://github.com/andyglick>, <andyglick@gmail.com>
|
@@ -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.3'
|
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.info "Elapsed_time Cookbook"
|
28
|
+
Chef::Log.info "------------ -------------"
|
29
|
+
cookbooks.sort_by{ |k,v| -v }.each do |cookbook, run_time|
|
30
|
+
Chef::Log.info "%12f %s" % [run_time, cookbook]
|
31
|
+
end
|
32
|
+
Chef::Log.info ""
|
33
|
+
|
34
|
+
Chef::Log.info "Elapsed_time Recipe"
|
35
|
+
Chef::Log.info "------------ -------------"
|
36
|
+
recipes.sort_by{ |k,v| -v }.each do |recipe, run_time|
|
37
|
+
Chef::Log.info "%12f %s" % [run_time, recipe]
|
38
|
+
end
|
39
|
+
Chef::Log.info ""
|
40
|
+
|
41
|
+
Chef::Log.info "Elapsed_time Resource"
|
42
|
+
Chef::Log.info "------------ -------------"
|
43
|
+
resources.sort_by{ |k,v| -v }.each do |resource, run_time|
|
44
|
+
Chef::Log.info "%12f %s" % [run_time, resource]
|
45
|
+
end
|
46
|
+
Chef::Log.info ""
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: profiling-chef-handler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe Miller
|
8
|
+
- Andy Glick
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: chef
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '10.14'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '10.14'
|
28
|
+
description: Report on the run time of cookbooks, recipes, and resources
|
29
|
+
email:
|
30
|
+
- andyglick@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- lib/chef/handler/chef_profiler.rb
|
38
|
+
homepage: https://github.com/andyglick/profiling-chef-handler
|
39
|
+
licenses: []
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.2.1
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Chef Profiler Handler
|
61
|
+
test_files: []
|