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.



930
931
932
933
# File 'lib/inspec/resources/service.rb', line 930

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

Instance Attribute Details

#inspecObject (readonly)

Returns the value of attribute inspec.



929
930
931
# File 'lib/inspec/resources/service.rb', line 929

def inspec
  @inspec
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



929
930
931
# File 'lib/inspec/resources/service.rb', line 929

def service_name
  @service_name
end

Instance Method Details

#find_utility_or_error(utility_name) ⇒ Object



935
936
937
938
939
940
941
# File 'lib/inspec/resources/service.rb', line 935

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