class Inspec::Resources::System

this resource returns additional system informatio

def hostname(opt = nil)

returns the hostname of the local system
def hostname(opt = nil)
  os = inspec.os
  if os.linux?
    linux_hostname(opt)
  elsif os.darwin?
    mac_hostname(opt)
  elsif os.windows?
    if !opt.nil?
      skip_resource "The `sys_info.hostname` resource is not supported with that option on your OS."
    else
      inspec.powershell("$env:computername").stdout.chomp
    end
  else
    skip_resource "The `sys_info.hostname` resource is not supported on your OS yet."
  end
end

def linux_hostname(opt = nil)

def linux_hostname(opt = nil)
  if opt
    opt = case opt
          when "f", "long", "fqdn", "full"
            " -f"
          when "d", "domain"
            " -d"
          when "i", "ip_address"
            " -I"
          when "s", "short"
            " -s"
          else
            "ERROR"
          end
  end
  if opt == "ERROR"
    skip_resource "The `sys_info.hostname` resource is not supported with that option on your OS."
  else
    inspec.command("hostname#{opt}").stdout.chomp
  end
end

def mac_hostname(opt = nil)

def mac_hostname(opt = nil)
  if opt
    opt = case opt
          when "f", "long", "fqdn", "full"
            " -f"
          when "s", "short"
            " -s"
          else
            "ERROR"
          end
  end
  if opt == "ERROR"
    skip_resource "The `sys_info.hostname` resource is not supported with that option on your OS."
  else
    inspec.command("hostname#{opt}").stdout.chomp
  end
end

def manufacturer

returns the Manufacturer of the local system
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

def model

returns the ServerModel of the local system
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

def resource_id

def resource_id
  "sys_info"
end

def to_s

def to_s
  "System Information"
end