Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "program name" field is missing in the JSON format #298

Closed
MalKeshar opened this issue Apr 9, 2024 · 3 comments
Closed

The "program name" field is missing in the JSON format #298

MalKeshar opened this issue Apr 9, 2024 · 3 comments

Comments

@MalKeshar
Copy link

Tested with 2.9, 2.10 atop versions.
Usual output has this field, but json output has not.

# atop -P PRC 1 1 | head -5
RESET
PRC xxx 1712653998 2024/04/09 05:13:18 334667 1 (systemd) S 100 7240 5353 0 120 0 0 2 0 1 y 507746534 () 646 -1 -1 54037 3978
PRC xxx 1712653998 2024/04/09 05:13:18 334667 2 (kthreadd) S 100 6 0 0 120 0 0 6 0 2 y 19616548 () 0 -2 -2 958 0
PRC xxx 1712653998 2024/04/09 05:13:18 334667 3 (rcu_gp) I 100 0 0 -20 100 0 0 0 0 3 y 0 () 0 -2 -2 2 0
PRC xxx 1712653998 2024/04/09 05:13:18 334667 4 (rcu_par_gp) I 100 0 0 -20 100 0 0 0 0 4 y 0 () 0 -2 -2 2 0

# atop -X -J PRC 1 1 | jq '.PRC |= map(@json)' | sed 's/"{/{/g; s/}"/}/g; s/\\//g' | head -10
{
  "host": "xxx",
  "timestamp": 1712654001,
  "elapsed": 334670,
  "PRC": [
    {"pid":1,"utime":7240,"stime":5353,"nice":0,"prio":120,"curcpu":2,"tgid":1,"isproc":1,"rundelay":507,"blkdelay":6460,"nvcsw":54037,"nivcsw":3978,"sleepavg":0},
    {"pid":2,"utime":6,"stime":0,"nice":0,"prio":120,"curcpu":6,"tgid":2,"isproc":1,"rundelay":19,"blkdelay":0,"nvcsw":958,"nivcsw":0,"sleepavg":0},
    {"pid":3,"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,"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,"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 -P PRM 1 1 | head -5
RESET
PRM xxx 1712654015 2024/04/09 05:13:35 334684 1 (systemd) S 4096 167272 10820 816 167272 10820 38047 167 8100 21116 1032 0 1 y 0 0 -1 -1 -1 -1
PRM xxx 1712654015 2024/04/09 05:13:35 334684 2 (kthreadd) S 4096 0 0 0 0 0 0 0 0 0 0 0 2 y 0 0 -2 -2 -2 -2
PRM xxx 1712654015 2024/04/09 05:13:35 334684 3 (rcu_gp) I 4096 0 0 0 0 0 0 0 0 0 0 0 3 y 0 0 -2 -2 -2 -2
PRM xxx 1712654015 2024/04/09 05:13:35 334684 4 (rcu_par_gp) I 4096 0 0 0 0 0 0 0 0 0 0 0 4 y 0 0 -2 -2 -2 -2

# atop -X -J PRM 1 1 | jq '.PRM |= map(@json)' | sed 's/"{/{/g; s/}"/}/g; s/\\//g' | head -10
{
  "host": "xxx",
  "timestamp": 1712654025,
  "elapsed": 334694,
  "PRM": [
    {"pid":1,"vmem":167272,"rmem":10820,"vexec":816,"vgrow":167272,"rgrow":10820,"minflt":38047,"majflt":167,"vlibs":8100,"vdata":21116,"vstack":1032,"vlock":0,"vswap":0,"pmem":0},
    {"pid":2,"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,"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,"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,"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},
@N-Storm
Copy link

N-Storm commented Apr 9, 2024

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.

@MalKeshar
Copy link
Author

@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},

@Atoptool
Copy link
Owner

Process name added to JSON output via PR #299 (renamed 'name' to 'cmd' and removed parenthesis).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants