Home > 工具介绍 > hwconfig查看硬件信息

hwconfig查看硬件信息

February 28th, 2012 Leave a comment Go to comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: hwconfig查看硬件信息

最近经常要测试新硬件,了解硬件的具体型号和参数就非常重要,过去经常透过lspci, dmidecode, dmesg, ethtool, lshal, megacli等命令和各种/proc信息来了解,需要对这些工具很熟悉, 貌似比较不方便和准确。

今天看到某同学用的hwconfig感觉信息很专业,推荐给大家。这里可以下载, 感谢微博@frostwatcher同学.

hwconfig透过收集上面提到的各种信息, 然后根据wiki或者厂家公布的设备识别码, 进一步加工,给用户一个直观的信息.

不废话,效果如下:

$ uname -r
2.6.18-164.el5
$ hwconfig  -h
usage:  hwconfig [-dhnv] [-t timeout] [-r file] [-x file] [-o file]
        -d  show debugging information
        -h  show usage
        -n  don't break output lines
        -o  write output to file (- for stdout)
        -r  write raw source to file (- for stdout)
        -t  abort after timeout seconds
        -v  show version
        -x  write xml to file (- for stdout)
##简约模式
$ sudo hwconfig   
hwconfig: warning: could not run megarc; please yinst megarc
Summary:        Huawei Technologies Tecal RH2285, 2 x Xeon E5620 2.40GHz, 23.5GB / 24GB 1066MHz
System:         Huawei Technologies Tecal RH2285 (Huawei Technologies BC11BTSA)
Processors:     2 x Xeon E5620 2.40GHz 133MHz FSB (16 cores)
Memory:         23.5GB / 24GB 1066MHz == 6 x 4GB, 6 x empty
Disk:           sda (megaraid_sas0): 107GB (38%) JBOD == 1 x LSI-MegaRAID-SAS-RMB
Disk:           sdb (megaraid_sas0): 5.9TB (1%) JBOD == 1 x LSI-MegaRAID-SAS-RMB
Disk-Control:   megaraid_sas0: LSI Logic / Symbios Logic MegaRAID SAS 1078
Disk-Control:   ata_piix0: Intel 82801JI (ICH10 Family) 4 port SATA IDE Controller
Disk-Control:   ata_piix1: Intel 82801JI (ICH10 Family) 2 port SATA IDE Controller
Network:        host5 (bnx2-1): Broadcom NetXtreme II BCM5709 Gigabit Ethernet
Network:        host6 (bnx2-0): Broadcom NetXtreme II BCM5709 Gigabit Ethernet
Network:        eth0 (bnx2): 08:19:a6:24:3c:05, 1000Mb/s <full-duplex>
Network:        eth1 (bnx2): 08:19:a6:24:3c:05, 1000Mb/s <full-duplex>
OS:             RHEL Server 5.4 (Tikanga), Linux 2.6.18-164.el5 x86_64, 64-bit
BIOS:           AMI CTSAV035 12/07/2010
Hostname:       xxxxxx

##这个是非常详细的模式, 了解到各个设备的细节.
$ sudo hwconfig -x cfg.xml
$ less cfg.xml
<system code_version="1.16.7" hostname="dr4000" timestamp="1331966816" xml_version="1.0.1">
  <base_board manufacturer="Dell Inc." model="084YMW" serial="..CN137401C800C9." version="A05" />
  <bios date="10/21/2011" manufacturer="Dell Inc." pretty="Dell 1.9.0 10/21/2011" rev="1.9" version="1.9.0" />
  <chipsets summary="Intel 5500 IOH-24D B3 (Tylersburg), 82801JIR A0 (ICH10R)">
    <chipset handle="56" model="5500 IOH-24D" name="Tylersburg" pci="00:00.0" pci_handle="1" stepping="B3" type="Northbridge" vendor="Intel" />
    <chipset handle="57" model="82801JIR" name="ICH10R" pci="00:1f.0" pci_handle="19" stepping="A0" type="Southbridge" vendor="Intel" />
  </chipsets>
...
 <volume controller="scsi0" drive_write_cache="default" handle="75" name="sda" raid="RAID-0" read_ahead="adaptive" size="598879502336" spans="1" status="ok" stripe="65536">
      <drives>
        <drive>66</drive>
        <drive>67</drive>
      </drives>
      <read_cache enable="0" />
      <write_cache enable="0" policy="write-back" />
    </volume>
  </storage>
  <system manufacturer="Dell Inc." model="Dell DR4000" pretty="Dell DR4000" serial="8MCBB3X" uuid="4C4C4544-004D-4310-8042-B8C04F423358" version="" />
</system>

看着信息还是很专业的,结果微博上有同学反映是个脚本,我看了下原来hwconfig真的是个脚本:

#!/usr/bin/perl -w

# $Id$

$ENV{PATH} = "/etc/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/home/opt:/opt/MegaRAID/MegaCli:/usr/StorMan";

use strict 'vars';
use Getopt::Std;
use POSIX;
...
$ cat `which hwconfig `|wc -l    
9101

挺佩服这帮人的,脚本也能有这样的耐心,写这么长。

祝大家玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 工具介绍 Tags:
  1. February 28th, 2012 at 18:51 | #1

    Huawei还出服务器呢?

    [Reply]

    Yu Feng Reply:

    华为出不少服务器!

    [Reply]

  2. February 28th, 2012 at 19:29 | #2

    我没搞错的话, 这应该是你们ali内部才有的脚本 继承自雅虎,

    还是新版的- –

    [Reply]

    Yu Feng Reply:

    原来是这样的。

    [Reply]

  3. vv
    February 28th, 2012 at 21:04 | #3

    y 的版本的作者還是 David Filo 呢.

    [Reply]

  4. Gill
    March 3rd, 2012 at 03:41 | #4

    Mac下运行出错
    hwconfig: perl-warn: Use of uninitialized value $sockets in numeric lt (<) at ./hwconfig line 10349.
    hwconfig: perl-warn: Use of uninitialized value in division (/) at ./hwconfig line 10362.
    hwconfig: perl-die: Illegal division by zero at ./hwconfig line 10362.

    [Reply]

    Yu Feng Reply:

    在linux下用吧

    [Reply]

  5. lrayathz
    March 13th, 2012 at 15:47 | #5

    悲剧,这个应该是yahoo的工具,本身ali的同学也是偷偷拿过来用,结果被你散播开了。。。

    [Reply]

  6. Woody
    May 8th, 2012 at 16:01 | #6

    链接给的地址是老版本的~~ 新版本的可以共享么
    # wc -l hwconfig
    10870 hwconfig

    ]# perl hwconfig -h
    usage: hwconfig [-dhnv] [-o output-file]
    -d show debugging information
    -h show usage
    -n don’t break output lines
    -v show version
    -o write output to a file
    ~]#

    [Reply]

    Yu Feng Reply:

    写email给我吧

    [Reply]

    slash Reply:

    同求新版:)

    [Reply]

  7. May 15th, 2012 at 15:26 | #7

    ha ,我也找geer要了个最新版本的.

    [Reply]

  8. ethan.wang
    February 21st, 2013 at 12:40 | #8

    也能给我一个新的版本么?谢谢!

    [Reply]

  9. gangzhou
    June 5th, 2013 at 11:32 | #9

    请问下这个最新版本 有么?

    [Reply]

  10. xiaolei
    June 19th, 2013 at 11:37 | #10

    想要个新版的,不知能否给下

    [Reply]

  11. guangguang
    August 19th, 2013 at 11:17 | #11

    褚大师,也给我一个吧。。谢谢。

    [Reply]

  12. sendy
    September 12th, 2013 at 13:22 | #12

    传份新版的给我吧,谢谢

    [Reply]

  13. xianpo
    September 22nd, 2013 at 19:19 | #13

    能传一份给我吗

    [Reply]

  14. xiaoxiao
    October 22nd, 2013 at 15:08 | #14

    能帮忙传一份新的吗

    [Reply]

  15. chengang
    March 18th, 2014 at 10:01 | #15

    麻烦也传一份新的给我。。非常感谢啊。。

    [Reply]

  16. shandandan
    August 10th, 2014 at 09:33 | #16

    也不知道 David Filo 知不知道自己的脚本在国内被使用得这么广泛

    [Reply]

  1. No trackbacks yet.