From c2595c36db7ae42b39250d68777cb06617666fd2 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 10 Dec 2022 11:29:00 +0100 Subject: [PATCH] Try to avoid displaying healthy metrics values in "red" (#177) Percentage values are now displayed in specific colors when they are greater or lower than a predefined limit depending on the metric's meaning. This means that, e.g. CPU %idle value will no longer be printed in red if the CPU is actually idle. Specific colors are now used when: * values are greater than 90% (or lower than 10%), * values are in the range 75% to 90% (or 25% to 10%). This is probably still not perfect but should eliminate many questions. Signed-off-by: Sebastien GODARD --- common.c | 45 +++++++++++------ common.h | 12 +++-- iostat.c | 15 +++--- mpstat.c | 30 ++++++------ pidstat.c | 10 ++-- pr_stats.c | 140 +++++++++++++++++++++++++++-------------------------- tapestat.c | 2 +- 7 files changed, 141 insertions(+), 113 deletions(-) diff --git a/common.c b/common.c index 3b7fdcd..c94cabf 100644 --- a/common.c +++ b/common.c @@ -58,8 +58,8 @@ unsigned long hz; unsigned int kb_shift; /* Colors strings */ -char sc_percent_high[MAX_SGR_LEN] = C_BOLD_RED; -char sc_percent_low[MAX_SGR_LEN] = C_BOLD_MAGENTA; +char sc_percent_warn[MAX_SGR_LEN] = C_BOLD_MAGENTA; +char sc_percent_xtreme[MAX_SGR_LEN] = C_BOLD_RED; char sc_zero_int_stat[MAX_SGR_LEN] = C_LIGHT_BLUE; char sc_int_stat[MAX_SGR_LEN] = C_BOLD_BLUE; char sc_item_name[MAX_SGR_LEN] = C_LIGHT_GREEN; @@ -1207,8 +1207,8 @@ void init_colors(void) * or set to "auto" and stdout is not a terminal: * Unset color strings. */ - strcpy(sc_percent_high, ""); - strcpy(sc_percent_low, ""); + strcpy(sc_percent_warn, ""); + strcpy(sc_percent_xtreme, ""); strcpy(sc_zero_int_stat, ""); strcpy(sc_int_stat, ""); strcpy(sc_item_name, ""); @@ -1233,11 +1233,13 @@ void init_colors(void) continue; switch (*p) { - case 'H': - snprintf(sc_percent_high, MAX_SGR_LEN, "\e[%sm", p + 2); - break; case 'M': - snprintf(sc_percent_low, MAX_SGR_LEN, "\e[%sm", p + 2); + case 'W': + snprintf(sc_percent_warn, MAX_SGR_LEN, "\e[%sm", p + 2); + break; + case 'X': + case 'H': + snprintf(sc_percent_xtreme, MAX_SGR_LEN, "\e[%sm", p + 2); break; case 'Z': snprintf(sc_zero_int_stat, MAX_SGR_LEN, "\e[%sm", p + 2); @@ -1303,7 +1305,7 @@ void cprintf_unit(int unit, int wi, double dval) * @num Number of values to print. * @wi Output width. *************************************************************************** -*/ + */ void cprintf_u64(int unit, int num, int wi, ...) { int i; @@ -1421,12 +1423,15 @@ void cprintf_f(int unit, int num, int wi, int wd, ...) * IN: * @human Set to > 0 if a percent sign (%) shall be displayed after * the value. + * @xtrem Set to non 0 to indicate that extreme (low or high) values + * should be displayed in specific color if beyond predefined + * limits. * @num Number of values to print. * @wi Output width. * @wd Number of decimal places. *************************************************************************** */ -void cprintf_pc(int human, int num, int wi, int wd, ...) +void cprintf_xpc(int human, int xtrem, int num, int wi, int wd, ...) { int i; double val, lim = 0.005; @@ -1465,11 +1470,23 @@ void cprintf_pc(int human, int num, int wi, int wd, ...) for (i = 0; i < num; i++) { val = va_arg(args, double); - if (val >= PERCENT_LIMIT_HIGH) { - printf("%s", sc_percent_high); + if ((xtrem == XHIGH) && (val >= PERCENT_LIMIT_XHIGH)) { + printf("%s", sc_percent_xtreme); + } + else if ((xtrem == XHIGH) && (val >= PERCENT_LIMIT_HIGH)) { + printf("%s", sc_percent_warn); + } + else if ((xtrem == XLOW) && (val <= PERCENT_LIMIT_XLOW)) { + printf("%s", sc_percent_xtreme); + } + else if ((xtrem == XLOW0) && (val <= PERCENT_LIMIT_XLOW) && (val >= lim)) { + printf("%s", sc_percent_xtreme); + } + else if ((xtrem == XLOW) && (val <= PERCENT_LIMIT_LOW)) { + printf("%s", sc_percent_warn); } - else if (val >= PERCENT_LIMIT_LOW) { - printf("%s", sc_percent_low); + else if ((xtrem == XLOW0) && (val <= PERCENT_LIMIT_LOW) && (val >= lim)) { + printf("%s", sc_percent_warn); } else if (((wd > 0) && (val < lim)) || ((wd == 0) && (val <= 0.5))) { /* "Round half to even" law */ diff --git a/common.h b/common.h index fc8a1a0..fcf1189 100644 --- a/common.h +++ b/common.h @@ -206,8 +206,14 @@ extern char persistent_name_type[MAX_FILE_LEN]; #define C_LIGHT_BLUE "\e[34;22m" #define C_NORMAL "\e[0m" +#define PERCENT_LIMIT_XHIGH 90.0 #define PERCENT_LIMIT_HIGH 75.0 -#define PERCENT_LIMIT_LOW 50.0 +#define PERCENT_LIMIT_LOW 25.0 +#define PERCENT_LIMIT_XLOW 10.0 + +#define XHIGH 1 +#define XLOW 2 +#define XLOW0 3 #define MAX_SGR_LEN 16 @@ -270,8 +276,8 @@ void cprintf_f (int, int, int, int, ...); void cprintf_in (int, char *, char *, int); -void cprintf_pc - (int, int, int, int, ...); +void cprintf_xpc + (int, int, int, int, int, ...); void cprintf_s (int, char *, char *); void cprintf_u64 diff --git a/iostat.c b/iostat.c index b490bc1..cf4897d 100644 --- a/iostat.c +++ b/iostat.c @@ -977,7 +977,7 @@ void write_plain_cpu_stat(int curr, unsigned long long deltot_jiffies) printf("avg-cpu: %%user %%nice %%system %%iowait %%steal %%idle\n"); printf(" "); - cprintf_pc(DISPLAY_UNIT(flags), 6, 7, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 5, 7, 2, ll_sp_value(st_cpu[!curr]->cpu_user, st_cpu[curr]->cpu_user, deltot_jiffies), ll_sp_value(st_cpu[!curr]->cpu_nice, st_cpu[curr]->cpu_nice, deltot_jiffies), /* @@ -989,7 +989,8 @@ void write_plain_cpu_stat(int curr, unsigned long long deltot_jiffies) st_cpu[curr]->cpu_sys + st_cpu[curr]->cpu_softirq + st_cpu[curr]->cpu_hardirq, deltot_jiffies), ll_sp_value(st_cpu[!curr]->cpu_iowait, st_cpu[curr]->cpu_iowait, deltot_jiffies), - ll_sp_value(st_cpu[!curr]->cpu_steal, st_cpu[curr]->cpu_steal, deltot_jiffies), + ll_sp_value(st_cpu[!curr]->cpu_steal, st_cpu[curr]->cpu_steal, deltot_jiffies)); + cprintf_xpc(DISPLAY_UNIT(flags), XLOW, 1, 7, 2, (st_cpu[curr]->cpu_idle < st_cpu[!curr]->cpu_idle) ? 0.0 : ll_sp_value(st_cpu[!curr]->cpu_idle, st_cpu[curr]->cpu_idle, deltot_jiffies)); @@ -1229,7 +1230,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, * %util * Again: Ticks in milliseconds. */ - cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, xds->util / 10.0 / (double) n); + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 6, 2, xds->util / 10.0 / (double) n); } else { if ((hpart == 1) || !hpart) { @@ -1246,7 +1247,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, cprintf_f(NO_UNIT, 1, 8, 2, S_VALUE(ioj->rd_merges, ioi->rd_merges, itv)); /* %rrqm */ - cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XLOW0, 1, 6, 2, xios->rrqm_pc); /* r_await */ cprintf_f(NO_UNIT, 1, 7, 2, @@ -1269,7 +1270,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, cprintf_f(NO_UNIT, 1, 8, 2, S_VALUE(ioj->wr_merges, ioi->wr_merges, itv)); /* %wrqm */ - cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XLOW0, 1, 6, 2, xios->wrqm_pc); /* w_await */ cprintf_f(NO_UNIT, 1, 7, 2, @@ -1292,7 +1293,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, cprintf_f(NO_UNIT, 1, 8, 2, S_VALUE(ioj->dc_merges, ioi->dc_merges, itv)); /* %drqm */ - cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XLOW0, 1, 6, 2, xios->drqm_pc); /* d_await */ cprintf_f(NO_UNIT, 1, 7, 2, @@ -1321,7 +1322,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, else { n = 1; } - cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, xds->util / 10.0 / (double) n); + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 6, 2, xds->util / 10.0 / (double) n); } } diff --git a/mpstat.c b/mpstat.c index b1999d9..53ceb43 100644 --- a/mpstat.c +++ b/mpstat.c @@ -720,7 +720,7 @@ void write_plain_cpu_stats(int dis, unsigned long long deltot_jiffies, int prev, * If the CPU is tickless then there is no change in CPU values * but the sum of values is not zero. */ - cprintf_pc(NO_UNIT, 10, 7, 2, + cprintf_xpc(NO_UNIT, FALSE, 10, 7, 2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0); printf("\n"); @@ -728,7 +728,7 @@ void write_plain_cpu_stats(int dis, unsigned long long deltot_jiffies, int prev, } } - cprintf_pc(NO_UNIT, 10, 7, 2, + cprintf_xpc(NO_UNIT, XHIGH, 9, 7, 2, (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ? 0.0 : ll_sp_value(scp->cpu_user - scp->cpu_guest, @@ -750,11 +750,12 @@ void write_plain_cpu_stats(int dis, unsigned long long deltot_jiffies, int prev, ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies), ll_sp_value(scp->cpu_guest_nice, - scc->cpu_guest_nice, deltot_jiffies), - (scc->cpu_idle < scp->cpu_idle) ? - 0.0 : - ll_sp_value(scp->cpu_idle, - scc->cpu_idle, deltot_jiffies)); + scc->cpu_guest_nice, deltot_jiffies)); + cprintf_xpc(NO_UNIT, XLOW, 1, 7, 2, + (scc->cpu_idle < scp->cpu_idle) ? + 0.0 : + ll_sp_value(scp->cpu_idle, + scc->cpu_idle, deltot_jiffies)); printf("\n"); } } @@ -998,7 +999,7 @@ void write_plain_node_stats(int dis, unsigned long long deltot_jiffies, if (!deltot_jiffies) { /* All CPU in node are tickless and/or offline */ - cprintf_pc(NO_UNIT, 10, 7, 2, + cprintf_xpc(NO_UNIT, FALSE, 10, 7, 2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0); printf("\n"); @@ -1006,7 +1007,7 @@ void write_plain_node_stats(int dis, unsigned long long deltot_jiffies, } } - cprintf_pc(NO_UNIT, 10, 7, 2, + cprintf_xpc(NO_UNIT, XHIGH, 9, 7, 2, (snc->cpu_user - snc->cpu_guest) < (snp->cpu_user - snp->cpu_guest) ? 0.0 : ll_sp_value(snp->cpu_user - snp->cpu_guest, @@ -1028,11 +1029,12 @@ void write_plain_node_stats(int dis, unsigned long long deltot_jiffies, ll_sp_value(snp->cpu_guest, snc->cpu_guest, deltot_jiffies), ll_sp_value(snp->cpu_guest_nice, - snc->cpu_guest_nice, deltot_jiffies), - (snc->cpu_idle < snp->cpu_idle) ? - 0.0 : - ll_sp_value(snp->cpu_idle, - snc->cpu_idle, deltot_jiffies)); + snc->cpu_guest_nice, deltot_jiffies)); + cprintf_xpc(NO_UNIT, XLOW, 1, 7, 2, + (snc->cpu_idle < snp->cpu_idle) ? + 0.0 : + ll_sp_value(snp->cpu_idle, + snc->cpu_idle, deltot_jiffies)); printf("\n"); } } diff --git a/pidstat.c b/pidstat.c index 57469bd..c48f460 100644 --- a/pidstat.c +++ b/pidstat.c @@ -1343,7 +1343,7 @@ int write_pid_task_all_stats(int prev, int curr, int dis, pstp = plist->pstats[prev]; if (DISPLAY_CPU(actflag)) { - cprintf_pc(DISPLAY_UNIT(pidflag), 5, 7, 2, + cprintf_xpc(DISPLAY_UNIT(pidflag), XHIGH, 5, 7, 2, (pstc->utime - pstc->gtime) < (pstp->utime - pstp->gtime) ? 0.0 : SP_VALUE(pstp->utime - pstp->gtime, @@ -1368,7 +1368,7 @@ int write_pid_task_all_stats(int prev, int curr, int dis, cprintf_u64(DISPLAY_UNIT(pidflag) ? UNIT_KILOBYTE : NO_UNIT, 2, 7, (unsigned long long) pstc->vsz, (unsigned long long) pstc->rss); - cprintf_pc(DISPLAY_UNIT(pidflag), 1, 6, 2, + cprintf_xpc(DISPLAY_UNIT(pidflag), XHIGH, 1, 6, 2, tlmkb ? SP_VALUE(0, pstc->rss, tlmkb) : 0.0); } @@ -1559,7 +1559,7 @@ int write_pid_task_cpu_stats(int prev, int curr, int dis, int disp_avg, pstc = plist->pstats[curr]; pstp = plist->pstats[prev]; - cprintf_pc(DISPLAY_UNIT(pidflag), 5, 7, 2, + cprintf_xpc(DISPLAY_UNIT(pidflag), XHIGH, 5, 7, 2, (pstc->utime - pstc->gtime) < (pstp->utime - pstp->gtime) ? 0.0 : SP_VALUE(pstp->utime - pstp->gtime, @@ -1741,7 +1741,7 @@ int write_pid_task_memory_stats(int prev, int curr, int dis, int disp_avg, (double) plist->total_vsz / plist->rt_asum_count, (double) plist->total_rss / plist->rt_asum_count); - cprintf_pc(DISPLAY_UNIT(pidflag), 1, 6, 2, + cprintf_xpc(DISPLAY_UNIT(pidflag), XHIGH, 1, 6, 2, tlmkb ? SP_VALUE(0, plist->total_rss / plist->rt_asum_count, tlmkb) : 0.0); @@ -1751,7 +1751,7 @@ int write_pid_task_memory_stats(int prev, int curr, int dis, int disp_avg, (unsigned long long) pstc->vsz, (unsigned long long) pstc->rss); - cprintf_pc(DISPLAY_UNIT(pidflag), 1, 6, 2, + cprintf_xpc(DISPLAY_UNIT(pidflag), XHIGH, 1, 6, 2, tlmkb ? SP_VALUE(0, pstc->rss, tlmkb) : 0.0); } diff --git a/pr_stats.c b/pr_stats.c index 048ffb5..0040f94 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -236,11 +236,11 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr, * but the sum of values is not zero. * %user, %nice, %system, %iowait, %steal, ..., %idle */ - cprintf_pc(DISPLAY_UNIT(flags), 5, 9, 2, - 0.0, 0.0, 0.0, 0.0, 0.0); + cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 5, 9, 2, + 0.0, 0.0, 0.0, 0.0, 0.0); if (DISPLAY_CPU_DEF(a->opt_flags)) { - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, 100.0); + cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2, 100.0); printf("\n"); } /* @@ -248,8 +248,8 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr, * %irq, %soft, %guest, %gnice. */ else if (DISPLAY_CPU_ALL(a->opt_flags)) { - cprintf_pc(DISPLAY_UNIT(flags), 5, 9, 2, - 0.0, 0.0, 0.0, 0.0, 100.0); + cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 5, 9, 2, + 0.0, 0.0, 0.0, 0.0, 100.0); printf("\n"); } continue; @@ -257,39 +257,41 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr, } if (DISPLAY_CPU_DEF(a->opt_flags)) { - cprintf_pc(DISPLAY_UNIT(flags), 6, 9, 2, - ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies), - ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies), - ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq, - scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq, - deltot_jiffies), - ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies), - ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies), - scc->cpu_idle < scp->cpu_idle ? - 0.0 : - ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies)); + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 5, 9, 2, + ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies), + ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies), + ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq, + scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq, + deltot_jiffies), + ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies), + ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies)); + cprintf_xpc(DISPLAY_UNIT(flags), XLOW, 1, 9, 2, + scc->cpu_idle < scp->cpu_idle ? + 0.0 : + ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies)); printf("\n"); } else if (DISPLAY_CPU_ALL(a->opt_flags)) { - cprintf_pc(DISPLAY_UNIT(flags), 10, 9, 2, - (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ? - 0.0 : - ll_sp_value(scp->cpu_user - scp->cpu_guest, - scc->cpu_user - scc->cpu_guest, deltot_jiffies), - (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ? - 0.0 : - ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice, - scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies), - ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies), - ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies), - ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies), - ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies), - ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies), - ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies), - ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies), - scc->cpu_idle < scp->cpu_idle ? - 0.0 : - ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies)); + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 9, 9, 2, + (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ? + 0.0 : + ll_sp_value(scp->cpu_user - scp->cpu_guest, + scc->cpu_user - scc->cpu_guest, deltot_jiffies), + (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ? + 0.0 : + ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice, + scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies), + ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies), + ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies), + ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies), + ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies), + ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies), + ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies), + ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies)); + cprintf_xpc(DISPLAY_UNIT(flags), XLOW, 1, 9, 2, + scc->cpu_idle < scp->cpu_idle ? + 0.0 : + ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies)); printf("\n"); } } @@ -479,7 +481,7 @@ __print_funct_t print_paging_stats(struct activity *a, int prev, int curr, S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv), S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv), S_VALUE(spp->pgsteal, spc->pgsteal, itv)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XLOW0, 1, 9, 2, (spc->pgscan_kswapd + spc->pgscan_direct - spp->pgscan_kswapd - spp->pgscan_direct) ? SP_VALUE(spp->pgsteal, spc->pgsteal, @@ -594,7 +596,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg (unsigned long long) smc->frmkb, (unsigned long long) smc->availablekb, (unsigned long long) (smc->tlmkb - nousedmem)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, smc->tlmkb ? SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) : 0.0); @@ -602,7 +604,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg (unsigned long long) smc->bufkb, (unsigned long long) smc->camkb, (unsigned long long) smc->comkb); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, (smc->tlmkb + smc->tlskb) ? SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0); @@ -647,7 +649,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg (double) avg_frmkb / avg_count, (double) avg_availablekb / avg_count, (double) smc->tlmkb - ((double) nousedmem / avg_count)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, smc->tlmkb ? SP_VALUE((double) (nousedmem / avg_count), smc->tlmkb, smc->tlmkb) : 0.0); @@ -655,7 +657,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg (double) avg_bufkb / avg_count, (double) avg_camkb / avg_count, (double) avg_comkb / avg_count); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, (smc->tlmkb + smc->tlskb) ? SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb) : 0.0); @@ -694,13 +696,13 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg cprintf_u64(unit, 2, 9, (unsigned long long) smc->frskb, (unsigned long long) (smc->tlskb - smc->frskb)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, smc->tlskb ? SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0); cprintf_u64(unit, 1, 9, (unsigned long long) smc->caskb); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2, (smc->tlskb - smc->frskb) ? SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0); @@ -719,7 +721,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg (double) avg_frskb / avg_count, ((double) avg_tlskb / avg_count) - ((double) avg_frskb / avg_count)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, avg_tlskb ? SP_VALUE((double) avg_frskb / avg_count, (double) avg_tlskb / avg_count, @@ -727,7 +729,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg : 0.0); cprintf_f(unit, 1, 9, 0, (double) avg_caskb / avg_count); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2, (avg_tlskb != avg_frskb) ? SP_VALUE(0.0, (double) avg_caskb / avg_count, ((double) avg_tlskb / avg_count) - @@ -1141,7 +1143,7 @@ __print_funct_t print_disk_stats(struct activity *a, int prev, int curr, cprintf_f(NO_UNIT, 2, 9, 2, S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0, xds.await); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, xds.util / 10.0); if (DISPLAY_PRETTY(flags)) { cprintf_in(IS_STR, " %s", dev_name, 0); @@ -1229,7 +1231,7 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr, S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv), S_VALUE(sndp->multicast, sndc->multicast, itv)); ifutil = compute_ifutil(sndc, rxkb, txkb); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, ifutil); + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, ifutil); if (DISPLAY_PRETTY(flags)) { cprintf_in(IS_STR, " %s", sndc->interface, 0); } @@ -2290,7 +2292,7 @@ void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg) if (dispavg) { /* Display average values */ cprintf_f(NO_UNIT, 1, 9, 2, (double) avg_temp[i] / avg_count); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, (avg_temp_max[i] - avg_temp_min[i]) ? ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100 : 0.0); @@ -2298,7 +2300,7 @@ void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg) else { /* Display instantaneous values */ cprintf_f(NO_UNIT, 1, 9, 2, spc->temp); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, (spc->temp_max - spc->temp_min) ? (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 : 0.0); @@ -2406,7 +2408,7 @@ void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg) if (dispavg) { /* Display average values */ cprintf_f(NO_UNIT, 1, 9, 2, (double) avg_in[i] / avg_count); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, (avg_in_max[i] - avg_in_min[i]) ? ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100 : 0.0); @@ -2414,7 +2416,7 @@ void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg) else { /* Display instantaneous values */ cprintf_f(NO_UNIT, 1, 9, 2, spc->in); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, (spc->in_max - spc->in_min) ? (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 : 0.0); @@ -2509,7 +2511,7 @@ void stub_print_huge_stats(struct activity *a, int curr, int dispavg) cprintf_u64(unit, 2, 9, (unsigned long long) smc->frhkb, (unsigned long long) (smc->tlhkb - smc->frhkb)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, smc->tlhkb ? SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0); cprintf_u64(unit, 2, 9, @@ -2528,7 +2530,7 @@ void stub_print_huge_stats(struct activity *a, int curr, int dispavg) (double) avg_frhkb / avg_count, ((double) avg_tlhkb / avg_count) - ((double) avg_frhkb / avg_count)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, avg_tlhkb ? SP_VALUE((double) avg_frhkb / avg_count, (double) avg_tlhkb / avg_count, @@ -2842,7 +2844,7 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int prev, int cu unit < 0 ? (double) sfc->f_bfree / 1024 / 1024 : (double) sfc->f_bfree, unit < 0 ? (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024 : (double) (sfc->f_blocks - sfc->f_bfree)); - cprintf_pc(DISPLAY_UNIT(flags), 2, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 2, 9, 2, /* f_blocks is not zero. But test it anyway ;-) */ sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks) : 0.0, @@ -2851,7 +2853,7 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int prev, int cu cprintf_u64(NO_UNIT, 2, 9, (unsigned long long) sfc->f_ffree, (unsigned long long) (sfc->f_files - sfc->f_ffree)); - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files) : 0.0); cprintf_in(IS_STR, " %s\n", dev_name, 0); @@ -3181,7 +3183,7 @@ void stub_print_psicpu_stats(struct activity *a, int prev, int curr, int dispavg if (!dispavg) { /* Display instantaneous values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) psic->some_acpu_10 / 100, (double) psic->some_acpu_60 / 100, (double) psic->some_acpu_300 / 100); @@ -3193,7 +3195,7 @@ void stub_print_psicpu_stats(struct activity *a, int prev, int curr, int dispavg } else { /* Display average values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) s_avg10 / (avg_count * 100), (double) s_avg60 / (avg_count * 100), (double) s_avg300 / (avg_count * 100)); @@ -3202,7 +3204,7 @@ void stub_print_psicpu_stats(struct activity *a, int prev, int curr, int dispavg s_avg10 = s_avg60 = s_avg300 = 0; } - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv)); printf("\n"); } @@ -3275,7 +3277,7 @@ void stub_print_psiio_stats(struct activity *a, int prev, int curr, int dispavg, if (!dispavg) { /* Display instantaneous "some" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) psic->some_aio_10 / 100, (double) psic->some_aio_60 / 100, (double) psic->some_aio_300 / 100); @@ -3287,7 +3289,7 @@ void stub_print_psiio_stats(struct activity *a, int prev, int curr, int dispavg, } else { /* Display average "some" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) s_avg10 / (avg_count * 100), (double) s_avg60 / (avg_count * 100), (double) s_avg300 / (avg_count * 100)); @@ -3296,12 +3298,12 @@ void stub_print_psiio_stats(struct activity *a, int prev, int curr, int dispavg, s_avg10 = s_avg60 = s_avg300 = 0; } - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, ((double) psic->some_io_total - psip->some_io_total) / (100 * itv)); if (!dispavg) { /* Display instantaneous "full" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) psic->full_aio_10 / 100, (double) psic->full_aio_60 / 100, (double) psic->full_aio_300 / 100); @@ -3313,7 +3315,7 @@ void stub_print_psiio_stats(struct activity *a, int prev, int curr, int dispavg, } else { /* Display average "full" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) f_avg10 / (avg_count * 100), (double) f_avg60 / (avg_count * 100), (double) f_avg300 / (avg_count * 100)); @@ -3322,7 +3324,7 @@ void stub_print_psiio_stats(struct activity *a, int prev, int curr, int dispavg, f_avg10 = f_avg60 = f_avg300 = 0; } - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, ((double) psic->full_io_total - psip->full_io_total) / (100 * itv)); printf("\n"); } @@ -3395,7 +3397,7 @@ void stub_print_psimem_stats(struct activity *a, int prev, int curr, int dispavg if (!dispavg) { /* Display instantaneous "some" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) psic->some_amem_10 / 100, (double) psic->some_amem_60 / 100, (double) psic->some_amem_300 / 100); @@ -3407,7 +3409,7 @@ void stub_print_psimem_stats(struct activity *a, int prev, int curr, int dispavg } else { /* Display average "some" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) s_avg10 / (avg_count * 100), (double) s_avg60 / (avg_count * 100), (double) s_avg300 / (avg_count * 100)); @@ -3416,12 +3418,12 @@ void stub_print_psimem_stats(struct activity *a, int prev, int curr, int dispavg s_avg10 = s_avg60 = s_avg300 = 0; } - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv)); if (!dispavg) { /* Display instantaneous "full" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) psic->full_amem_10 / 100, (double) psic->full_amem_60 / 100, (double) psic->full_amem_300 / 100); @@ -3433,7 +3435,7 @@ void stub_print_psimem_stats(struct activity *a, int prev, int curr, int dispavg } else { /* Display average "full" values */ - cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 9, 2, (double) f_avg10 / (avg_count * 100), (double) f_avg60 / (avg_count * 100), (double) f_avg300 / (avg_count * 100)); @@ -3442,7 +3444,7 @@ void stub_print_psimem_stats(struct activity *a, int prev, int curr, int dispavg f_avg10 = f_avg60 = f_avg300 = 0; } - cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2, ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv)); printf("\n"); } diff --git a/tapestat.c b/tapestat.c index e0f2769..fcc4e8b 100644 --- a/tapestat.c +++ b/tapestat.c @@ -464,7 +464,7 @@ void tape_write_stats(struct calc_stats *tape, int i) : tape->kbytes_read_per_second / divisor, DISPLAY_UNIT(flags) ? tape->kbytes_written_per_second : tape->kbytes_written_per_second / divisor); - cprintf_pc(DISPLAY_UNIT(flags), 3, 4, 0, + cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 3, 4, 0, (double) tape->read_pct_wait, (double) tape->write_pct_wait, (double) tape->all_pct_wait); -- 2.40.0