ps: plus for symmetry 'UTILIZATION_C' is newest format

This commit just compliments a change referenced below
by providing the value which includes reaped children.

[ as an aside, it looks like ps only includes reaped ]
[ children values under an obscure BSD or GNU option ]

[ so, this change is possibly of even more relevance ]

Reference(s):
. Mar, 2022 - added %CUU
commit 2ac72e2e80

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2022-03-06 00:00:00 -06:00
committed by Craig Small
parent cfa5538832
commit 53917334d0
4 changed files with 26 additions and 1 deletions

View File

@@ -1339,7 +1339,7 @@ setREL1(EXE)
return max_rightward-rightward;
}
/* %cpu utilization over task lifetime */
/* %cpu utilization over task lifetime, as ##.### format */
static int pr_utilization(char *restrict const outbuf, const proc_t *restrict const pp){
double cu;
setREL1(UTILIZATION)
@@ -1350,6 +1350,17 @@ setREL1(UTILIZATION)
return snprintf(outbuf, COLWID, "%#.3f", cu);
}
/* %cpu utilization (plus dead children) over task lifetime, as ##.### format */
static int pr_utilization_c(char *restrict const outbuf, const proc_t *restrict const pp){
double cu;
setREL1(UTILIZATION_C)
cu = rSv(UTILIZATION_C, real, pp);
/* this check is really just for us (the ps program) since we will be very
short lived and the library might reflect 100% or even more utilization */
if (cu > 99.0) cu = 99.999;
return snprintf(outbuf, COLWID, "%#.3f", cu);
}
/************************* Systemd stuff ********************************/
static int pr_sd_unit(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(SD_UNIT)
@@ -1635,6 +1646,7 @@ static const format_struct format_array[] = { /*
{"cputime", "TIME", pr_time, PIDS_TIME_ALL, 8, DEC, ET|RIGHT}, /*time*/
{"cputimes", "TIME", pr_times, PIDS_TIME_ALL, 8, LNX, ET|RIGHT}, /*time*/
{"ctid", "CTID", pr_nop, PIDS_noop, 5, SUN, ET|RIGHT}, // resource contracts?
{"cuc", "%CUC", pr_utilization_c, PIDS_UTILIZATION_C, 6, XXX, AN|RIGHT},
{"cursig", "CURSIG", pr_nop, PIDS_noop, 6, DEC, AN|RIGHT},
{"cutime", "-", pr_nop, PIDS_TICS_USER_C, 1, LNX, AN|RIGHT},
{"cuu", "%CUU", pr_utilization, PIDS_UTILIZATION, 6, XXX, AN|RIGHT},