witr v0.3.4 配置参数详解
witr v0.3.4 行为参数全集:15 个旗标的取值与默认值、五类目标解析规则、七种输出形态、0-6 退出码契约、TUI 按键与 Shell 补全配置,全部配真实服务器实测回显。
witr v0.3.4 配置参数详解
目标:把 witr v0.3.4 的全部行为参数一次讲透——15 个命令行旗标的取值与默认值、五类查询目标的解析规则、七种输出形态、0–6 退出码契约、TUI 交互按键与 Shell 补全配置,并给出可直接落地的脚本集成模板。witr 无配置文件,一切行为由旗标控制,本文即它的「配置全集」;每个参数说明均配 Ubuntu 24.04.5 LTS 真机实测回显。安装步骤见《Ubuntu 24.04 安装 witr v0.3.4 指南》,命令场景实操见《witr v0.3.4 常用 CLI 命令详解》。
一、环境信息
本文全部实测在以下环境完成,回显为实际输出:
| 项 | 值 |
|---|---|
| 操作系统 | Ubuntu 24.04.5 LTS(x86_64,systemd 在管) |
| witr 版本 | v0.3.4(commit 7e46fa68,2026-10-04 构建) |
| 安装路径 | /usr/local/bin/witr(方案 A 脚本安装) |
| man 页 | /usr/local/share/man/man1/witr.1 |
| 运行用户 | root |
| 实测样例进程 | sshd(pid 7194,ssh.service 拉起的监听进程)、python3 -m http.server 8141(会话内临时服务) |
💡 说明:witr 的「参数」分三层——旗标层(本文第四~六章)、交互层(TUI 按键,第八章)、契约层(退出码与 JSON 字段约定,第七章与 6.4 节)。没有
/etc/witr.conf这类配置文件,也没有环境变量开关,全部配置随命令行生效即走。
二、前置条件
- 已按安装指南完成 witr 安装并确认版本:
witr --version
实测回显:
witr v0.3.4 (commit 7e46fa68151fd7c59fb7a0cf4247a9a0ac0fbb6e, built 2026-10-04T17:31:44Z)
- root 或普通用户均可运行(普通用户看不到其他用户进程详情,端口场景仅返回归属用户;本文以 root 实测);
--container功能需要目标运行时的 CLI 在PATH中(docker/podman/nerdctl/crictl 等,装了哪个查哪个);- TUI 需要 tty 终端(脚本/管道中运行会得到退出码 4,见 8.3 节实测)。
三、参数查看与修改方式
witr 没有可持久化的配置,参数体系通过三个入口查看与固化:
| 入口 | 命令 | 用途 |
|---|---|---|
| 内置帮助 | witr --help | 一屏看全 15 个旗标、默认值与官方示例 |
| man 手册 | man witr | 按 man 分节组织的参数与描述(随安装附带) |
| Shell 补全 | witr completion <shell> | 把旗标补全注入 bash/zsh/fish/powershell,输入时即得参数提示 |
witr --help 完整实测回显(本文参数表的原始依据):
witr explains why a process or port is running by tracing its ancestry.
Usage:
witr [process name...] [flags]
Examples:
# Inspect a running process by name
witr nginx
# Look up a process by PID
witr --pid 1234
# Find the process listening on a specific port
witr --port 5432
# Find the process holding a file open
witr --file /var/lib/dpkg/lock
# Inspect a container by name
witr --container redis
# Inspect a process by name with exact matching (no fuzzy search)
witr bun --exact
# Show the full process ancestry (who started whom)
witr postgres --tree
# Show only warnings (suspicious env, arguments, parents)
witr docker --warnings
# Display only environment variables of the process
witr node --env
# Short, single-line output (useful for scripts)
witr sshd --short
# Disable colorized output (CI or piping)
witr redis --no-color
# Output machine-readable JSON
witr chrome --json
# Show extended process information (memory, I/O, file descriptors)
witr mysql --verbose
# Combine flags: inspect port, show environment variables, output JSON
witr --port 8080 --env --json
# Multiple inputs
witr nginx node
witr --port 8080 --port 3000
witr --pid 1234 --pid 5678
# Mixed inputs
witr nginx --pid 1234 --port 8080
Flags:
-c, --container strings container(s) to look up (repeatable)
--env show environment variables for the process
-x, --exact use exact name matching (no substring search)
-f, --file strings file(s) held open by a process (repeatable)
-h, --help help for witr
-i, --interactive interactive mode (TUI)
--json show result as JSON
--no-color disable colorized output
-p, --pid strings pid(s) to look up (repeatable)
-o, --port strings port(s) to look up (repeatable)
-s, --short show only ancestry
-t, --tree show only ancestry as a tree
--verbose show extended process information
-v, --version version for witr
--warnings show only warnings
man 手册同源(man -P cat witr 实测节选):
WITR(1) WITR(1)
NAME
witr - Why is this running?
SYNOPSIS
witr [process name...] [flags]
DESCRIPTION
witr explains why a process or port is running by tracing its ancestry.
OPTIONS
-c, --container=[] container(s) to look up (repeatable)
...
四、参数总览
15 个旗标按用途分三组的总表(默认值均来自上方 --help 实测回显):
目标选择组(决定「查谁」)
| 旗标(短/长) | 类型与默认值 | 作用 |
|---|---|---|
| 位置参数 | 字符串,可不传 | 进程/服务名,默认子串模糊匹配 |
-x, --exact | 布尔,默认 false | 名称改用精确匹配(关掉子串搜索) |
-p, --pid | 字符串列表,可重复 | 按 PID 查询 |
-o, --port | 字符串列表,可重复 | 按监听端口查询 |
-f, --file | 字符串列表,可重复 | 按被打开文件查询 |
-c, --container | 字符串列表,可重复 | 按容器名/ID/镜像/compose 服务查询 |
输出模式组(决定「怎么呈现」)
| 旗标 | 类型与默认值 | 作用 |
|---|---|---|
| (默认) | — | 标准报告(进程卡片+因果链+来源+上下文+警告) |
-s, --short | 布尔,默认 false | 只输出单行祖先链 |
-t, --tree | 布尔,默认 false | 只输出树形祖先图(含最多 10 个子进程并高亮目标) |
--json | 布尔,默认 false | 结构化 JSON 输出(字段契约见 6.4) |
--env | 布尔,默认 false | 只输出进程环境变量 |
--warnings | 布尔,默认 false | 只输出警告清单 |
--verbose | 布尔,默认 false | 附加 CPU/内存/IO/文件描述符/线程明细 |
--no-color | 布尔,默认 false | 关闭着色(CI、管道、日志归档场景) |
交互与元信息组
| 旗标 | 类型与默认值 | 作用 |
|---|---|---|
-i, --interactive | 布尔,默认 false | 进入 TUI 交互仪表盘(无参数运行也自动进入) |
-h, --help | 布尔,默认 false | 显示帮助(实测见第三章) |
-v, --version | 布尔,默认 false | 显示版本号与构建信息 |
关键差异解读:目标组各旗标可重复、可任意混用(结果按输入顺序分段输出);输出模式组各旗标互斥(同给时按内部优先级取一种,--json 可与 -s/-t/--warnings/--env 叠加成四种缩减 JSON 形态)。多次运行想固化参数组合,用 Shell 别名或脚本包装即可(模板见第十章)。
五、目标选择参数详解
5.1 位置参数:进程名(默认模糊匹配)
不加旗标直接给名字,按子串在全部进程名中搜索。实测 witr sshd(本机有监听主进程与多个会话子进程,全部命中):
Multiple matching processes found:
[1] sshd (pid 7194)
sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
[2] sshd (pid 25397)
sshd: root@notty
[3] sshd (pid 88186)
sshd: root@notty
[4] sshd (pid 214186)
sshd: root@pts/2
[5] sshd (pid 214891)
sshd: root@notty
Re-run with:
witr --pid <pid>
多命中时列出候选并提示用 --pid 复查,退出码为 4(歧义)。模糊匹配的代价是「短名误伤」——witr ssh 也会命中所有 sshd,此时用 --exact 关闭子串搜索。
5.2 -x, --exact:精确匹配
加 -x 后只匹配进程名完全相等的进程。实测对比(主机侧有 python3 系统进程,另有一个跑在 python:3.12-alpine 上的演示负载,进程名恰为 python):
witr python -x
实测回显:
Target : python
Process : python (pid 849108) {forked}
User : root
Security : AppArmor docker-default (enforce)
Container : docker: witr-v034-py
Image : python:3.12-alpine
Command : python -m http.server 8142 --bind 0.0.0.0
Started : just now (Sun 2026-10-25 09:41:45 +08:00)
Why It Exists :
systemd (pid 1) → ? (original parent exited) → containerd-shim-runc-v2 (pid 849084) → python (pid 849108)
Source : docker (container)
Working Dir : /
Warnings :
• Process is running as root
• Container has no healthcheck configured
主机侧的 python3 未被误命中——精确匹配把结果收窄到了名字完全相等的进程。{forked} 标记表示该进程是 fork 出的子进程形态。
5.3 -p, --pid:按 PID 查询
--pid 直达目标,无歧义问题。实测:
witr --pid 7194 --short
实测回显:
systemd (pid 1) → sshd (pid 7194)
PID 可重复(--pid 1234 --pid 5678),也可与位置参数混用。查不存在的 PID 与查不存在进程名一样返回退出码 2:
witr --pid 4194305 ; echo "exit=$?"
实测回显:
no running process with pid 4194305
No matching process or service found. Please check your query or try a different name/port/PID.
For usage and options, run: witr --help
exit=2
5.4 -o, --port:按端口查询
给出端口号,witr 找到持有者后照常给出完整因果报告。实测(先在服务器上起一个临时 HTTP 服务再溯源):
python3 -m http.server 8141 --bind 0.0.0.0 &
witr --port 8141
实测回显:
Target : python3
Process : python3 (pid 744395)
User : root
Command : python3 -m http.server 8141 --bind 0.0.0.0
Started : just now (Sun 2026-10-25 09:26:12 +08:00)
Why It Exists :
systemd (pid 1) → ? (original parent exited) → python3 (pid 744395)
Source : session-17.scope (systemd)
Description : Session 17 of User root
Unit File : /run/systemd/transient/session-17.scope
Working Dir : /opt/data/quzuo/tmp/witr
Git Repo : quzuo (master)
Sockets : 0.0.0.0:8141 (TCP | LISTENING)
Warnings :
• Process is listening on a public interface
• Process is running as root
• Process sets LD_PRELOAD (potential library injection)
• Process sets DYLD_* variables (potential library injection): DYLD_LIBRARY_PATH
两个细节值得展开:其一,启动它的 shell 已退出,因果链如实标注 ? (original parent exited),来源落到 systemd 会话 scope(session-17.scope)——这是「前台临时进程」的典型溯源形态;其二,端口由 docker-proxy、socket 激活等代持时,witr 会继续回溯到背后真正的服务或容器(官方 README §8.1「Port → Container fallback」),这是它强于 ss -ltnp 的地方。查无主端口(root 身份下)返回退出码 2。
5.5 -f, --file:按文件查询
给出文件路径,找打开它的进程。实测(临时 HTTP 服务的访问日志正被 python3 持有):
witr --file /opt/data/quzuo/tmp/witr/http.log
实测回显:
Target : python3
Process : python3 (pid 744395)
User : root
Command : python3 -m http.server 8141 --bind 0.0.0.0
Started : just now (Sun 2026-10-25 09:26:12 +08:00)
Why It Exists :
systemd (pid 1) → ? (original parent exited) → python3 (pid 744395)
Source : session-17.scope (systemd)
Description : Session 17 of User root
Unit File : /run/systemd/transient/session-17.scope
Working Dir : /opt/data/quzuo/tmp/witr
Git Repo : quzuo (master)
Sockets : 0.0.0.0:8141 (TCP | LISTENING)
Warnings :
• Process is listening on a public interface
• Process is running as root
• Process sets LD_PRELOAD (potential library injection)
• Process sets DYLD_* variables (potential library injection): DYLD_LIBRARY_PATH
典型用途是包管理锁与日志文件,官方示例即 witr --file /var/lib/dpkg/lock(定位 apt 自动升级进程)。
5.6 -c, --container:容器内进程查询
--container 接受容器名、容器 ID(全量/短/最短 4 字符前缀)、镜像名或 compose 项目/服务名,跨 Docker、Podman、nerdctl、K8s(crictl)、containerd、Incus/LXC/LXD 及 FreeBSD jails 统一检索,直接落到容器主进程并给出镜像、发布端口、compose 文件与重启策略。实测(本机起一个演示负载后按容器名查询):
witr --container witr-v034-demo
实测回显:
Target : sleep
Process : sleep (pid 754786) {forked}
User : root
Security : AppArmor docker-default (enforce)
Container : docker: witr-v034-demo (id 85fcf40bcf7e)
Image : busybox
Command : sleep 3600
Started : just now (Sun 2026-10-25 09:27:41 +08:00)
Why It Exists :
systemd (pid 1) → ? (original parent exited) → containerd-shim-runc-v2 (pid 754761) → sleep (pid 754786)
Source : docker (container)
Working Dir : /
Warnings :
• Process is running as root
• Container has no healthcheck configured
按镜像名同样可查(witr --container busybox 实测命中同一进程,头部回显同上)。--verbose 可追加挂载明细。无对应运行时 CLI 时该旗标查不到目标(README §8.1 注明需要运行时 CLI 在 PATH 中)。
5.7 多目标混用规则
所有目标旗标可重复、可混合,结果按输入顺序输出并以 ----- [类型: 值] ----- 分隔。实测:
witr --pid 7194 --port 8141
实测回显(分段头,正文同单目标报告):
----- [pid: 7194] -----
Process : sshd (pid 7194)
Source : ssh.service (systemd)
----- [port: 8141] -----
Process : python3 (pid 744395)
Source : session-17.scope (systemd)
混用时退出码取「最严重」结果,严重度排序为:失败(2–5)> 无法溯源(6)> 有警告(1)> 干净(0)。
六、输出模式参数详解
6.1 标准报告(默认输出)
不带输出旗标即标准报告,五段式结构(以 5.4 的 witr --port 8141 回显为例):Target 查询目标 → Process 进程卡片(含重启计数、安全上下文)→ Why It Exists 因果链 → Source 主来源与单元文件 → 上下文与 Warnings。每段含义在《witr v0.3.4 介绍与选型指南》3.2 节有完整拆解,此处不重复。
6.2 -s, --short:单行祖先链
witr --port 8141 --short
实测回显:
systemd (pid 1) → ? (original parent exited) → python3 (pid 744395)
一行看全因果链,工单与聊天记录粘贴首选。与 --json 叠加时输出链上各节点的 {PID, Command, PPID, ParentExited} 列表。
6.3 -t, --tree:树形祖先图
witr --pid 7194 --tree
实测回显:
systemd (pid 1)
└─ sshd (pid 7194)
├─ sshd (pid 25397)
├─ sshd (pid 88186)
├─ sshd (pid 214186)
└─ sshd (pid 214891)
树中高亮目标进程并最多列 10 个子进程(官方说明),--json 叠加时输出 {Ancestry, Children} 两组。
6.4 --json:结构化输出(字段契约)
witr --port 8141 --json 实测回显(节选首尾,全文约 700 行 JSON):
{
"Target": {
"Type": "port",
"Value": "8141"
},
"ResolvedTarget": "python3",
"Process": {
"PID": 744395,
"PPID": 1,
"Command": "python3",
"Cmdline": "python3 -m http.server 8141 --bind 0.0.0.0",
"StartedAt": "2026-10-25T09:26:12.92+08:00",
"User": "root",
"WorkingDir": "/opt/data/quzuo/tmp/witr",
"GitRepo": "quzuo",
"GitBranch": "master",
"Sockets": [
{
"Inode": "2467781",
"Port": 8141,
"Address": "0.0.0.0",
"State": "LISTEN",
"Protocol": "TCP"
}
],
...
},
"RestartCount": 0,
"Ancestry": [...],
"Source": {
"Type": "systemd",
"Name": "session-17.scope",
"Description": "Session 17 of User root",
"UnitFile": "/run/systemd/transient/session-17.scope",
"Details": {}
},
"Warnings": [
"Process is listening on a public interface",
"Process is running as root",
"Process sets LD_PRELOAD (potential library injection)",
"Process sets DYLD_* variables (potential library injection): DYLD_LIBRARY_PATH"
],
"SocketInfo": {
"Port": 8141,
"State": "LISTEN",
"LocalAddr": "0.0.0.0",
"Explanation": "The process is actively waiting for incoming connections."
},
...
}
官方契约要点(README §7.3,查询日期 2026-10-25):字段名/含义/类型稳定、可安全忽略新增字段;字段顺序、空白与人类可读文案不在契约内;失败查询返回 {Target, Error}(歧义时附 Matches);破坏性变更只在 Release Notes 声明的版本发生。多目标时输出为按输入顺序排列的数组。
6.5 --env:进程环境变量
witr --pid 744395 --env
实测回显(节选,全文 161 行):
Process : python3 (pid 744395)
Command : python3 -m http.server 8141 --bind 0.0.0.0
Environment :
SHELL=/bin/bash
COLORTERM=truecolor
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
...
排查「这个服务怎么配错的」时直接看生效环境。macOS 上受 SIP 限制部分系统进程不可读(README 兼容矩阵 ⚠️ 项)。
6.6 --warnings:只看警告
witr --pid 7194 --warnings
实测回显:
Process : sshd (pid 7194)
Command : sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Warnings :
• Process is listening on a public interface
• Process is running as root
• Process is running from a suspicious working directory: /
巡检脚本用它做「体检摘要」。完整警告触发条件清单见《witr v0.3.4 介绍与选型指南》4.3 节。
6.7 --verbose:扩展明细
witr --pid 7194 --verbose
实测回显(在标准报告之上追加的部分):
CPU (avg) : 0.0%
Memory:
Virtual : 11.8 MB
Resident : 8.2 MB
Shared : 7.1 MB
I/O Statistics:
Read : 3.4 MB (413178 ops)
Write : 72.0 KB (5382 ops)
Open Files : 5 of 1024 (0%)
File Descriptors: 5/1024
0 -> /dev/null
1 -> socket:[51663]
2 -> socket:[51663]
3 -> socket:[23346]
4 -> socket:[26701]
Children of sshd (pid 7194):
├─ sshd (pid 25397)
├─ sshd (pid 88186)
├─ sshd (pid 214186)
└─ sshd (pid 214891)
6.8 --no-color 与输出环境
--no-color 关闭着色。witr 对非 tty 管道输出自动去色,实测中所有管道到文件的回显均无 ANSI 色码;重定向归档、CI 采集时无需额外处理,交互终端想强制无色再加 --no-color。
七、退出码契约(0–6)
witr 用退出码表达查询结论,脚本不解析文本即可分支(官方 README §7.1 原表,本机实测验证了 1/2/4 三种,0 因全机进程均带警告未复现):
| 码 | 含义 | 本机复现实例 |
|---|---|---|
| 0 | 干净:找到目标,无警告 | 本机未复现——这台服务器上的系统进程普遍触发「running as root / suspicious working directory」类警告;对巡检脚本而言 0 即全绿信号 |
| 1 | 找到但有警告 | witr --pid 7194(监听公网+root)实测 exit=1 |
| 2 | 未找到 | witr nginx-proc-not-exist 实测 exit=2 |
| 3 | 权限不足(需 sudo 重试) | 非 root 查他人进程时触发 |
| 4 | 输入无效或歧义 | witr sshd(多匹配)实测 exit=4 |
| 5 | 内部错误 | 未复现(官方定义) |
| 6 | 找到但无法溯源(原因写在警告里) | 原始父退出且无监管者场景 |
配套验证——直接用退出码分支的脚本实测(两次运行分别命中 1 与 2):
witr --pid 7194 --short > /dev/null 2>&1; rc=$?
case $rc in
0) echo "All clear" ;;
1) echo "Warnings detected" ;;
2) echo "Process not running" ;;
3) echo "Need elevated privileges" ;;
4) echo "Invalid input or ambiguous match" ;;
5) echo "Internal error" ;;
6) echo "Cannot tell what started it" ;;
esac
实测回显(第一次):
Warnings detected
把目标换成不存在的进程再跑,回显:
Process not running
💡 说明:退出码 1 不是失败——README 特别强调「found with warnings, not a failure」。把
witr接进 CI 时,对 1 的处理应是「记录警告并放行」,只有 2–5 才该让流水线失败。
八、TUI 交互模式与按键
8.1 进入方式
三种进入路径:无参数直接运行 witr;显式 witr -i;带目标进入并预聚焦 witr -i --pid 1234 / witr -i nginx / witr -i -o 5432 / witr -i -c web / witr -i -f /path(分别聚焦对应标签页或预填过滤词)。
8.2 四个标签页与功能
官方 README §4 的能力清单(查询日期 2026-10-25):Processes(实时进程列表+祖先树侧栏)、Ports(监听端口+持有进程侧栏,按 a 切 LISTEN/ALL)、Containers(跨 8 类运行时的容器统一列表+详情)、Locks(系统文件锁,按 a 切全量打开文件)。支持鼠标点选、列排序、过滤、进程详情下钻(环境变量/工作目录/套接字/文件上下文)、发信号(Kill/Terminate/Pause/Resume,发送前确认进程名)与 renice(Unix);主题随终端亮暗自适应,列表按 3 秒起步的自适应节奏自动刷新。
8.3 无终端环境的实测行为
脚本/管道中(无 tty)运行 TUI 会拒绝启动并要求给目标,实测:
witr -i < /dev/null ; echo "exit=$?"
实测回显:
Error: interactive mode needs a terminal; give a target to explain: a process name, --pid, --port, --file or --container
exit=4
同理,只给输出旗标不给目标(如 witr --json)也不进 TUI,实测:
Error: must specify --pid, --port, --file, --container, or a process name
exit=4
这两条让「误在 CI 里跑出 TUI 挂死」成为不可能,自动化场景可直接依赖退出码 4 兜底。
九、Shell 补全配置
四个 shell 的补全脚本均可生成(四个实测均通过)。按官方 README 推荐方式启用:
# bash
echo 'eval "$(witr completion bash)"' >> ~/.bashrc
source ~/.bashrc
# zsh
echo 'eval "$(witr completion zsh)"' >> ~/.zshrc
source ~/.zshrc
# fish(即时生效 + 永久化)
witr completion fish | source
witr completion fish > ~/.config/fish/completions/witr.fish
# powershell
witr completion powershell | Out-String | Invoke-Expression
witr completion bash 实测生成头部:
# bash completion V2 for witr -*- shell-script -*-
__witr_debug()
{
if [[ -n ${BASH_COMP_DEBUG_FILE-} ]]; then
echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
fi
}
fish 与 powershell 的生成同样正常(头部 # fish completion for witr、# powershell completion for witr 均实测确认)。补全覆盖全部旗标,输入 witr --pid 后 Tab 即可补全旗标名。
十、生产脚本集成模板
两个可直接落地的模板,均在本机验证。
模板一:发布前端口占用检查(退出码分支)
#!/bin/bash
# deploy-guard.sh —— 上线前确认业务端口未被占用
PORT=8141
witr --port $PORT --short > /dev/null 2>&1
rc=$?
case $rc in
2) echo "Port $PORT free, go" ;;
0|1) echo "Port $PORT occupied:"; witr --port $PORT --short ;;
3) echo "Need sudo to inspect port $PORT" ;;
*) echo "witr exit=$rc, check manually" ;;
esac
实测(端口被占时执行):
Port 8141 occupied:
systemd (pid 1) → ? (original parent exited) → python3 (pid 744395)
模板二:jq 解析 JSON 做巡检清单
witr --pid 7194 --json | jq -r '"\(.ResolvedTarget) | source=\(.Source.Name) | warnings=\(.Warnings | length)"'
实测回显:
sshd | source=ssh.service | warnings=3
JSON 字段契约保证这两个模板跨版本稳定;版本升级后重跑一次验证即可(升级操作见安装指南第八章)。
十一、常见问题(FAQ)
Q1:--json、--short 等输出旗标可以同时给吗?
输出形态旗标之间是互斥选择(同时给出时按内部优先级取一种);--json 特殊,可与 -s、-t、--warnings、--env 叠加成四种缩减 JSON。与目标旗标、--no-color、-i 的组合不受限。
Q2:为什么 witr --port 8141 报的启动链里有 ? (original parent exited)?
表示启动该进程的原始父进程(通常是 shell)已退出,witr 拒绝把收养者(PID 1)冒认为启动者,只标注断点并继续追溯其后链路。有 systemd 单元/容器/会话 scope 等监管证据时,Source 仍会给出(如 5.4 实测的 session-17.scope);毫无证据时来源为 unknown、退出码 6。
Q3:普通用户运行和 root 有什么差别?
非 root 看不到其他用户进程的详情:端口场景只返回归属用户名(官方表述「it belongs to postgres」),进程卡片缺省。需要完整信息 sudo witr ...。退出码 3 即「权限不足请提权重试」。
Q4:--container 查不到我知道在跑的负载?
按顺序排查:目标运行时 CLI 是否在 PATH(docker/podman/nerdctl/crictl…);给的标识是否属于该运行时管理的对象;容器 ID 前缀是否至少 4 个字符。跨运行时的对象(如同一镜像在 Podman 与 Docker 各跑一个)会分别命中,用 --json 的 Runtime 字段区分。
Q5:管道里输出怎么没有颜色?
witr 检测到输出非 tty 时自动去色,属预期行为。交互终端想强制无色加 --no-color;想让管道输出保留颜色用于归档高亮,目前版本以 tty 直写为准。
十二、参考链接
- 官方 README Flags 章节:https://github.com/pranshuparmar/witr#6-flags--options
- 官方 README Output Behavior(退出码与 JSON 契约):https://github.com/pranshuparmar/witr#7-output-behavior
- 官方 README TUI 章节:https://github.com/pranshuparmar/witr#4-interactive-mode-tui
- 本专栏认知篇:《witr v0.3.4 介绍与选型指南》(https://www.quzuo.net/document/76Q10ziexrrH)
- 本专栏安装篇:《Ubuntu 24.04 安装 witr v0.3.4 指南》(https://www.quzuo.net/document/SZHKmhS1Kns9)
- 本专栏命令实操篇:《witr v0.3.4 常用 CLI 命令详解》。