Class: Inspec::Resources::System
- Inherits:
-
Object
- Object
- Inspec::Resources::System
- Defined in:
- lib/inspec/resources/sys_info.rb
Overview
this resource returns additional system informatio
Instance Method Summary collapse
-
#hostname ⇒ Object
returns the hostname of the local system.
-
#manufacturer ⇒ Object
returns the Manufacturer of the local system.
-
#model ⇒ Object
returns the ServerModel of the local system.
Instance Method Details
#hostname ⇒ Object
returns the hostname of the local system
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/inspec/resources/sys_info.rb', line 19 def hostname os = inspec.os if os.linux? || os.darwin? inspec.command("hostname").stdout.chomp elsif os.windows? inspec.powershell("$env:computername").stdout.chomp else skip_resource "The `sys_info.hostname` resource is not supported on your OS yet." end end |
#manufacturer ⇒ Object
returns the Manufacturer of the local system
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/inspec/resources/sys_info.rb', line 31 def manufacturer os = inspec.os if os.darwin? "Apple Inc." elsif os.linux? inspec.command("cat /sys/class/dmi/id/sys_vendor").stdout.chomp elsif os.windows? inspec.powershell("Get-CimInstance -ClassName Win32_ComputerSystem | Select Manufacturer -ExpandProperty Manufacturer").stdout.chomp else skip_resource "The `sys_info.manufacturer` resource is not supported on your OS yet." end end |
#model ⇒ Object
returns the ServerModel of the local system
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/inspec/resources/sys_info.rb', line 45 def model os = inspec.os if os.darwin? inspec.command("sysctl -n hw.model").stdout.chomp elsif os.linux? inspec.command("cat /sys/class/dmi/id/product_name").stdout.chomp elsif os.windows? inspec.powershell("Get-CimInstance -ClassName Win32_ComputerSystem | Select Model -ExpandProperty Model").stdout.chomp else skip_resource "The `sys_info.model` resource is not supported on your OS yet." end end |