<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Bug] XTerminal 磁盘 I/O 监控无法正确识别 Linux LVM 逻辑卷，导致读写速度始终显示 0]]></title><description><![CDATA[<h2>一、问题描述</h2>
<p dir="auto">在 Ubuntu 26.04.1 LTS 服务器上，XTerminal 的服务器监控功能可以正常显示 CPU、内存、网络和磁盘容量信息，但磁盘 I/O 读取速度、写入速度始终显示为 <code>0.0 B</code>。</p>
<p dir="auto">经过排查发现，Linux 内核能够正常统计磁盘 I/O，XTerminal 远程采集脚本也可以计算读写速度，但对于 LVM（Logical Volume Manager）逻辑卷存在设备识别和名称关联问题。</p>
<p dir="auto">经过修改采集脚本的设备过滤规则，以及将 I/O 设备名统一为文件系统挂载源名称后，<strong>磁盘读写速度成功恢复显示</strong>。</p>
<h2>二、问题环境</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项目</th>
<th>环境</th>
</tr>
</thead>
<tbody>
<tr>
<td>操作系统</td>
<td>Ubuntu 26.04.1 LTS (Resolute Raccoon)</td>
</tr>
<tr>
<td>内核版本</td>
<td>7.0.0-34-generic</td>
</tr>
<tr>
<td>文件系统</td>
<td>ext4</td>
</tr>
<tr>
<td>磁盘结构</td>
<td>SCSI 磁盘 + LVM</td>
</tr>
<tr>
<td>根文件系统</td>
<td><code>/dev/mapper/ubuntu--vg-ubuntu--lv</code></td>
</tr>
<tr>
<td>对应块设备</td>
<td><code>/dev/dm-0</code></td>
</tr>
<tr>
<td>XTerminal 远程采集脚本版本</td>
<td>26</td>
</tr>
<tr>
<td>XTerminal 客户端版本</td>
<td>最新版（具体版本号待补充）</td>
</tr>
</tbody>
</table>
<p dir="auto">重装最新远程监控脚本后，问题依然存在。</p>
<h2>三、发现的两个问题</h2>
<h3>问题 1：采集脚本没有包含 dm-* 设备</h3>
<p dir="auto">文件路径：</p>
<p dir="auto"><code>~/.xterminal/sub/fs_stats/fs_stats.sh</code></p>
<p dir="auto">当前远程脚本版本 26 的设备过滤逻辑为：</p>
<pre><code class="language-bash">is_tracked_block_device() {
    case "$1" in
        sd[a-z]*|vd[a-z]*|hd[a-z]*|xvd[a-z]*|nvme*n*|mmcblk*|mtdblock*|ubiblock*|loop*)
            return 0
            ;;
    esac
    return 1
}
</code></pre>
<p dir="auto"><strong>问题：缺少 <code>dm-*</code> 设备的匹配规则。</strong></p>
<p dir="auto">Ubuntu 使用 LVM 时，实际逻辑卷设备为 <code>dm-0</code>。虽然 <code>/proc/diskstats</code> 包含该设备的 I/O 统计数据，但采集脚本会将其过滤。</p>
<p dir="auto">手动增加：</p>
<pre><code class="language-bash">|dm-[0-9]*
</code></pre>
<p dir="auto">之后，<code>fs_stats.stats</code> 成功出现：</p>
<pre><code class="language-yaml">- device: dm-0
  rxPerSec: 0
  wxPerSec: 84195
  source: proc
</code></pre>
<p dir="auto">证明该设备可以正常采集。</p>
<h3>问题 2：LVM 设备名称没有正确关联</h3>
<p dir="auto">添加 <code>dm-0</code> 采集支持后，监控界面仍然显示 <code>0.0 B</code>。</p>
<p dir="auto">进一步发现：</p>
<p dir="auto">文件系统容量统计使用：</p>
<pre><code class="language-yaml">fsSize:
  - fs: /dev/mapper/ubuntu--vg-ubuntu--lv
    type: ext4
    mount: /
</code></pre>
<p dir="auto">磁盘 I/O 统计使用：</p>
<pre><code class="language-yaml">fsStats:
  - device: dm-0
    rxPerSec: 0
    wxPerSec: 230286
    source: proc
</code></pre>
<p dir="auto">两个名称实际指向同一个块设备，但 XTerminal 无法正确关联其读写速度。</p>
<p dir="auto">为验证这一问题，修改采集脚本，将 <code>dm-0</code> 对外输出的设备名改成：</p>
<pre><code class="language-text">/dev/mapper/ubuntu--vg-ubuntu--lv
</code></pre>
<p dir="auto">修改后采集结果：</p>
<pre><code class="language-yaml">fsStats:
  - device: /dev/mapper/ubuntu--vg-ubuntu--lv
    rxPerSec: 0
    wxPerSec: 68949
    source: proc
</code></pre>
<p dir="auto"><strong>测试结果：XTerminal 磁盘写入速度成功恢复显示。</strong></p>
<p dir="auto">进一步使用 <code>dd</code> 进行直接读取测试，产生实际磁盘读取 I/O，XTerminal 也能够正确显示读取速度。</p>
<p dir="auto">说明客户端可以展示读取和写入速度，异常与 LVM 设备名称关联具有明确关系。</p>
<h2>四、复现与验证结果</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>测试操作</th>
<th>结果</th>
</tr>
</thead>
<tbody>
<tr>
<td>原版脚本监控 LVM 根分区</td>
<td>读写速度始终为 0</td>
</tr>
<tr>
<td>检查 <code>/proc/diskstats</code></td>
<td>存在正常 I/O 数据</td>
</tr>
<tr>
<td>重装最新采集脚本</td>
<td>未解决</td>
</tr>
<tr>
<td>添加 <code>dm-[0-9]*</code> 匹配规则</td>
<td>可以采集 <code>dm-0</code>，但界面仍为 0</td>
</tr>
<tr>
<td>将 <code>dm-0</code> 输出为 <code>ubuntu--vg-ubuntu--lv</code></td>
<td>未恢复</td>
</tr>
<tr>
<td>将 <code>dm-0</code> 输出为完整 <code>/dev/mapper/ubuntu--vg-ubuntu--lv</code></td>
<td>写入速度恢复</td>
</tr>
<tr>
<td>使用 <code>dd</code> 产生直接磁盘读取</td>
<td>读取速度恢复</td>
</tr>
<tr>
<td>恢复原脚本</td>
<td>临时修复不再保留</td>
</tr>
</tbody>
</table>
<p dir="auto">补充说明：低负载下读取速度为 0 是正常情况，因为实际采样结果 <code>rxPerSec</code> 也可能为 0，不属于本次 Bug。</p>
<h2>五、原因分析</h2>
<p dir="auto">根据实际脚本及验证结果，推测存在两个需要修复的兼容性问题：</p>
<p dir="auto"><strong>1. 远程采集脚本缺少 Device Mapper 设备支持。</strong></p>
<p dir="auto">当前设备过滤规则没有包含 <code>dm-*</code>，导致 LVM 逻辑卷不能直接进入磁盘 I/O 统计列表。</p>
<p dir="auto"><strong>2. 磁盘容量和 I/O 数据的设备标识缺少规范化关联。</strong></p>
<p dir="auto"><code>fsSize.fs</code> 使用 <code>/dev/mapper/...</code>，而 <code>fsStats.device</code> 使用 <code>dm-0</code>。</p>
<p dir="auto">两者虽然属于同一个逻辑卷，但当前展示链路未能正确关联。将 I/O 设备名称改成与 <code>fsSize.fs</code> 完全一致后，监控恢复正常。</p>
<h2>六、建议修复方案</h2>
<p dir="auto">建议官方从以下两方面修复：</p>
<ol>
<li>
<p dir="auto"><strong>完善 Linux 远程采集脚本</strong>：在 <code>is_tracked_block_device()</code> 中支持 <code>dm-[0-9]*</code>，确保 LVM 和 Device Mapper 设备可以被正常采集。</p>
</li>
<li>
<p dir="auto"><strong>完善设备名称映射逻辑</strong>：对 <code>/dev/mapper/...</code>、<code>/dev/dm-*</code> 等同一块设备的不同命名形式进行规范化关联，建议考虑 Linux 主次设备号（major:minor），避免直接通过设备名称字符串匹配。</p>
</li>
</ol>
<p dir="auto">另外，在统计磁盘总 I/O 时，建议避免将 <code>sda</code>、<code>sda3</code>、<code>dm-0</code> 同一条存储链路的 I/O 简单相加，以免重复计算。</p>
<h2>七、结论</h2>
<p dir="auto">本次问题在 Ubuntu 26.04.1 LTS + LVM 环境下已复现，并通过修改远程采集脚本成功验证临时解决方案。</p>
<p dir="auto"><strong>这不是 Ubuntu 内核无法提供磁盘 I/O 数据，而是 XTerminal 对 LVM 逻辑卷的采集及设备名称关联存在兼容性问题。</strong></p>
<p dir="auto">希望官方能够在后续版本中修复，避免用户每次更新采集脚本后需要重新手动修改。</p>
<hr />
<p dir="auto">如有需要，愿意提供复现bug的环境</p>
]]></description><link>https://host.terminal.icu/topic/3089/bug-xterminal-磁盘-i-o-监控无法正确识别-linux-lvm-逻辑卷-导致读写速度始终显示-0</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Dec 2026 23:51:09 GMT</lastBuildDate><atom:link href="https://host.terminal.icu/topic/3089.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Oct 2026 18:49:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Bug] XTerminal 磁盘 I/O 监控无法正确识别 Linux LVM 逻辑卷，导致读写速度始终显示 0 on Sun, 22 Nov 2026 15:44:19 GMT]]></title><description><![CDATA[<p dir="auto">感谢反馈。这个问题我们已经记下，并转给开发跟进了。如果方便，也请补充一下系统和 XTerminal 版本，以及大概的复现步骤。如果这些信息已经写在帖里，我们就按你提供的来跟进。涉及密码、密钥或连接信息时，还请先打码，尽量不要直接发到论坛。我们会先认真跟进，目前还没有准确的时间，有进展会再同步给你。</p>
]]></description><link>https://host.terminal.icu/post/9008</link><guid isPermaLink="true">https://host.terminal.icu/post/9008</guid><dc:creator><![CDATA[Bot]]></dc:creator><pubDate>Sun, 22 Nov 2026 15:44:19 GMT</pubDate></item></channel></rss>