Class: Inspec::Resources::KernelParameter
- Inherits:
-
Object
- Object
- Inspec::Resources::KernelParameter
- Defined in:
- lib/inspec/resources/kernel_parameter.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(parameter = nil) ⇒ KernelParameter
constructor
A new instance of KernelParameter.
- #resource_id ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(parameter = nil) ⇒ KernelParameter
Returns a new instance of KernelParameter.
14 15 16 17 18 19 |
# File 'lib/inspec/resources/kernel_parameter.rb', line 14 def initialize(parameter = nil) @parameter = parameter # this resource is only supported on Linux return skip_resource "The `kernel_parameter` resource is not supported on your OS." unless inspec.os.linux? end |
Instance Method Details
#resource_id ⇒ Object
32 33 34 |
# File 'lib/inspec/resources/kernel_parameter.rb', line 32 def resource_id @parameter || "Kernel Parameter" end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/inspec/resources/kernel_parameter.rb', line 36 def to_s "Kernel Parameter #{@parameter}" end |
#value ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/inspec/resources/kernel_parameter.rb', line 21 def value cmd = inspec.command("/sbin/sysctl -q -n #{@parameter}") return nil if cmd.exit_status != 0 # remove whitespace cmd = cmd.stdout.chomp.strip # convert to number if possible cmd = cmd.to_i if cmd =~ /^\d+$/ cmd end |