module Ohai::Mixin::ShellOut

Public Instance Methods

shell_out(cmd, **options) click to toggle source
Calls superclass method
# File lib/ohai/mixin/shell_out.rb, line 33
def shell_out(cmd, **options)
  options = options.dup
  # unless specified by the caller timeout after configured timeout (default 30 seconds)
  options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
  begin
    so = super(cmd, **options)
    logger.trace("Plugin #{name}: ran '#{cmd}' and returned #{so.exitstatus}")
    so
  rescue Errno::ENOENT => e
    logger.trace("Plugin #{name}: ran '#{cmd}' and failed #{e.inspect}")
    raise Ohai::Exceptions::Exec, e
  rescue Mixlib::ShellOut::CommandTimeout => e
    logger.trace("Plugin #{name}: ran '#{cmd}' and timed out after #{options[:timeout]} seconds")
    raise Ohai::Exceptions::Exec, e
  end
end