diff --git a/ps/common.h b/ps/common.h index c60aa316..fde39321 100644 --- a/ps/common.h +++ b/ps/common.h @@ -165,6 +165,7 @@ makEXT(TTY) makEXT(TTY_NAME) makEXT(TTY_NUMBER) makEXT(UTILIZATION) +makEXT(UTILIZATION_C) makEXT(VM_DATA) makEXT(VM_RSS_LOCKED) makEXT(VM_RSS) diff --git a/ps/global.c b/ps/global.c index 82ced68a..f973f47c 100644 --- a/ps/global.c +++ b/ps/global.c @@ -146,6 +146,7 @@ makREL(TTY) makREL(TTY_NAME) makREL(TTY_NUMBER) makREL(UTILIZATION) +makREL(UTILIZATION_C) makREL(VM_DATA) makREL(VM_RSS_LOCKED) makREL(VM_RSS) diff --git a/ps/output.c b/ps/output.c index f37419e9..ba6d638b 100644 --- a/ps/output.c +++ b/ps/output.c @@ -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}, diff --git a/ps/ps.1 b/ps/ps.1 index a6275fd3..7c7aff46 100644 --- a/ps/ps.1 +++ b/ps/ps.1 @@ -1211,12 +1211,23 @@ cumulative CPU time in seconds (alias .BR times ). T} +cuc %CUC T{ +The CPU utilization of a process, including dead children, in an extended "##.###" format. +(see also +.BR %cpu , +.BR c , +.BR cp , +.BR cuu , +.BR pcpu ). +T} + cuu %CUU T{ The CPU utilization of a process in an extended "##.###" format. (see also .BR %cpu , .BR c , .BR cp , +.BR cuc , .BR pcpu ). T}