variable-width %CPU,PPID,PID

This commit is contained in:
albert 2005-01-06 00:13:12 +00:00
parent 1010c1d281
commit 95cc4c37bb
3 changed files with 41 additions and 4 deletions

8
NEWS
View File

@ -1,12 +1,14 @@
procps-3.2.4 --> procps-3.2.5 procps-3.2.4 --> procps-3.2.5
display problem on 64-bit systems fixed display problem on 64-bit systems fixed #287947
top: variable-width PID and PPID
top: variable-width %CPU rh110555
sysctl: better error messages sysctl: better error messages
ps: security labels can contain any printable ASCII ps: security labels can contain any printable ASCII
top: help and version message on stdout, with exit(0) #283541 top: help and version message on stdout, with exit(0) #283541
ps: SIGTSTP from ^Z shouldn't print bug email address ps: SIGTSTP and SIGTTOU shouldn't print bug email address #246123
slabtop: compile with glibc 2.2.17 (and older, likely) slabtop: compile with glibc 2.2.17 (and older, likely)
slabtop: fix overflow on huge NUMA boxes slabtop: fix overflow on huge NUMA boxes #264640
procps-3.2.3 --> procps-3.2.4 procps-3.2.3 --> procps-3.2.4

View File

@ -564,6 +564,7 @@ int main(int argc, char *argv[]){
case 0: case 0:
case SIGINT: /* ^C */ case SIGINT: /* ^C */
case SIGTSTP: /* ^Z */ case SIGTSTP: /* ^Z */
case SIGTTOU: /* see stty(1) man page */
case SIGQUIT: /* ^\ */ case SIGQUIT: /* ^\ */
case SIGPROF: /* profiling */ case SIGPROF: /* profiling */
case SIGKILL: /* can not catch */ case SIGKILL: /* can not catch */

36
top.c
View File

@ -77,6 +77,7 @@ static unsigned page_to_kb_shift;
/* SMP Irix/Solaris mode */ /* SMP Irix/Solaris mode */
static int Cpu_tot; static int Cpu_tot;
static double pcpu_max_value; // usually 99.9, for %CPU display
/* assume no IO-wait stats, overridden if linux 2.5.41 */ /* assume no IO-wait stats, overridden if linux 2.5.41 */
static const char *States_fmts = STATES_line2x4; static const char *States_fmts = STATES_line2x4;
@ -1551,6 +1552,39 @@ static void before (char *me)
i >>= 1; i >>= 1;
page_to_kb_shift++; page_to_kb_shift++;
} }
Fieldstab[P_CPU].head = " %CPU";
Fieldstab[P_CPU].fmts = " %#4.1f";
pcpu_max_value = 99.9;
Fieldstab[P_CPN].head = " P";
Fieldstab[P_CPN].fmts = " %1u";
if(smp_num_cpus>9){
Fieldstab[P_CPN].head = " P";
Fieldstab[P_CPN].fmts = " %2u";
if(Rc.mode_irixps){
// this will do for up to 999; hopefully a 1024-node box
// will have at least 2.4% idle time
pcpu_max_value = 9999.0;
Fieldstab[P_CPU].fmts = " %4.0f";
}
}
if(smp_num_cpus>99){
Fieldstab[P_CPN].head = " P";
Fieldstab[P_CPN].fmts = " %3u";
}
if(smp_num_cpus>999){
Fieldstab[P_CPN].head = " P";
Fieldstab[P_CPN].fmts = " %4u";
}
unsigned pid_digits = get_pid_digits();
if(pid_digits<4) pid_digits=4;
static char pid_fmt[6];
snprintf(pid_fmt, sizeof pid_fmt, " %%%uu", pid_digits);
Fieldstab[P_PID].fmts = pid_fmt;
Fieldstab[P_PID].head = " PID" + 10 - pid_digits;
Fieldstab[P_PPD].fmts = pid_fmt;
Fieldstab[P_PPD].head = " PPID" + 10 - pid_digits;
} }
@ -2941,7 +2975,7 @@ static void task_show (const WIN_t *q, const proc_t *p)
break; break;
case P_CPU: case P_CPU:
{ float u = (float)p->pcpu * Frame_tscale; { float u = (float)p->pcpu * Frame_tscale;
if (99.9 < u) u = 99.9; if (u > pcpu_max_value) u = pcpu_max_value;
MKCOL(u); MKCOL(u);
} }
break; break;