diff options
author | Allan Jude <allanjude@FreeBSD.org> | 2015-09-05 17:02:01 +0000 |
---|---|---|
committer | Allan Jude <allanjude@FreeBSD.org> | 2015-09-05 17:02:01 +0000 |
commit | 474b62b876718890adf24759cc7c15fa5cb7778e (patch) | |
tree | 4806bed030076ad0f4a32b484130a17d3ddf5b58 /usr.bin/procstat/procstat_rlimit.c | |
parent | 4569e7cfe25b562e09629471fc645262bc726f8c (diff) | |
download | src-474b62b876718890adf24759cc7c15fa5cb7778e.tar.gz src-474b62b876718890adf24759cc7c15fa5cb7778e.zip |
Introduce libxo to procstat(1)
Reviewed by: rodrigc, bapt
Approved by: marcel (mentor)
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D2446
Notes
Notes:
svn path=/head/; revision=287486
Diffstat (limited to 'usr.bin/procstat/procstat_rlimit.c')
-rw-r--r-- | usr.bin/procstat/procstat_rlimit.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/usr.bin/procstat/procstat_rlimit.c b/usr.bin/procstat/procstat_rlimit.c index f7f67af1e0ff..5e7d12efc55f 100644 --- a/usr.bin/procstat/procstat_rlimit.c +++ b/usr.bin/procstat/procstat_rlimit.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2011 Mikolaj Golub + * Copyright (c) 2015 Allan Jude <allanjude@freebsd.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,15 +94,33 @@ procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp) int i; if (!hflag) { - printf("%5s %-16s %-16s %16s %16s\n", + xo_emit("{T:/%5s %-16s %-16s %16s %16s}\n", "PID", "COMM", "RLIMIT", "SOFT ", "HARD "); } + xo_emit("{ek:process_id/%5d}{e:command/%-16s/%s}", kipp->ki_pid, + kipp->ki_comm); for (i = 0; i < RLIM_NLIMITS; i++) { if (procstat_getrlimit(prstat, kipp, i, &rlimit) == -1) return; - printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm, + xo_emit("{dk:process_id/%5d} {d:command/%-16s} " + "{d:rlimit_param/%-16s} ", kipp->ki_pid, kipp->ki_comm, rlimit_param[i].name); - printf("%16s ", humanize_rlimit(i, rlimit.rlim_cur)); - printf("%16s\n", humanize_rlimit(i, rlimit.rlim_max)); + + xo_open_container(rlimit_param[i].name); + if (rlimit.rlim_cur == RLIM_INFINITY) + xo_emit("{e:soft_limit/infinity}"); + else + xo_emit("{e:soft_limit/%U}", rlimit.rlim_cur); + + if (rlimit.rlim_max == RLIM_INFINITY) + xo_emit("{e:hard_limit/infinity}"); + else + xo_emit("{e:hard_limit/%U}", rlimit.rlim_max); + xo_close_container(rlimit_param[i].name); + + xo_emit("{d:rlim_cur/%16s} ", + humanize_rlimit(i, rlimit.rlim_cur)); + xo_emit("{d:rlim_max/%16s}\n", + humanize_rlimit(i, rlimit.rlim_max)); } } |