inxi是一个用于获取Linux系统信息的终端命令。
能够获取软件和硬件的详细信息,比如计算机型号、内核版本、发行版号以及桌面环境等信息,甚至可以读取主存模块占用主板的哪块RAM卡槽等详细信息。
inxi还可以用于监控系统中正在消耗CPU或者内存资源的进程。
首先展示下如何安装inxi。
在Linux上安装inxi
inxi也算是一个非常流行的工具,所以在大多数Linux发行版仓库中都可以轻松获取到该工具。
不过还没有流行到各大Linux发行版默认就安装了该软件,所以需要自己安装一下。
博主日常用RHEL系,就只展示下CentOS7的命令。
1 2 dnf install epel-release -y dnf install inxi -y
用inxi获取信息
直接运行inxi的效果如下。
1 2 3 4 > inxi CPU: 2x 8-Core Intel Xeon Silver 4208 (-MT MCP SMP-) speed/min/max: 2500/800/3200 MHz Kernel: 5.10.6-1.el7.elrepo.x86_64 x86_64 Up: 357d 5h 17m Mem: 9544.2/64063.7 MiB (14.9%) Storage: 1.53 TiB (4.9% used) Procs: 912 Shell: Zsh inxi: 3.3.09
可以简要浏览这些信息:
CPU
时钟频率(speed/min/max)
内核信息(Kernel)
开机时间(Up)
内存(Mem)
磁盘存储空间(Storage)
运行进程数量(Procs)
当前使用的Shell
inxi版本信息
带上-b
可以获得更为详细的信息,博主随便拉了个常用的服务器跑了一次。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 System: Host: normal-server Kernel: 5.10.6-1.el7.elrepo.x86_64 x86_64 bits: 64 Console: pty pts/4 Distro: CentOS Linux release 7.9.2009 (Core) Machine: Type: Server System: Inspur product: SA5212M5 v: 00001 serial: 719296827 Mobo: Inspur model: YZMB-00882-104 v: SA5212M5 serial: MBKC07S24822B40 BIOS: American Megatrends v: 4.1.9 date: 01/21/2020 CPU: Info: 2x 8-Core Intel Xeon Silver 4208 [MT MCP SMP] speed: 2500 MHz min/max: 800/3200 MHz Graphics: Device-1: ASPEED Graphics Family driver: ast v: kernel Display: server: No display server data found. Headless machine? tty: 180x46 Message: Unable to show advanced data. Required tool glxinfo missing. Network: Device-1: Intel Ethernet X722 for 10GbE SFP+ driver: i40e Device-2: Intel Ethernet X722 for 10GbE SFP+ driver: i40e Device-3: Mellanox MT27710 Family [ConnectX-4 Lx] driver: mlx5_core Device-4: Mellanox MT27710 Family [ConnectX-4 Lx] driver: mlx5_core Drives: Local Storage: total: 1.53 TiB used: 75.96 GiB (4.9%) Info: Processes: 894 Uptime: 357d 5h 29m Memory: 62.56 GiB used: 9.3 GiB (14.9%) Init: systemd runlevel: 3 Shell: Zsh inxi: 3.3.09
信息还挺多的,不过没有显卡。
杂项信息
使用-A
获得Audio信息,即音频输入输出设备。
使用-B
是Battery信息。
使用-G
是图形显示相关信息。
以上三个在服务器上都没有……
使用-F
则是获得比-b
更为详尽的信息。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 System: Host: normal-server Kernel: 5.10.6-1.el7.elrepo.x86_64 x86_64 bits: 64 Console: pty pts/4 Distro: CentOS Linux release 7.9.2009 (Core) Machine: Type: Server System: Inspur product: SA5212M5 v: 00001 serial: 719296827 Mobo: Inspur model: YZMB-00882-104 v: SA5212M5 serial: MBKC07S24822B40 BIOS: American Megatrends v: 4.1.9 date: 01/21/2020 CPU: Info: 2x 8-Core model: Intel Xeon Silver 4208 bits: 64 type: MT MCP SMP cache: L2: 2x 8 MiB (16 MiB) Speed: 2500 MHz min/max: 800/3200 MHz Core speeds (MHz): 1: 2500 2: 2500 3: 2500 4: 2500 5: 2500 6: 2500 7: 2500 8: 2500 9: 2500 10: 2500 11: 2500 12: 2501 13: 2500 14: 2500 15: 2500 16: 2500 17: 2500 18: 2500 19: 2500 20: 2503 21: 2502 22: 2500 23: 2500 24: 2500 25: 2500 26: 2500 27: 2500 28: 2500 29: 2500 30: 2500 31: 2500 32: 2500 Graphics: Device-1: ASPEED Graphics Family driver: ast v: kernel Display: server: No display server data found. Headless machine? tty: 180x46 Message: Unable to show advanced data. Required tool glxinfo missing. Audio: Message: No device data found. Network: Device-1: Intel Ethernet X722 for 10GbE SFP+ driver: i40e IF: em1 state: up speed: 10000 Mbps duplex: full mac: b4:05:5d:0f:ff:7a Device-2: Intel Ethernet X722 for 10GbE SFP+ driver: i40e IF: em2 state: down mac: b4:05:5d:0f:ff:7b Device-3: Mellanox MT27710 Family [ConnectX-4 Lx] driver: mlx5_core IF: p1p1 state: up speed: 25000 Mbps duplex: full mac: 0c:42:a1:b2:2a:78 Device-4: Mellanox MT27710 Family [ConnectX-4 Lx] driver: mlx5_core IF: p1p2 state: down mac: 0c:42:a1:b2:2a:79 IF-ID-1: br-25031b40df82 state: up speed: 10000 Mbps duplex: unknown mac: 02:42:39:76:64:e4 IF-ID-2: docker0 state: down mac: 02:42:e5:0c:2e:c6 IF-ID-3: veth1a4373b state: up speed: 10000 Mbps duplex: full mac: b2:e7:dc:cf:67:a4 IF-ID-4: veth981c6f5 state: up speed: 10000 Mbps duplex: full mac: c6:dc:d3:04:26:7a IF-ID-5: veth9f95df8 state: up speed: 10000 Mbps duplex: full mac: 96:e2:3f:58:f1:19 IF-ID-6: vethbb2cae1 state: up speed: 10000 Mbps duplex: full mac: f6:82:d8:91:08:ad IF-ID-7: vethc85d4c4 state: up speed: 10000 Mbps duplex: full mac: 42:21:8e:64:55:63 IF-ID-8: vethcee0e6a state: up speed: 10000 Mbps duplex: full mac: e6:26:77:0b:eb:4f IF-ID-9: vethcffaf62 state: up speed: 10000 Mbps duplex: full mac: 0e:67:16:a8:48:e2 IF-ID-10: vethfe3e800 state: up speed: 10000 Mbps duplex: full mac: a6:a6:00:d5:98:24 RAID: Hardware-1: Broadcom / LSI MegaRAID SAS-3 3108 [Invader] driver: megaraid_sas Drives: Local Storage: total: 1.53 TiB used: 75.96 GiB (4.9%) ID-1: /dev/sda model: MR9361-8i size: 223.06 GiB ID-2: /dev/sdb model: MR9361-8i size: 1.31 TiB Partition: ID-1: / size: 204.96 GiB used: 16.59 GiB (8.1%) fs: xfs dev: /dev/sda2 ID-2: /boot size: 1.99 GiB used: 216 MiB (10.6%) fs: xfs dev: /dev/sda1 Swap: ID-1: swap-1 type: partition size: 16 GiB used: 149.5 MiB (0.9%) dev: /dev/sda3 Sensors: System Temperatures: ipmi cpu-1: 29 C cpu-2: 30 C mobo: N/A Fan Speeds (RPM): ipmi fan-1: 4320 fan-2: 4320 fan-3: 4320 System Temperatures: lm-sensors cpu: 28.0 C mobo: N/A Fan Speeds (RPM): lm-sensors N/A Info: Processes: 873 Uptime: 357d 5h 35m Memory: 62.56 GiB used: 9.16 GiB (14.6%) Init: systemd runlevel: 3 Shell: Zsh inxi: 3.3.09
甚至能看到虚拟网卡和RAID卡的信息。
进程/内存/包存储库/raid/天气
使用-I
显示当前进程数、开机时间、shell、内存使用情况和inxi的版本号,差不多就是无参数的inxi弱化版。
1 2 Info: Processes: 856 Uptime: 357d 5h 39m Memory: 62.56 GiB used: 8.7 GiB (13.9%) Init: systemd runlevel: 3 Shell: Zsh inxi: 3.3.09
使用-m
就是内存信息了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Memory: RAM: total: 62.56 GiB used: 8.88 GiB (14.2%) Array-1: capacity: 9 TiB note: check slots: 24 EC: Single-bit ECC Device-1: CPU0_CH0_DIMM0 size: 16 GiB speed: spec: 2666 MT/s actual: 2400 MT/s Device-2: CPU0_CH0_DIMM1 size: No Module Installed Device-3: CPU0_CH1_DIMM0 size: 16 GiB speed: spec: 2666 MT/s actual: 2400 MT/s Device-4: CPU0_CH1_DIMM1 size: No Module Installed Device-5: CPU0_CH2_DIMM0 size: No Module Installed Device-6: CPU0_CH2_DIMM1 size: No Module Installed Device-7: CPU0_CH3_DIMM0 size: No Module Installed Device-8: CPU0_CH3_DIMM1 size: No Module Installed Device-9: CPU0_CH4_DIMM0 size: No Module Installed Device-10: CPU0_CH4_DIMM1 size: No Module Installed Device-11: CPU0_CH5_DIMM0 size: No Module Installed Device-12: CPU0_CH5_DIMM1 size: No Module Installed Device-13: CPU1_CH0_DIMM0 size: 16 GiB speed: spec: 2666 MT/s actual: 2400 MT/s Device-14: CPU1_CH0_DIMM1 size: No Module Installed Device-15: CPU1_CH1_DIMM0 size: 16 GiB speed: spec: 2666 MT/s actual: 2400 MT/s Device-16: CPU1_CH1_DIMM1 size: No Module Installed Device-17: CPU1_CH2_DIMM0 size: No Module Installed Device-18: CPU1_CH2_DIMM1 size: No Module Installed Device-19: CPU1_CH3_DIMM0 size: No Module Installed Device-20: CPU1_CH3_DIMM1 size: No Module Installed Device-21: CPU1_CH4_DIMM0 size: No Module Installed Device-22: CPU1_CH4_DIMM1 size: No Module Installed Device-23: CPU1_CH5_DIMM0 size: No Module Installed Device-24: CPU1_CH5_DIMM1 size: No Module Installed
不愧是服务器,插槽真多(。
使用--memory-shrot
则能看简易版的内存信息。
1 2 Memory: RAM: total: 62.56 GiB used: 8.47 GiB (13.5%) Report: arrays: 1 slots: 24 modules: 4 type: Unknown
使用-r
查看当前使用的包管理仓库。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 Repos: No active dnf repos in: /etc/dnf/dnf.conf No active yum repos in: /etc/yum.conf No active yum repos in: /etc/yum.repos.d/CentOS-Base.repo No active yum repos in: /etc/yum.repos.d/CentOS-CR.repo No active yum repos in: /etc/yum.repos.d/CentOS-Debuginfo.repo No active yum repos in: /etc/yum.repos.d/CentOS-Media.repo Active yum repos in: /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo 1: centos-sclo-rh ~ http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh Active yum repos in: /etc/yum.repos.d/CentOS-SCLo-scl.repo 1: centos-sclo-sclo ~ http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo No active yum repos in: /etc/yum.repos.d/CentOS-Sources.repo No active yum repos in: /etc/yum.repos.d/CentOS-Vault.repo No active yum repos in: /etc/yum.repos.d/CentOS-fasttrack.repo No active yum repos in: /etc/yum.repos.d/CentOS-x86_64-kernel.repo No active yum repos in: /etc/yum.repos.d/ansible-tower.repo Active yum repos in: /etc/yum.repos.d/elrepo.repo 1: elrepo ~ http://mirrors.tuna.tsinghua.edu.cn/elrepo/elrepo/el7/$basearch/ No active yum repos in: /etc/yum.repos.d/epel-testing.repo Active yum repos in: /etc/yum.repos.d/epel.repo 1: epel ~ https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch No active yum repos in: /etc/yum.repos.d/remi-glpi91.repo No active yum repos in: /etc/yum.repos.d/remi-glpi92.repo No active yum repos in: /etc/yum.repos.d/remi-glpi93.repo No active yum repos in: /etc/yum.repos.d/remi-glpi94.repo No active yum repos in: /etc/yum.repos.d/remi-modular.repo No active yum repos in: /etc/yum.repos.d/remi-php54.repo No active yum repos in: /etc/yum.repos.d/remi-php70.repo No active yum repos in: /etc/yum.repos.d/remi-php71.repo No active yum repos in: /etc/yum.repos.d/remi-php72.repo Active yum repos in: /etc/yum.repos.d/remi-php73.repo 1: remi-php73 ~ http://cdn.remirepo.net/enterprise/7/php73/mirror No active yum repos in: /etc/yum.repos.d/remi-php74.repo No active yum repos in: /etc/yum.repos.d/remi-php80.repo No active yum repos in: /etc/yum.repos.d/remi-php81.repo Active yum repos in: /etc/yum.repos.d/remi-safe.repo 1: remi-safe ~ http://cdn.remirepo.net/enterprise/7/safe/mirror No active yum repos in: /etc/yum.repos.d/remi.repo
不过好像对安装了dnf的CentOS不太友好。
-R
则是raid卡设备了。
1 RAID: Hardware-1: Broadcom / LSI MegaRAID SAS-3 3108 [Invader] driver: megaraid_sas
甚至可以用-W
查询天气。
1 2 3 > inxi -W Tokyo,Japan Weather: Report: temperature: 0.6 C (33 F) conditions: Overcast clouds Locale: current time: Thu 06 Jan 2022 09:21:55 PM JST Source: WeatherBit.io
监控资源使用情况
-t
可以查看top5的进程信息。还可以追加-c
和-m
查看cpu和内存使用情况。
-t
效果和-t cm5
相同,即top5的信息。
1 2 3 4 5 6 7 8 9 10 11 12 13 Processes: CPU top: 5 of 838 1: cpu: 67.4% command: mysqld pid: 24509 2: cpu: 30.1% command: ./agent pid: 30118 3: cpu: 8.0% command: poller.php started by: php pid: 2235 4: cpu: 5.1% command: poller.php started by: php pid: 2163 5: cpu: 4.5% command: poller.php started by: php pid: 2124 System RAM: total: 62.56 GiB used: 8.39 GiB (13.4%) Memory top: 5 of 838 1: mem: 1521.1 MiB (2.3%) command: mysqld pid: 24509 2: mem: 150.1 MiB (0.2%) command: mysqld pid: 19241 3: mem: 84.5 MiB (0.1%) command: systemd-journald pid: 764 4: mem: 78.5 MiB (0.1%) command: dockerd-current pid: 8074 5: mem: 78.1 MiB (0.1%) command: ./agent pid: 30118
偶尔需要监控资源使用情况时,该工具还算趁手。
如果需要更多的资源监控功能,则推荐使用一些其他的工具。
总结
对于需要诊断计算机问题以及获取那些并不熟悉的软硬件信息的人来说,inxi 工具是十分便利且有用的。
它能识别那些消耗 CPU、内存的进程;可以检查是否安装了合适的图形驱动程序、主板 UEFI/BIOS 是否需要更新等等。
事实上,在inxi开源社区论坛上,会要求那些寻求帮助的成员提供inxi命令输出内容以便判断他们当前正在使用什么样的系统环境。
当然也有其他的工具可以读取Linux上的硬件信息,不过inxi同时能读取硬件和软件信息。