Sha256: 5f8773df7185a3c283ebde08d902dd7923d4b6f61c56228b4157f499ec0921f1

Contents?: true

Size: 602 Bytes

Versions: 6

Compression:

Stored size: 602 Bytes

Contents

Ohai.plugin(:Pci) do
  provides 'dpci'

  def from_cmd(cmd)
    so = shell_out(cmd)
    so.stdout.lines
  end

  collect_data(:default) do
    dpci Mash.new
    pcis from_cmd('lspci')

    r_bus_slot_num = /\d+:[0-9a-fA-F]+\.\d\s/
    r_slot_name = /^[A-z\s]+/

    pcis.each_with_index do |pci, i|
      bus_slot_num = pci.slice! r_bus_slot_num
      slot_name = pci.slice! r_slot_name
      pci.slice! /^:\s/
      device_name = pci

      dpci["pci_#{i}"] = {
        "bus_slot_num" =>  bus_slot_num,
        "slot_name" => slot_name,
        "device_name" => device_name
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cupper-0.2.1 lib/cupper/plugins/ohai/dpci.rb
cupper-0.2.0 lib/cupper/plugins/ohai/dpci.rb
cupper-0.1.3 lib/cupper/plugins/ohai/dpci.rb
cupper-0.1.2 lib/cupper/plugins/ohai/dpci.rb
cupper-0.1.1 lib/cupper/plugins/ohai/dpci.rb
cupper-0.1.0 lib/cupper/plugins/ohai/dpci.rb