Closed MalKeshar closed 4 months ago
Indeed, "parsable output" (-P flag) prints "process name" fields (ps->gen.name) after PIDs, but json.c output misses those. Was easy to fix. Submitted PR #299, which fixes the issue.
@N-Storm, thanks!
$ atop -X -J PRC 1 1 | jq '.PRC |= map(@json)' | sed 's/"{/{/g; s/}"/}/g; s/\\//g' | head -10
{
"host": "xxx",
"timestamp": 1712744378,
"elapsed": 425047,
"PRC": [
{"pid":1,"name":"(systemd)","utime":9223,"stime":6772,"nice":0,"prio":120,"curcpu":9,"tgid":1,"isproc":1,"rundelay":623,"blkdelay":6460,"nvcsw":68260,"nivcsw":4648,"sleepavg":0},
{"pid":2,"name":"(kthreadd)","utime":7,"stime":0,"nice":0,"prio":120,"curcpu":1,"tgid":2,"isproc":1,"rundelay":20,"blkdelay":0,"nvcsw":1168,"nivcsw":0,"sleepavg":0},
{"pid":3,"name":"(rcu_gp)","utime":0,"stime":0,"nice":-20,"prio":100,"curcpu":0,"tgid":3,"isproc":1,"rundelay":0,"blkdelay":0,"nvcsw":2,"nivcsw":0,"sleepavg":0},
{"pid":4,"name":"(rcu_par_gp)","utime":0,"stime":0,"nice":-20,"prio":100,"curcpu":0,"tgid":4,"isproc":1,"rundelay":0,"blkdelay":0,"nvcsw":2,"nivcsw":0,"sleepavg":0},
{"pid":6,"name":"(kworker/0:0H-ev)","utime":0,"stime":0,"nice":-20,"prio":100,"curcpu":0,"tgid":6,"isproc":1,"rundelay":0,"blkdelay":0,"nvcsw":4,"nivcsw":0,"sleepavg":0},
$ atop -X -J PRM 1 1 | jq '.PRM |= map(@json)' | sed 's/"{/{/g; s/}"/}/g; s/\\//g' | head -10
{
"host": "xxx",
"timestamp": 1712744394,
"elapsed": 425063,
"PRM": [
{"pid":1,"name":"(systemd)","vmem":167272,"rmem":10836,"vexec":816,"vgrow":167272,"rgrow":10836,"minflt":44763,"majflt":167,"vlibs":8100,"vdata":21116,"vstack":1032,"vlock":0,"vswap":0,"pmem":0},
{"pid":2,"name":"(kthreadd)","vmem":0,"rmem":0,"vexec":0,"vgrow":0,"rgrow":0,"minflt":0,"majflt":0,"vlibs":0,"vdata":0,"vstack":0,"vlock":0,"vswap":0,"pmem":0},
{"pid":3,"name":"(rcu_gp)","vmem":0,"rmem":0,"vexec":0,"vgrow":0,"rgrow":0,"minflt":0,"majflt":0,"vlibs":0,"vdata":0,"vstack":0,"vlock":0,"vswap":0,"pmem":0},
{"pid":4,"name":"(rcu_par_gp)","vmem":0,"rmem":0,"vexec":0,"vgrow":0,"rgrow":0,"minflt":0,"majflt":0,"vlibs":0,"vdata":0,"vstack":0,"vlock":0,"vswap":0,"pmem":0},
{"pid":6,"name":"(kworker/0:0H-ev)","vmem":0,"rmem":0,"vexec":0,"vgrow":0,"rgrow":0,"minflt":0,"majflt":0,"vlibs":0,"vdata":0,"vstack":0,"vlock":0,"vswap":0,"pmem":0},
Process name added to JSON output via PR #299 (renamed 'name' to 'cmd' and removed parenthesis).
Tested with 2.9, 2.10 atop versions. Usual output has this field, but json output has not.