Class: Inspec::Resources::MonitoringTool

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/resources/service.rb

Overview

Helper class for monitored_by matcher

Direct Known Subclasses

God, Monit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inspec, service_name) ⇒ MonitoringTool

Returns a new instance of MonitoringTool.



926
927
928
929
# File 'lib/inspec/resources/service.rb', line 926

def initialize(inspec, service_name)
  @inspec = inspec
  @service_name ||= service_name
end

Instance Attribute Details

#inspecObject (readonly)

Returns the value of attribute inspec.



925
926
927
# File 'lib/inspec/resources/service.rb', line 925

def inspec
  @inspec
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



925
926
927
# File 'lib/inspec/resources/service.rb', line 925

def service_name
  @service_name
end

Instance Method Details

#find_utility_or_error(utility_name) ⇒ Object



931
932
933
934
935
936
937
# File 'lib/inspec/resources/service.rb', line 931

def find_utility_or_error(utility_name)
  [ "/usr/sbin/#{utility_name}" , "/sbin/#{utility_name}" , "/usr/bin/#{utility_name}" , "/bin/#{utility_name}" , "#{utility_name}" ].each do |cmd|
    return cmd if inspec.command(cmd).exist?
  end

  raise Inspec::Exceptions::ResourceFailed, "Could not find `#{utility_name}`"
end