version 1.56, 2018/10/05 18:56:57 |
version 1.57, 2018/11/17 23:10:08 |
|
|
int y_idlecursor; |
int y_idlecursor; |
int y_procs; |
int y_procs; |
extern int ncpu; |
extern int ncpu; |
|
extern int ncpuonline; |
extern int combine_cpus; |
extern int combine_cpus; |
extern struct process_select ps; |
extern struct process_select ps; |
|
|
|
|
int |
int |
display_resize(void) |
display_resize(void) |
{ |
{ |
int display_lines; |
int cpu_lines, display_lines; |
int cpu_lines = (combine_cpus ? 1 : ncpu); |
|
|
|
|
ncpuonline = getncpuonline(); |
|
cpu_lines = (combine_cpus ? 1 : ncpuonline); |
y_mem = 2 + cpu_lines; |
y_mem = 2 + cpu_lines; |
y_header = 4 + cpu_lines; |
y_header = 4 + cpu_lines; |
y_procs = 5 + cpu_lines; |
y_procs = 5 + cpu_lines; |
|
|
/* if operating in "dumb" mode, we only need one line */ |
/* if operating in "dumb" mode, we only need one line */ |
display_lines = smart_terminal ? screen_length - y_procs : 1; |
display_lines = smart_terminal ? screen_length - y_procs : 1; |
|
|
y_idlecursor = y_message = 3 + (combine_cpus ? 1 : ncpu); |
y_idlecursor = y_message = 3 + (combine_cpus ? 1 : ncpuonline); |
if (screen_length <= y_message) |
if (screen_length <= y_message) |
y_idlecursor = y_message = screen_length - 1; |
y_idlecursor = y_message = screen_length - 1; |
|
|
|
|
} |
} |
|
|
void |
void |
i_cpustates(int64_t *ostates) |
i_cpustates(int64_t *ostates, int *online) |
{ |
{ |
int i, first, cpu; |
int i, first, cpu, cpu_line; |
double value; |
double value; |
int64_t *states; |
int64_t *states; |
char **names, *thisname; |
char **names, *thisname; |
|
|
} |
} |
memset(values, 0, num_cpustates * sizeof(*values)); |
memset(values, 0, num_cpustates * sizeof(*values)); |
for (cpu = 0; cpu < ncpu; cpu++) { |
for (cpu = 0; cpu < ncpu; cpu++) { |
|
if (!online[cpu]) |
|
continue; |
names = cpustate_names; |
names = cpustate_names; |
states = ostates + (CPUSTATES * cpu); |
states = ostates + (CPUSTATES * cpu); |
i = 0; |
i = 0; |
|
|
first = 0; |
first = 0; |
move(2, 0); |
move(2, 0); |
clrtoeol(); |
clrtoeol(); |
printwp("%-3d CPUs: ", ncpu); |
printwp("%-3d CPUs: ", ncpuonline); |
|
|
while ((thisname = *names++) != NULL) { |
while ((thisname = *names++) != NULL) { |
if (*thisname != '\0') { |
if (*thisname != '\0') { |
value = values[i++] / ncpu; |
value = values[i++] / ncpuonline; |
/* if percentage is >= 1000, print it as 100% */ |
/* if percentage is >= 1000, print it as 100% */ |
printwp((value >= 1000 ? "%s%4.0f%% %s" : |
printwp((value >= 1000 ? "%s%4.0f%% %s" : |
"%s%4.1f%% %s"), first++ == 0 ? "" : ", ", |
"%s%4.1f%% %s"), first++ == 0 ? "" : ", ", |
|
|
} |
} |
return; |
return; |
} |
} |
for (cpu = 0; cpu < ncpu; cpu++) { |
for (cpu = cpu_line = 0; cpu < ncpu; cpu++) { |
|
/* skip if offline */ |
|
if (!online[cpu]) |
|
continue; |
|
|
/* now walk thru the names and print the line */ |
/* now walk thru the names and print the line */ |
names = cpustate_names; |
names = cpustate_names; |
first = 0; |
first = 0; |
states = ostates + (CPUSTATES * cpu); |
states = ostates + (CPUSTATES * cpu); |
|
|
if (screen_length > 2 + cpu || !smart_terminal) { |
if (screen_length > 2 + cpu_line || !smart_terminal) { |
move(2 + cpu, 0); |
move(2 + cpu_line, 0); |
clrtoeol(); |
clrtoeol(); |
addstrp(cpustates_tag(cpu)); |
addstrp(cpustates_tag(cpu)); |
|
|
|
|
} |
} |
} |
} |
putn(); |
putn(); |
|
cpu_line++; |
} |
} |
} |
} |
} |
} |