6 个版本
使用旧的 Rust 2015
0.1.5 | 2017年6月22日 |
---|---|
0.1.4 | 2017年6月22日 |
#11 in #命令行
85KB
356 行
tracetree
运行一个进程,ptrace 它及其所有子进程,并在结束时打印整个进程树。
目前仅支持 Linux。
示例
以文本格式将进程树打印到 stdout
$ tracetree /bin/bash -c '/bin/sleep 1; /bin/sleep 1'
16665 bash -c /bin/sleep 1; /bin/sleep 1 [2.004s]
16666 sleep 1 [1.001s]
16667 sleep 1 [1.000s]
以 JSON 格式将进程树打印到 output.json
$ tracetree -f json -o output.json /bin/bash -c '/bin/sleep 1; /bin/sleep 1'
$ python -mjson.tool output.json
{
"children": [
{
"children": [],
"cmdline": [
"/bin/sleep",
"1"
],
"ended": "2017-06-22T06:28:58.960384212-04:00",
"pid": 16727,
"started": "2017-06-22T06:28:57.959636824-04:00"
},
{
"children": [],
"cmdline": [
"/bin/sleep",
"1"
],
"ended": "2017-06-22T06:28:59.961990469-04:00",
"pid": 16728,
"started": "2017-06-22T06:28:58.960849779-04:00"
}
],
"cmdline": [
"/bin/bash",
"-c",
"/bin/sleep 1; /bin/sleep 1"
],
"ended": "2017-06-22T06:28:59.962407641-04:00",
"pid": 16726,
"started": "2017-06-22T06:28:57.958836370-04:00"
}
可以使用此 网络可视化工具 查看JSON输出:
依赖项
~13MB
~240K SLoC