Skip to content

Instantly share code, notes, and snippets.

@nstielau
Created October 28, 2011 21:22
Show Gist options
  • Save nstielau/1323597 to your computer and use it in GitHub Desktop.
Save nstielau/1323597 to your computer and use it in GitHub Desktop.
Check the load times of Ohai plugins
#!/usr/bin/env ruby
# Check on the load times for Ohai plugins.
# To disable from chef-solo and chef-client runs see
# http://wiki.opscode.com/display/chef/Disabling+Ohai+Plugins
require 'benchmark'
require 'rubygems'
require 'ohai'
ohai = Ohai::System.new()
ohai.require_plugin('os')
Ohai::Config[:plugin_path].each do |path|
[
Dir[File.join(path, '*')],
Dir[File.join(path, ohai.data['os'], '**', '*')]
].flatten.each do |file|
file_regex = Regexp.new("#{path}#{File::SEPARATOR}(.+).rb$")
md = file_regex.match(file)
if md
plugin_name = md[1].gsub(File::SEPARATOR, "::")
dur = Benchmark.realtime do
ohai.require_plugin(plugin_name) unless ohai.seen_plugins.has_key?(plugin_name)
end
puts "Loaded #{plugin_name} in #{(dur*1000).to_i / 1000.0} seconds"
end
end
end
@artemyarulin
Copy link

Hello!

Any chances to get this script updated for Ohai 7? Because right now Windows is already using ohai 7 and it is not possible to run the following script to benchmark plugin load time.

BTW: https://wiki.opscode.com/display/chef/Disabling+Ohai+Plugins should be changed as well, because ohai 7 has a different syntax for disabling plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment