読者です 読者をやめる 読者になる 読者になる

ハードウェアの情報収集にlshwを使う

Linux CentOS TIPS

ハードウェアの情報集種コマンドとして「lshw」なるものがある事を知り、簡単に試してみました。


インストールはyum一発です。
ただし、EPELをリポジトリとして指定しておく必要があります。

 # yum install lshw


VirtualBox上のVMで実行してみた結果はこんな感じでした。

# lshw
[your hostname] 
    description: Computer
    product: VirtualBox
    vendor: innotek GmbH
    version: 1.2
    serial: 0
    width: 32 bits
    capabilities: smbios-2.5 dmi-2.5
    configuration: uuid=92AA0C0C-F619-43DF-A33E-F469BB57643F
  *-core
       description: Motherboard
       physical id: 0
     *-firmware
          description: BIOS
          vendor: innotek GmbH
          physical id: 0
          version: VirtualBox (12/01/2006)
          size: 128KiB
          capabilities: isa pci cdboot bootselect int9keyboard int10video acpi
     *-memory
          description: System memory
          physical id: 1
          size: 511MiB
     *-cpu
          product: Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
          vendor: Intel Corp.
          physical id: 2
          bus info: cpu@0
          version: 6.7.10
          serial: 0001-067A-0000-0000-0000-0000
          size: 18EHz
          width: 32 bits
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 nx constant_tsc up pni monitor ssse3
     *-pci
          description: Host bridge
          product: 440FX - 82441FX PMC [Natoma]
          vendor: Intel Corporation
          physical id: 100
          bus info: pci@0000:00:00.0
          version: 02
          width: 32 bits
          clock: 33MHz
        *-isa
             description: ISA bridge
             product: 82371SB PIIX3 ISA [Natoma/Triton II]
             vendor: Intel Corporation
             physical id: 1
             bus info: pci@0000:00:01.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: isa bus_master
             configuration: latency=0
        *-ide
             description: IDE interface
             product: 82371AB/EB/MB PIIX4 IDE
             vendor: Intel Corporation
             physical id: 1.1
             bus info: pci@0000:00:01.1
             version: 01
             width: 32 bits
             clock: 33MHz
             capabilities: ide bus_master
             configuration: driver=PIIX_IDE latency=0
           *-ide
                description: IDE Channel 1
                physical id: 1
                bus info: ide@1
                logical name: ide1
                clock: 33MHz
              *-cdrom
                   description: DVD reader
                   product: VBOX CD-ROM
                   physical id: 0
                   bus info: ide@1.0
                   logical name: /dev/hdc
                   version: 1.0
                   serial: VB2-01700376
                   capabilities: packet atapi cdrom removable nonmagnetic dma lba iordy audio dvd
                   configuration: mode=udma2 status=open
        *-display UNCLAIMED
             description: VGA compatible controller
             product: VirtualBox Graphics Adapter
             vendor: InnoTek Systemberatung GmbH
             physical id: 2
             bus info: pci@0000:00:02.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: vga_controller bus_master
             configuration: latency=0
        *-network
             description: Ethernet interface
             product: 82540EM Gigabit Ethernet Controller
             vendor: Intel Corporation
             physical id: 3
             bus info: pci@0000:00:03.0
             logical name: eth0
             version: 02
             serial: 08:00:27:2a:85:16
             size: 1GB/s
             capacity: 1GB/s
             width: 32 bits
             clock: 66MHz
             capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
             configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=7.3.21-k4.1-NAPI duplex=full firmware=N/A ip=192.168.11.60 latency=64 link=yes mingnt=255 module=e1000 multicast=yes port=twisted pair speed=1GB/s
        *-system UNCLAIMED
             description: System peripheral
             product: VirtualBox Guest Service
             vendor: InnoTek Systemberatung GmbH
             physical id: 4
             bus info: pci@0000:00:04.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: bus_master
             configuration: latency=0
        *-multimedia
             description: Multimedia audio controller
             product: 82801AA AC'97 Audio Controller
             vendor: Intel Corporation
             physical id: 5
             bus info: pci@0000:00:05.0
             version: 01
             width: 32 bits
             clock: 33MHz
             capabilities: bus_master
             configuration: driver=Intel ICH latency=64 module=snd_intel8x0
        *-usb:0
             description: USB Controller
             product: KeyLargo/Intrepid USB
             vendor: Apple Computer Inc.
             physical id: 6
             bus info: pci@0000:00:06.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: ohci bus_master
             configuration: driver=ohci_hcd latency=64 module=ohci_hcd
           *-usbhost
                product: OHCI Host Controller
                vendor: Linux 2.6.18-194.26.1.el5 ohci_hcd
                physical id: 1
                bus info: usb@2
                logical name: usb2
                version: 2.06
                capabilities: usb-1.10
                configuration: driver=hub maxpower=0mA slots=8 speed=12.0MB/s
        *-bridge UNCLAIMED
             description: Bridge
             product: 82371AB/EB/MB PIIX4 ACPI
             vendor: Intel Corporation
             physical id: 7
             bus info: pci@0000:00:07.0
             version: 08
             width: 32 bits
             clock: 33MHz
             capabilities: bridge bus_master
             configuration: latency=0
        *-usb:1
             description: USB Controller
             product: 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller
             vendor: Intel Corporation
             physical id: b
             bus info: pci@0000:00:0b.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: ehci bus_master
             configuration: driver=ehci_hcd latency=64 module=ehci_hcd
           *-usbhost
                product: EHCI Host Controller
                vendor: Linux 2.6.18-194.26.1.el5 ehci_hcd
                physical id: 1
                bus info: usb@1
                logical name: usb1
                version: 2.06
                capabilities: usb-2.00
                configuration: driver=hub maxpower=0mA slots=8 speed=480.0MB/s
        *-storage
             description: SATA controller
             product: 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
             vendor: Intel Corporation
             physical id: d
             bus info: pci@0000:00:0d.0
             logical name: scsi0
             version: 02
             width: 32 bits
             clock: 33MHz
             capabilities: storage msi pm ahci_1.0 bus_master emulated
             configuration: driver=ahci latency=64 module=ahci
           *-disk
                description: ATA Disk
                product: VBOX HARDDISK
                physical id: 0.0.0
                bus info: scsi@0:0.0.0
                logical name: /dev/sda
                version: 1.0
                serial: VBa801f774-640c70b1
                size: 20GiB (21GB)
                capabilities: partitioned partitioned:dos
                configuration: ansiversion=5 signature=0007065b
              *-volume:0
                   description: EXT3 volume
                   vendor: Linux
                   physical id: 1
                   bus info: scsi@0:0.0.0,1
                   logical name: /dev/sda1
                   logical name: /boot
                   version: 1.0
                   serial: 0d34e930-c815-4f35-bd42-cd63c006636e
                   size: 101MiB
                   capacity: 101MiB
                   capabilities: primary bootable journaled extended_attributes large_files huge_files recover ext3 ext2 initialized
                   configuration: created=2010-12-18 11:07:43 filesystem=ext3 label=/boot modified=2010-12-30 15:41:25 mount.fstype=ext3 mount.options=rw,data=ordered mounted=2010-12-30 10:45:28 state=mounted
              *-volume:1
                   description: Linux LVM Physical Volume partition
                   physical id: 2
                   bus info: scsi@0:0.0.0,2
                   logical name: /dev/sda2
                   serial: eulDiA-qZ94-0FAH-pouK-0BUz-d0pn-4qel0W
                   size: 19GiB
                   capacity: 19GiB
                   capabilities: primary multi lvm2


「-short」オプション付けると、もう少しシンプルな表示になります。

# lshw -short
H/W path          Device     Class       Description
====================================================
                             system      VirtualBox
/0                           bus         Motherboard
/0/0                         memory      128KiB BIOS
/0/1                         memory      511MiB System memory
/0/2                         processor   Intel(R) Core(TM)2 Duo CPU     P8600  @
/0/100                       bridge      440FX - 82441FX PMC [Natoma]
/0/100/1                     bridge      82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1.1                   storage     82371AB/EB/MB PIIX4 IDE
/0/100/1.1/1      ide1       bus         IDE Channel 1
/0/100/1.1/1/0    /dev/hdc   disk        VBOX CD-ROM
/0/100/2                     display     VirtualBox Graphics Adapter
/0/100/3          eth0       network     82540EM Gigabit Ethernet Controller
/0/100/4                     system      VirtualBox Guest Service
/0/100/5                     multimedia  82801AA AC'97 Audio Controller
/0/100/6                     bus         KeyLargo/Intrepid USB
/0/100/6/1        usb2       bus         OHCI Host Controller
/0/100/7                     bridge      82371AB/EB/MB PIIX4 ACPI
/0/100/b                     bus         82801FB/FBM/FR/FW/FRW (ICH6 Family) USB
/0/100/b/1        usb1       bus         EHCI Host Controller
/0/100/d          scsi0      storage     82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI 
/0/100/d/0.0.0    /dev/sda   disk        21GB VBOX HARDDISK
/0/100/d/0.0.0/1  /dev/sda1  volume      101MiB EXT3 volume
/0/100/d/0.0.0/2  /dev/sda2  volume      19GiB Linux LVM Physical Volume partiti


クラス指定してフィルタリングも出来るようです。

# lshw -C cpu
  *-cpu                   
       product: Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
       vendor: Intel Corp.
       physical id: 2
       bus info: cpu@0
       version: 6.7.10
       serial: 0001-067A-0000-0000-0000-0000
       size: 18EHz
       width: 32 bits
       capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 nx constant_tsc up pni monitor ssse3

# lshw -short -C cpu
H/W path          Device     Class       Description
====================================================
/0/2                         processor   Intel(R) Core(TM)2 Duo CPU     P8600  @

他、HTMLやXMLへの出力も出来る様です。
加工したい場合はこっちの方がいいかも知れません。

今日はこんな所で。