Skip to content

Commit 75ed3f9

Browse files
committed
json: Print cgroups'a name when using -J and the label
Before: ``` % atop -X -J PRG 1 | jq { "pid": 514432, "name": "(php-fpm8.2)", "state": "E", "ruid": 69963, "rgid": 69963, "tgid": 514432, "nthr": 1, "st": "-E", "exitcode": 0, "btime": "1700730621", "cmdline": "(php-fpm: pool www )", "ppid": 514430, "nthrrun": 0, "nthrslpi": 0, "nthrslpu": 0, "nthridle": 0, "euid": 0, "egid": 0, "elaps": "1299", "isproc": 1, "cid": "-" }, ``` After: ``` { "pid": 526057, "name": "(php-fpm8.2)", "state": "S", "ruid": 70019, "rgid": 70019, "tgid": 526057, "nthr": 1, "st": "-E", "exitcode": 0, "btime": "1700731393", "cmdline": "(php-fpm: master process (/etc/php-fpm/php-fpm.conf) )", "ppid": 1, "nthrrun": 0, "nthrslpi": 1, "nthrslpu": 0, "nthridle": 0, "euid": 70019, "egid": 70019, "elaps": "0", "isproc": 1, "cid": "-", "cgroup": "/u000000096" }, ``` Signed-off-by: Donatas Abraitis <[email protected]>
1 parent 8cadc35 commit 75ed3f9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

json.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,8 @@ static void json_print_PRG(char *hp, struct sstat *ss, struct tstat *ps, int nac
989989
"\"egid\": %d, "
990990
"\"elaps\": \"%ld\", "
991991
"\"isproc\": %d, "
992-
"\"cid\": \"%.19s\"}",
992+
"\"cid\": \"%.19s\", "
993+
"\"cgroup\": \"%s\"}",
993994
ps->gen.pid,
994995
ps->gen.name,
995996
ps->gen.state,
@@ -1010,7 +1011,8 @@ static void json_print_PRG(char *hp, struct sstat *ss, struct tstat *ps, int nac
10101011
ps->gen.egid,
10111012
ps->gen.elaps,
10121013
!!ps->gen.isproc, /* convert to boolean */
1013-
ps->gen.utsname[0] ? ps->gen.utsname:"-");
1014+
ps->gen.utsname[0] ? ps->gen.utsname:"-",
1015+
ps->gen.cgpath[0] ? ps->gen.cgpath:"-");
10141016
}
10151017

10161018
printf("]");

0 commit comments

Comments
 (0)