The `ff_traffic` and `ff_top`'s `-P` argument support bigger than 38.

This commit is contained in:
fengbojiang 2021-01-24 22:02:08 +08:00
parent 73bdce4162
commit 9324004395
2 changed files with 10 additions and 4 deletions

View File

@ -57,6 +57,7 @@ int main(int argc, char **argv)
float sys, usr, idle;
float psys, pusr, pidle;
unsigned long loops, ploops;
int title_line = 40;
ff_ipc_init();
@ -76,6 +77,8 @@ int main(int argc, char **argv)
ff_ipc_exit();
return -1;
}
if (max_proc_id > title_line - 2)
title_line = max_proc_id + 2;
break;
case 'd':
delay = atoi(optarg) ?: 1;
@ -99,7 +102,7 @@ int main(int argc, char **argv)
return -1;
}
if (i % 40 == 0) {
if (i % title_line == 0) {
printf("|---------|---------|---------|---------------|\n");
printf("|%9s|%9s|%9s|%15s|\n", "idle", "sys", "usr", "loop");
printf("|---------|---------|---------|---------------|\n");
@ -117,7 +120,7 @@ int main(int argc, char **argv)
/*
* get and show cpu usage from proc_id to max_proc_id.
*/
if (i % (40 / (max_proc_id - proc_id + 2)) == 0) {
if (i % (title_line / (max_proc_id - proc_id + 2)) == 0) {
printf("|---------|---------|---------|"
"---------|---------------|\n");
printf("|%9s|%9s|%9s|%9s|%15s|\n",

View File

@ -57,6 +57,7 @@ int main(int argc, char **argv)
int proc_id = 0, max_proc_id = -1;
uint64_t rxp, rxb, txp, txb;
uint64_t prxp, prxb, ptxp, ptxb;
int title_line = 40;
ff_ipc_init();
@ -77,6 +78,8 @@ int main(int argc, char **argv)
ff_ipc_exit();
return -1;
}
if (max_proc_id > title_line - 2)
title_line = max_proc_id + 2;
break;
case 'd':
delay = atoi(optarg) ?: 1;
@ -140,7 +143,7 @@ int main(int argc, char **argv)
return -1;
}
if (i % 40 == 0) {
if (i % title_line == 0) {
printf("|--------------------|--------------------|");
printf("--------------------|--------------------|\n");
printf("|%20s|%20s|%20s|%20s|\n", "rx packets", "rx bytes",
@ -161,7 +164,7 @@ int main(int argc, char **argv)
/*
* get and show traffic from proc_id to max_proc_id.
*/
if (i % (40 / (max_proc_id - proc_id + 2)) == 0) {
if (i % (title_line / (max_proc_id - proc_id + 2)) == 0) {
printf("|---------|--------------------|--------------------|"
"--------------------|--------------------|\n");
printf("|%9s|%20s|%20s|%20s|%20s|\n",