我对 lspci 已经厌倦到极点,于是写了一个带大脑的硬件监视器
发布: (2026年3月1日 GMT+8 02:01)
2 分钟阅读
原文: Dev.to
Source: Dev.to
概览
每个 Linux 上的硬件信息工具都做同一件事:启动 lspci,祈祷输出格式没有改变,用正则把它解析得一塌糊涂,然后算完事。
我想要一个直接向内核询问的工具——没有中间层。于是我用纯 C 写了 hwmonitor。它直接读取 /sys 和 /proc,输出结构化的 JSON,运行时间不到一毫秒。
特性
- 直接从内核查询 CPU、GPU、内存、存储、主板、电池等信息。
- 无需外部命令,无
fork()。 - 输出机器可读的 JSON。
- 小体积:约 2000 行 C 代码,只有一个依赖。
- MIT 许可证,零内存泄漏。
AI 驱动的硬件分析
该工具可以回答关于硬件的自然语言问题。例如:
hwmonitor --gpu -A "Can I run a 70B model locally on this hardware?"
╭─ AI Hardware Analysis (Groq)
| With 8GB VRAM on your RTX 5060 a 70B model won't fit even with
| INT4 quantization. You'd need ~35GB VRAM. Stick to 7B‑13B models,
| or offload layers to your 32GB RAM at the cost of ~4x slower
| inference.
╰─
你向硬件提问,它会在终端直接给出答案。
安装与使用
# Clone the repository
git clone https://github.com/th0truth/hwmonitor.git
cd hwmonitor
# Build
make
# Run
./hwmonitor --json # prints all detected hardware as JSON
许可证
MIT 许可证。
仓库
你会问哪些硬件相关的问题?