it-swarm.cn

如何找到有关Linux计算机上硬件的详细信息?

-即-如何获取硬件组件的完整列表在命令行中(在没有窗口系统的机器上)

谢谢。

41
Evgeny

lspci(用于pci卡),lsusb(用于USB),lshw(用于基于Debian的发行版),以下是获取 其他硬件规格 的方法的列表,

41
Keith

如果可用,则dmidecode很方便。尤其是在Dell,HP,IBM硬件上,他们不愿意将相关的硬件信息编程到各个寄存器中。

37
Chad Huneycutt

lspci是列出系统硬件的好工具。 (无论如何,PCI总线上的任何东西。)

cat /proc/cpuinfo-显示CPU信息

cat /proc/meminfo-显示内存信息

dmesg(或cat /var/log/dmesg)包含一些信息,不一定包含所有信息。

如果您有RedHat/CentOS系统,则可以使用sosreport收集大量信息,尽管我不知道它是否列出了所有硬件信息。

这些都是开始寻找所需信息的好地方。

30
baumgart

/ proc文件系统将为您提供所需的信息...但是我不知道您将如何获得它是一个简单的地方。

'cat/proc/cpuinfo'将告诉您有关CPU的信息'cat/proc/devices'将告诉您有关块设备的一些有限信息。 'ifconfig -a'将告诉您有关网络连接的信息

其他人将可以告诉您更多设备。您要对特定设备进行故障排除吗?如果是这样,您将获得更好的帮助,询问一个特定的问题。

3
Michael Shaw

inxi将显示几乎所有内容,不使用任何缩写形式运行,但是有很多选项,但是运行inxi -h可以看到它们

inxi是项目主页所描述的“全功能信息脚本”: https://github.com/smxi/inxi

这是有关如何在Ubuntu上安装它的信息: https://askubuntu.com/questions/284635/inxi-installation-on-ubunt

2
hackinjack

总结一下,我想说这是获取有关您的系统信息的好开始:

  1. dmesg-打印或控制内核环形缓冲区
  2. lspci-列出所有PCI设备
  3. lsusb-列出USB设备
  4. / proc-进程信息伪文件系统
1
alexus

我建议检查出事实,该事实以一种易于在脚本中使用的形式输出大量信息。

http://www.puppetlabs.com/puppet/related-projects/facter/

1
Niels Basjes

我真的很喜欢使用“ Facter ”。列出了非常有用的信息。

1
Sc0rian

您可以使用vi复制以下代码

#!/bin/bash

a=1; c=0
a=1; c=0
# Gather system information, can e.g. be sent to | mail in a cronjob
f_() { while read l; do echo $l; done < $f ; }
#
f_() { while read l; do echo $l; done < $f ; }
# TODO
# ----
# * Netstat output
# * Memory/swap information
# * ifconfig information
# * Make output dependent on argv
# * md5sum checks                               (done)
# * Keep previeous values and compare
# * How to
# * chmod a+x sysinfo.sh
# * ./sysinfo.sh
####################### DO NOT EDIT UNDER THIS LINE ###########################

siheader() {
        echo "================================================================"
        echo -e "* System statistics for: \t`hostname`.`dnsdomainname`"
        echo -e "* Generated on: \t\t`date`"
        echo -e "* Running as: \t\t\t`whoami`"
        echo
}

fuptime() {
        upSeconds=$(cat /proc/uptime | tr "." " " | awk '{print $1}')
        secs=$((${upSeconds}%60))
        mins=$((${upSeconds}/60%60))
        hours=$((${upSeconds}/3600/24))
        days=$((${upSeconds}/86400))
        if [ "${days}" -ne "0" ]
        then
                echo -n "${days} days, "
        fi
        echo "`printf '%02d' ${hours}`:`printf '%02d' ${mins}`:`printf '%02d' ${secs}`"
}

siuptime() {
        echo "=================== Uptime ====================================="
        echo -e "* Uptime: \t\t\t`fuptime`"
        if [ -x /usr/bin/uprecords ];
        then
                echo -e "* High score: \t\t\t`uprecords | tail -n1 | cut -d'|' -f1 | cut -d'n' -f3 | sed 's/^[[:blank:]]*//'`"
        fi
        echo -e "* Load average: \t\t`cat /proc/loadavg | head -c14`"
        echo
}

fw () {
        OFS=${IFS}
        IFS=$'\n'
        CNT=$(echo `w | wc -l`-1 | bc)

        w | tail -n ${CNT} | while read -r a;
        do
                echo -e "\t${a}"
        done

        IFS=${OFS}
}

siusers() {
        echo "=================== Users ======================================"
        echo -e "* Active users: \t\t`who | wc -l`"
        echo "* User information"
        fw
        echo
}

fpstree() {
        OFS=${IFS}
        IFS=$'\n'
        pstree | while read -r a;
        do
                echo -e "\t${a}"
        done
        IFS=${OFS}
}

fcomms() {
        ps -eo comm | sort | uniq | grep -v ^COMMAND | column
        echo

        IFS=${OFS}
}

fprocs() {
        echo `TERM=Linux top -n1 -b | grep "Tasks" | awk '{print $4,$6,$8,$10}'`
        echo -e "==================================Tasks process and memory utilization=============================\n"
    echo "`top -n1 -b`"
}


sitasks() {
        echo "=================== Tasks ======================================"
        echo -e "* Number of running tasks: \t$(echo `ps ax | wc -l` - 1 | bc)"
        #This screws up the email
        #echo "* PS Tree:"
        #fpstree
        echo "* Running programs:"
        fcomms
        echo -e "* CPU load: \t\t\t`TERM=linux top -n2 -b | grep 'Cpu' | tail -n1 | awk '{print $2+$4+$6}'`%"
        PROCS=`fprocs`
        echo "* Process state:"
        echo -e "\tRunning: \t\t`echo ${PROCS} | awk '{print $1}'`"
        echo -e "\tSleeping: \t\t`echo ${PROCS} | awk '{print $2}'`"
        echo -e "\tZombie: \t\t`echo ${PROCS} | awk '{print $3}'`"
        echo -e "\tStopped: \t\t`echo ${PROCS} | awk '{print $4}'`"
        echo
}

froute() {
        OFS=${IFS}
        IFS=$'\n'

        CNT=$(echo `/sbin/route | wc -l` - 1 | bc)
        /sbin/route | tail -n ${CNT} | while read -r a;
        do
                echo -e "\t${a}"
        done

        IFS=${OFS}
}

sinetwork() {
        echo "=================== Networking ================================"
        echo "* Routing table:"
        froute
        echo
}

simemory() {
        echo "=================== Memory ===================================="
        RAMTOTAL=`echo $(($(cat /proc/meminfo | grep MemTotal | awk '{print $2}')/1024))`
        echo "* Ram:\t\t\t free of ${RAMTOTAL}Mb"
}

sidiskstats() {
        echo "=================== Hard Disc ================================="
        echo "* Disk Information:"
        OFS=${IFS}
        IFS=$'\n'
        df -h | grep -v ^none | while read -r a;
        do
                echo -e "\t${a}"
        done
        IFS=${OFS}
        echo
        echo "* Mounts:"
        OFS=${IFS}
        IFS=$'\n'
        mount | while read -r a;
        do
                echo -e "\t${a}"
        done
        IFS=${OFS}
        echo
}

simd5() {
        if [ ! -e md5sums.lst ];
        then
                return
        fi

        echo "=================== MD5Sum Check =============================="

        OFS=${IFS}
        IFS=$'\n'

        echo "* Checking MD5 Sums"

        cat md5sums.lst | grep "^/" | while read -r a;
        do
                F=`echo ${a} | cut -d':' -f1`
                S=`echo ${a} | cut -d':' -f2`
                S2=`md5sum ${F} | cut -d' ' -f1`
                echo -n -e "\t${F}: \t\t\t\t"
                if [ "${S}" = "${S2}" ];
                then
                        echo "[OK]"
                else
                        echo "[INVALID]"
                fi                        
        done

        IFS=${OFS}
        echo
}


##For finding CPU model, cores and 
cpuinfo() {
    echo "=================== CPU Details for Xen =============================="
    echo -e "CPU Details: \n`cat /proc/cpuinfo | sed -n '1,/^$/p'`"
    echo -e "No of Cores: \n`cat /proc/cpuinfo | grep processor | wc -l`"
    if [ "egrep '(vmx|svm)' /proc/cpuinfo >/dev/null 2>/dev/null" ];
    then
        echo -e "\n===============================================================\nServer supports Full-virtualization"
    else
        echo -e "\n===============================================================\nEither server does not support Full-virtualization or it is turned off in BIOS"
    fi

    if [ "egrep 'pae' /proc/cpuinfo >/dev/null 2>/dev/null" ];
    then
        echo -e "\n===============================================================\nServer supports Para-virtualization"
    else
        echo -e "\n===============================================================\nServer does not support Para-virtualization"
    fi
}

##For disk info
diskinfo() {
        echo "=================== Disk usage =============================="
        echo -e "Disk Usage details: \n`df -h`"
}   
##Distro info
distroinfo() {
        echo "=================== Distro Info =============================="
        echo -e "Distro details: \n`lsb_release -a`"
        echo -e "Kernel details: \n`uname -a`"
}   

##Distro info
deviceinfo() {
        echo "=================== Device Info =============================="
        echo -e "Device details: \n`lspci -v`"
        echo -e "Kernel details: \n`uname -a`"
}   
summary() {
        siheader
        siuptime
        siusers
        sitasks
        sinetwork

        simemory
        sidiskstats
    fprocs
        simd5
    deviceinfo
    cpuinfo
    distroinfo
        echo "==============================================================="
        echo "* Brought to you by Taashee- http://www.taashee.com"
}

summary
1
Rajat

对于硬盘,我使用一个自定义脚本,该脚本将以下输出汇总为一个列表:

cat /proc/partitions
cat /proc/mounts

parted -m /dev/sdX unit MB print # need to be root for parted
# or
parted -m -l unit MB print

blkid /dev/sdXN
0
mivk
# tree -d /sys/devices
0
Wojciech Domalewski

最简单的方法是在命令行上键入“ dmesg | more“,这使您可以查看上次系统启动期间发生的所有引导输出。

0
djangofan