]> granicus.if.org Git - sysstat/commitdiff
sar: Display values in human readable format
authorSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 17 Nov 2016 09:58:03 +0000 (10:58 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 17 Nov 2016 09:58:03 +0000 (10:58 +0100)
Take into account new "--human" option to display values in human
readable format.
Functions cprintf_f() cprintf_u64() are modified to add the unit after
the value if requested.
Only a few options are concerned for sar.
Other commands are updated too, but the option will be activated in
separate patches.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
cifsiostat.c
common.c
common.h
iostat.c
mpstat.c
pidstat.c
pr_stats.c
tapestat.c

index 704e9df02b1cafca24e92bc75b4db8ed03707007..17714be16d3f98f88696f108d1cc16c8c98b6a31 100644 (file)
@@ -438,13 +438,13 @@ void write_cifs_stat(int curr, unsigned long long itv, int fctr,
        }
 
        /*       rB/s   wB/s   fo/s   fc/s   fd/s*/
-       cprintf_f(2, 12, 2,
+       cprintf_f(-1, 2, 12, 2,
                  S_VALUE(ionj->rd_bytes, ioni->rd_bytes, itv) / fctr,
                  S_VALUE(ionj->wr_bytes, ioni->wr_bytes, itv) / fctr);
-       cprintf_f(2, 9, 2,
+       cprintf_f(-1, 2, 9, 2,
                  S_VALUE(ionj->rd_ops, ioni->rd_ops, itv),
                  S_VALUE(ionj->wr_ops, ioni->wr_ops, itv));
-       cprintf_f(3, 12, 2,
+       cprintf_f(-1, 3, 12, 2,
                  S_VALUE(ionj->fopens, ioni->fopens, itv),
                  S_VALUE(ionj->fcloses, ioni->fcloses, itv),
                  S_VALUE(ionj->fdeletes, ioni->fdeletes, itv));
index 603b62d253494c536427bdc8805c1c6d4b4356a0..77d8d34d22a025e8e7ed1862fe714d4bc148f2ee 100644 (file)
--- a/common.c
+++ b/common.c
 #define _(string) (string)
 #endif
 
+/* Units (sectors, Bytes, kilobytes, etc.) */
+char units[] = {'s', 'B', 'k', 'M', 'G', 'T', 'P', '?'};
+#define NR_UNITS       8
+
 /* Number of ticks per second */
 unsigned int hz;
 /* Number of bit shifts to convert pages to kB */
@@ -1103,20 +1107,22 @@ void init_colors(void)
 
 /*
  ***************************************************************************
- * Print 64 bit unsigned values using colors.
+ * Print 64 bit unsigned values using colors, possibly followed by a unit.
  *
  * IN:
+ * @unit       Default values unit. -1 if no unit should be displayed.
  * @num                Number of values to print.
- * @width      Output width.
+ * @wi         Output width.
  ***************************************************************************
 */
-void cprintf_u64(int num, int width, ...)
+void cprintf_u64(int unit, int num, int wi, ...)
 {
-       int i;
+       int i, u;
        uint64_t val;
+       double dval;
        va_list args;
 
-       va_start(args, width);
+       va_start(args, wi);
 
        for (i = 0; i < num; i++) {
                val = va_arg(args, unsigned long long);
@@ -1126,8 +1132,41 @@ void cprintf_u64(int num, int width, ...)
                else {
                        printf("%s", sc_int_stat);
                }
-               printf(" %*"PRIu64, width, val);
+               if (unit < 0) {
+                       printf(" %*"PRIu64, wi, val);
+               }
+               else {
+                       if (wi < 5) {
+                               /* E.g. 1.34M */
+                               wi = 5;
+                       }
+                       u = unit;
+                       if (!u) {
+                               /* Value is a number of sectors. Convert it to Bytes */
+                               val *= 512;
+                               u++;
+                       }
+                       if (val < 1024) {
+                               printf(" %*"PRIu64, wi - 1, val);
+                       }
+                       else {
+                               dval = (double) val;
+                               while (dval >= 1024) {
+                                       dval /= 1024;
+                                       u++;
+                               }
+                               printf(" %*.*f", wi - 1, 2, dval);
+                       }
+               }
                printf("%s", sc_normal);
+
+               if (unit >= 0) {
+                       /* Display unit */
+                       if (u >= NR_UNITS) {
+                               u = NR_UNITS;
+                       }
+                       printf("%c", units[u]);
+               }
        }
 
        va_end(args);
@@ -1162,17 +1201,19 @@ void cprintf_x(int num, int width, ...)
 
 /*
  ***************************************************************************
- * Print "double" statistics values using colors.
+ * Print "double" statistics values using colors, possibly followed by a
+ * unit.
  *
  * IN:
+ * @unit       Default values unit. -1 if no unit should be displayed.
  * @num                Number of values to print.
  * @width      Output width.
  * @wd         Number of decimal places.
  ***************************************************************************
 */
-void cprintf_f(int num, int wi, int wd, ...)
+void cprintf_f(int unit, int num, int wi, int wd, ...)
 {
-       int i;
+       int i, u;
        double val;
        va_list args;
 
@@ -1187,8 +1228,37 @@ void cprintf_f(int num, int wi, int wd, ...)
                else {
                        printf("%s", sc_int_stat);
                }
-               printf(" %*.*f", wi, wd, val);
+
+               if (unit < 0) {
+                       printf(" %*.*f", wi, wd, val);
+               }
+               else {
+                       if (wi < 5) {
+                               /* E.g. 1.34M */
+                               wi = 5;
+                       }
+                       u = unit;
+                       if (!u) {
+                               /* Value is a number of sectors. Convert it to kilobytes */
+                               val /= 2;
+                               u = 2;
+                       }
+                       while (val >= 1024) {
+                               val /= 1024;
+                               u++;
+                       }
+                       printf(" %*.*f", wi - 1, 2, val);
+               }
+
                printf("%s", sc_normal);
+
+               if (unit >= 0) {
+                       /* Display unit */
+                       if (u >= NR_UNITS) {
+                               u = NR_UNITS - 1;
+                       }
+                       printf("%c", units[u]);
+               }
        }
 
        va_end(args);
index 6b58aa5887e71d03c66258e63ecd9d474859a300..14711fdbc1115420404bbe4f2c574f709d5b79a5 100644 (file)
--- a/common.h
+++ b/common.h
@@ -223,7 +223,7 @@ int count_bits
 int count_csvalues
        (int, char **);
 void cprintf_f
-       (int, int, int, ...);
+       (int, int, int, int, ...);
 void cprintf_in
        (int, char *, char *, int);
 void cprintf_pc
@@ -231,7 +231,7 @@ void cprintf_pc
 void cprintf_s
        (int, char *, char *);
 void cprintf_u64
-       (int, int, ...);
+       (int, int, int, ...);
 void cprintf_x
        (int, int, ...);
 char *device_name
index 21db950eaf86dae986e980694ffb438c99974e2c..6178a56465f6492a401d32f9091a0a1199a2cfaa 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -1008,20 +1008,20 @@ void write_plain_ext_stat(unsigned long long itv, int fctr,
        }
 
        /*       rrq/s wrq/s   r/s   w/s  rsec  wsec  rqsz  qusz await r_await w_await svctm %util */
-       cprintf_f(2, 8, 2,
+       cprintf_f(-1, 2, 8, 2,
                  S_VALUE(ioj->rd_merges, ioi->rd_merges, itv),
                  S_VALUE(ioj->wr_merges, ioi->wr_merges, itv));
-       cprintf_f(2, 7, 2,
+       cprintf_f(-1, 2, 7, 2,
                  S_VALUE(ioj->rd_ios, ioi->rd_ios, itv),
                  S_VALUE(ioj->wr_ios, ioi->wr_ios, itv));
-       cprintf_f(4, 8, 2,
+       cprintf_f(-1, 4, 8, 2,
                  S_VALUE(ioj->rd_sectors, ioi->rd_sectors, itv) / fctr,
                  S_VALUE(ioj->wr_sectors, ioi->wr_sectors, itv) / fctr,
                  xds->arqsz,
                  S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
-       cprintf_f(3, 7, 2, xds->await, r_await, w_await);
+       cprintf_f(-1, 3, 7, 2, xds->await, r_await, w_await);
        /* The ticks output is biased to output 1000 ticks per second */
-       cprintf_f(1, 6, 2, xds->svctm);
+       cprintf_f(-1, 1, 6, 2, xds->svctm);
        /*
         * Again: Ticks in milliseconds.
         * In the case of a device group (option -g), shi->used is the number of
@@ -1181,12 +1181,12 @@ void write_plain_basic_stat(unsigned long long itv, int fctr,
        else {
                cprintf_in(IS_STR, "%-13s", devname, 0);
        }
-       cprintf_f(1, 8, 2,
+       cprintf_f(-1, 1, 8, 2,
                  S_VALUE(ioj->rd_ios + ioj->wr_ios, ioi->rd_ios + ioi->wr_ios, itv));
-       cprintf_f(2, 12, 2,
+       cprintf_f(-1, 2, 12, 2,
                  S_VALUE(ioj->rd_sectors, ioi->rd_sectors, itv) / fctr,
                  S_VALUE(ioj->wr_sectors, ioi->wr_sectors, itv) / fctr);
-       cprintf_u64(2, 10,
+       cprintf_u64(-1, 2, 10,
                    (unsigned long long) rd_sec / fctr,
                    (unsigned long long) wr_sec / fctr);
        printf("\n");
index 6c38e00d8f169b4af9183b9ad632ff58c9392f28..bd29bec612a2c95ac416e0e882ff0a57930fdf85 100644 (file)
--- a/mpstat.c
+++ b/mpstat.c
@@ -604,7 +604,7 @@ void write_plain_isumcpu_stats(int dis, unsigned long long itv, int prev, int cu
                printf("%-11s", curr_string);
                cprintf_in(IS_STR, " %s", " all", 0);
                /* Print total number of interrupts among all cpu */
-               cprintf_f(1, 9, 2,
+               cprintf_f(-1, 1, 9, 2,
                          S_VALUE(st_irq[prev]->irq_nr, st_irq[curr]->irq_nr, itv));
                printf("\n");
        }
@@ -634,7 +634,7 @@ void write_plain_isumcpu_stats(int dis, unsigned long long itv, int prev, int cu
                                 */
                                printf("%-11s", curr_string);
                                cprintf_in(IS_INT, " %4d", "", cpu - 1);
-                               cprintf_f(1, 9, 2, 0.0);
+                               cprintf_f(-1, 1, 9, 2, 0.0);
                                printf("\n");
                        }
                        continue;
@@ -648,12 +648,12 @@ void write_plain_isumcpu_stats(int dis, unsigned long long itv, int prev, int cu
 
                if (!pc_itv) {
                        /* This is a tickless CPU: Value displayed is 0.00 */
-                       cprintf_f(1, 9, 2, 0.0);
+                       cprintf_f(-1, 1, 9, 2, 0.0);
                        printf("\n");
                }
                else {
                        /* Display total number of interrupts for current CPU */
-                       cprintf_f(1, 9, 2,
+                       cprintf_f(-1, 1, 9, 2,
                                  S_VALUE(sip->irq_nr, sic->irq_nr, itv));
                        printf("\n");
                }
@@ -921,7 +921,7 @@ void write_plain_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis,
 
                        if (!strcmp(p0->irq_name, q0->irq_name) || !interval) {
                                q = st_ic[prev] + (cpu - 1) * ic_nr + offset;
-                               cprintf_f(1, colwidth[j], 2,
+                               cprintf_f(-1, 1, colwidth[j], 2,
                                          S_VALUE(q->interrupt, p->interrupt, itv));
                        }
                        else {
@@ -929,7 +929,7 @@ void write_plain_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis,
                                 * Instead of printing "N/A", assume that previous value
                                 * for this new interrupt was zero.
                                 */
-                               cprintf_f(1, colwidth[j], 2,
+                               cprintf_f(-1, 1, colwidth[j], 2,
                                          S_VALUE(0, p->interrupt, itv));
                        }
                }
index e06d4efe26c1592ac3bf62494b9f2fabfe284c26..9677addeaa163db8d5642938275d024ef001e017 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -1393,10 +1393,10 @@ int write_pid_task_all_stats(int prev, int curr, int dis,
                }
 
                if (DISPLAY_MEM(actflag)) {
-                       cprintf_f(2, 9, 2,
+                       cprintf_f(-1, 2, 9, 2,
                                  S_VALUE(pstp->minflt, pstc->minflt, itv),
                                  S_VALUE(pstp->majflt, pstc->majflt, itv));
-                       cprintf_u64(2, 7,
+                       cprintf_u64(-1, 2, 7,
                                    (unsigned long long) pstc->vsz,
                                    (unsigned long long) pstc->rss);
                        cprintf_pc(1, 6, 2,
@@ -1404,7 +1404,7 @@ int write_pid_task_all_stats(int prev, int curr, int dis,
                }
 
                if (DISPLAY_STACK(actflag)) {
-                       cprintf_u64(2, 7,
+                       cprintf_u64(-1, 2, 7,
                                    (unsigned long long) pstc->stack_size,
                                    (unsigned long long) pstc->stack_ref);
                }
@@ -1412,7 +1412,7 @@ int write_pid_task_all_stats(int prev, int curr, int dis,
                if (DISPLAY_IO(actflag)) {
                        if (!NO_PID_IO(pstc->flags))
                        {
-                               cprintf_f(3, 9, 2,
+                               cprintf_f(-1, 3, 9, 2,
                                          S_VALUE(pstp->read_bytes,  pstc->read_bytes, itv)  / 1024,
                                          S_VALUE(pstp->write_bytes, pstc->write_bytes, itv) / 1024,
                                          S_VALUE(pstp->cancelled_write_bytes,
@@ -1427,30 +1427,30 @@ int write_pid_task_all_stats(int prev, int curr, int dis,
                                cprintf_s(IS_ZERO, "%s", dstr);
                        }
                        /* I/O delays come from another file (/proc/#/stat) */
-                       cprintf_u64(1, 7,
+                       cprintf_u64(-1, 1, 7,
                                    (unsigned long long) (pstc->blkio_swapin_delays - pstp->blkio_swapin_delays));
                }
 
                if (DISPLAY_CTXSW(actflag)) {
-                       cprintf_f(2, 9, 2,
+                       cprintf_f(-1, 2, 9, 2,
                                  S_VALUE(pstp->nvcsw, pstc->nvcsw, itv),
                                  S_VALUE(pstp->nivcsw, pstc->nivcsw, itv));
                }
 
                if (DISPLAY_KTAB(actflag)) {
-                       cprintf_u64(1, 7,
+                       cprintf_u64(-1, 1, 7,
                                    (unsigned long long) pstc->threads);
                        if (NO_PID_FD(pstc->flags)) {
                                /* /proc/#/fd directory not readable */
                                cprintf_s(IS_ZERO, " %7s", "-1");
                        }
                        else {
-                               cprintf_u64(1, 7, (unsigned long long) pstc->fd_nr);
+                               cprintf_u64(-1, 1, 7, (unsigned long long) pstc->fd_nr);
                        }
                }
 
                if (DISPLAY_RT(actflag)) {
-                       cprintf_u64(1, 4,
+                       cprintf_u64(-1, 1, 4,
                                    (unsigned long long) pstc->priority);
                        cprintf_s(IS_STR, " %6s",
                                  GET_POLICY(pstc->policy));
@@ -1504,7 +1504,7 @@ int write_pid_child_all_stats(int prev, int curr, int dis,
                __print_line_id(pstc, '0');
 
                if (DISPLAY_CPU(actflag)) {
-                       cprintf_f(3, 9, 0,
+                       cprintf_f(-1, 3, 9, 0,
                                  (pstc->utime + pstc->cutime - pstc->gtime - pstc->cgtime) <
                                  (pstp->utime + pstp->cutime - pstp->gtime - pstp->cgtime) ?
                                  0.0 :
@@ -1518,7 +1518,7 @@ int write_pid_child_all_stats(int prev, int curr, int dis,
                }
 
                if (DISPLAY_MEM(actflag)) {
-                       cprintf_u64(2, 9,
+                       cprintf_u64(-1, 2, 9,
                                    (unsigned long long) ((pstc->minflt + pstc->cminflt) - (pstp->minflt + pstp->cminflt)),
                                    (unsigned long long) ((pstc->majflt + pstc->cmajflt) - (pstp->majflt + pstp->cmajflt)));
                }
@@ -1653,7 +1653,7 @@ int write_pid_child_cpu_stats(int prev, int curr, int dis, int disp_avg,
 
                print_line_id(curr_string, pstc);
                if (disp_avg) {
-                       cprintf_f(3, 9, 0,
+                       cprintf_f(-1, 3, 9, 0,
                                  (pstc->utime + pstc->cutime - pstc->gtime - pstc->cgtime) <
                                  (pstp->utime + pstp->cutime - pstp->gtime - pstp->cgtime) ?
                                  0.0 :
@@ -1668,7 +1668,7 @@ int write_pid_child_cpu_stats(int prev, int curr, int dis, int disp_avg,
                                            (HZ * pstc->uc_asum_count) * 1000);
                }
                else {
-                       cprintf_f(3, 9, 0,
+                       cprintf_f(-1, 3, 9, 0,
                                  (pstc->utime + pstc->cutime - pstc->gtime - pstc->cgtime) <
                                  (pstp->utime + pstp->cutime - pstp->gtime - pstp->cgtime) ?
                                  0.0 :
@@ -1742,12 +1742,12 @@ int write_pid_task_memory_stats(int prev, int curr, int dis, int disp_avg,
 
                print_line_id(curr_string, pstc);
 
-               cprintf_f(2, 9, 2,
+               cprintf_f(-1, 2, 9, 2,
                          S_VALUE(pstp->minflt, pstc->minflt, itv),
                          S_VALUE(pstp->majflt, pstc->majflt, itv));
 
                if (disp_avg) {
-                       cprintf_f(2, 7, 0,
+                       cprintf_f(-1, 2, 7, 0,
                                  (double) pstc->total_vsz / pstc->rt_asum_count,
                                  (double) pstc->total_rss / pstc->rt_asum_count);
 
@@ -1757,7 +1757,7 @@ int write_pid_task_memory_stats(int prev, int curr, int dis, int disp_avg,
                                   : 0.0);
                }
                else {
-                       cprintf_u64(2, 7,
+                       cprintf_u64(-1, 2, 7,
                                    (unsigned long long) pstc->vsz,
                                    (unsigned long long) pstc->rss);
 
@@ -1823,14 +1823,14 @@ int write_pid_child_memory_stats(int prev, int curr, int dis, int disp_avg,
 
                print_line_id(curr_string, pstc);
                if (disp_avg) {
-                       cprintf_f(2, 9, 0,
+                       cprintf_f(-1, 2, 9, 0,
                                  (double) ((pstc->minflt + pstc->cminflt) -
                                            (pstp->minflt + pstp->cminflt)) / pstc->rc_asum_count,
                                  (double) ((pstc->majflt + pstc->cmajflt) -
                                            (pstp->majflt + pstp->cmajflt)) / pstc->rc_asum_count);
                }
                else {
-                       cprintf_u64(2, 9,
+                       cprintf_u64(-1, 2, 9,
                                    (unsigned long long) ((pstc->minflt + pstc->cminflt) - (pstp->minflt + pstp->cminflt)),
                     (unsigned long long) ((pstc->majflt + pstc->cmajflt) - (pstp->majflt + pstp->cmajflt)));
                }
@@ -1897,12 +1897,12 @@ int write_pid_stack_stats(int prev, int curr, int dis, int disp_avg,
                print_line_id(curr_string, pstc);
 
                if (disp_avg) {
-                       cprintf_f(2, 7, 0,
+                       cprintf_f(-1, 2, 7, 0,
                                  (double) pstc->total_stack_size / pstc->sk_asum_count,
                                  (double) pstc->total_stack_ref  / pstc->sk_asum_count);
                }
                else {
-                       cprintf_u64(2, 7,
+                       cprintf_u64(-1, 2, 7,
                                    (unsigned long long) pstc->stack_size,
                                    (unsigned long long) pstc->stack_ref);
                }
@@ -1968,7 +1968,7 @@ int write_pid_io_stats(int prev, int curr, int dis, int disp_avg,
 
                print_line_id(curr_string, pstc);
                if (!NO_PID_IO(pstc->flags)) {
-                       cprintf_f(3, 9, 2,
+                       cprintf_f(-1, 3, 9, 2,
                                  S_VALUE(pstp->read_bytes,  pstc->read_bytes, itv)  / 1024,
                                  S_VALUE(pstp->write_bytes, pstc->write_bytes, itv) / 1024,
                                  S_VALUE(pstp->cancelled_write_bytes,
@@ -1981,12 +1981,12 @@ int write_pid_io_stats(int prev, int curr, int dis, int disp_avg,
                }
                /* I/O delays come from another file (/proc/#/stat) */
                if (disp_avg) {
-                       cprintf_f(1, 7, 0,
+                       cprintf_f(-1, 1, 7, 0,
                                  (double) (pstc->blkio_swapin_delays - pstp->blkio_swapin_delays) /
                                            pstc->delay_asum_count);
                }
                else {
-                       cprintf_u64(1, 7,
+                       cprintf_u64(-1, 1, 7,
                                    (unsigned long long) (pstc->blkio_swapin_delays - pstp->blkio_swapin_delays));
                }
 
@@ -2038,7 +2038,7 @@ int write_pid_ctxswitch_stats(int prev, int curr, int dis,
                        continue;
 
                print_line_id(curr_string, pstc);
-               cprintf_f(2, 9, 2,
+               cprintf_f(-1, 2, 9, 2,
                          S_VALUE(pstp->nvcsw, pstc->nvcsw, itv),
                          S_VALUE(pstp->nivcsw, pstc->nivcsw, itv));
                print_comm(pstc);
@@ -2089,7 +2089,7 @@ int write_pid_rt_stats(int prev, int curr, int dis,
                        continue;
 
                print_line_id(curr_string, pstc);
-               cprintf_u64(1, 4,
+               cprintf_u64(-1, 1, 4,
                            (unsigned long long) pstc->priority);
                cprintf_s(IS_STR, " %6s", GET_POLICY(pstc->policy));
                print_comm(pstc);
@@ -2156,20 +2156,20 @@ int write_pid_ktab_stats(int prev, int curr, int dis, int disp_avg,
                print_line_id(curr_string, pstc);
 
                if (disp_avg) {
-                       cprintf_f(2, 7, 0,
+                       cprintf_f(-1, 2, 7, 0,
                                  (double) pstc->total_threads / pstc->tf_asum_count,
                                  NO_PID_FD(pstc->flags) ?
                                  -1.0 :
                                  (double) pstc->total_fd_nr / pstc->tf_asum_count);
                }
                else {
-                       cprintf_u64(1, 7,
+                       cprintf_u64(-1, 1, 7,
                                    (unsigned long long) pstc->threads);
                        if (NO_PID_FD(pstc->flags)) {
                                cprintf_s(IS_ZERO, " %7s", "-1");
                        }
                        else {
-                               cprintf_u64(1, 7,
+                               cprintf_u64(-1, 1, 7,
                                            (unsigned long long) pstc->fd_nr);
                        }
                }
index 1c345dd75218854a0586857342399aaf371ebb97..7b089530e065c8333c138c71feb0a68b656841b1 100644 (file)
@@ -285,7 +285,7 @@ __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(2, 9, 2,
+       cprintf_f(-1, 2, 9, 2,
                  S_VALUE(spp->processes,      spc->processes,      itv),
                  S_VALUE(spp->context_switch, spc->context_switch, itv));
        printf("\n");
@@ -338,7 +338,7 @@ __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
                                cprintf_in(IS_INT, " %9d", "", i -1);
                        }
 
-                       cprintf_f(1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
+                       cprintf_f(-1, 1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
                        printf("\n");
                }
        }
@@ -367,7 +367,7 @@ __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(2, 9, 2,
+       cprintf_f(-1, 2, 9, 2,
                  S_VALUE(ssp->pswpin,  ssc->pswpin,  itv),
                  S_VALUE(ssp->pswpout, ssc->pswpout, itv));
        printf("\n");
@@ -396,7 +396,7 @@ __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(8, 9, 2,
+       cprintf_f(-1, 8, 9, 2,
                  S_VALUE(spp->pgpgin,        spc->pgpgin,        itv),
                  S_VALUE(spp->pgpgout,       spc->pgpgout,       itv),
                  S_VALUE(spp->pgfault,       spc->pgfault,       itv),
@@ -444,7 +444,7 @@ __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
         * We display 0.0 in this case though we should rather tell
         * the user that the value cannot be calculated here.
         */
-       cprintf_f(5, 9, 2,
+       cprintf_f(-1, 5, 9, 2,
                  sic->dk_drive < sip->dk_drive ? 0.0 :
                  S_VALUE(sip->dk_drive, sic->dk_drive, itv),
                  sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
@@ -495,6 +495,12 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                avg_frskb = 0,
                avg_tlskb = 0,
                avg_caskb = 0;
+       int unit = -1;
+
+       if (DISPLAY_UNIT(flags)) {
+               /* Default values unit is kB */
+               unit = 2;
+       }
 
        if (DISPLAY_MEMORY(a->opt_flags)) {
                if (dis) {
@@ -502,7 +508,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                }
 
                printf("%-11s", timestamp[curr]);
-               cprintf_f(3, 9, 2,
+               cprintf_f(-1, 3, 9, 2,
                          S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
                          S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
                          S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
@@ -517,7 +523,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                if (!dispavg) {
                        /* Display instantaneous values */
                        printf("%-11s", timestamp[curr]);
-                       cprintf_u64(3, 9,
+                       cprintf_u64(unit, 3, 9,
                                    (unsigned long long) smc->frmkb,
                                    (unsigned long long) smc->availablekb,
                                    (unsigned long long) (smc->tlmkb - smc->frmkb));
@@ -525,7 +531,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                                   smc->tlmkb ?
                                   SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb)
                                   : 0.0);
-                       cprintf_u64(3, 9,
+                       cprintf_u64(unit, 3, 9,
                                    (unsigned long long) smc->bufkb,
                                    (unsigned long long) smc->camkb,
                                    (unsigned long long) smc->comkb);
@@ -533,14 +539,14 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                                   (smc->tlmkb + smc->tlskb) ?
                                   SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
                                   : 0.0);
-                       cprintf_u64(3, 9,
+                       cprintf_u64(unit, 3, 9,
                                    (unsigned long long) smc->activekb,
                                    (unsigned long long) smc->inactkb,
                                    (unsigned long long) smc->dirtykb);
 
                        if (DISPLAY_MEM_ALL(a->opt_flags)) {
                                /* Display extended memory statistics */
-                               cprintf_u64(5, 9,
+                               cprintf_u64(unit, 5, 9,
                                            (unsigned long long) smc->anonpgkb,
                                            (unsigned long long) smc->slabkb,
                                            (unsigned long long) smc->kstackkb,
@@ -572,7 +578,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                else {
                        /* Display average values */
                        printf("%-11s", timestamp[curr]);
-                       cprintf_f(3, 9, 0,
+                       cprintf_f(unit, 3, 9, 0,
                                  (double) avg_frmkb / avg_count,
                                  (double) avg_availablekb / avg_count,
                                  (double) smc->tlmkb - ((double) avg_frmkb / avg_count));
@@ -580,7 +586,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                                   smc->tlmkb ?
                                   SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb, smc->tlmkb)
                                   : 0.0);
-                       cprintf_f(3, 9, 0,
+                       cprintf_f(unit, 3, 9, 0,
                                  (double) avg_bufkb / avg_count,
                                  (double) avg_camkb / avg_count,
                                  (double) avg_comkb / avg_count);
@@ -588,13 +594,13 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                                   (smc->tlmkb + smc->tlskb) ?
                                   SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
                                   : 0.0);
-                       cprintf_f(3, 9, 0,
+                       cprintf_f(unit, 3, 9, 0,
                                  (double) avg_activekb / avg_count,
                                  (double) avg_inactkb / avg_count,
                                  (double) avg_dirtykb / avg_count);
 
                        if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                               cprintf_f(5, 9, 0,
+                               cprintf_f(unit, 5, 9, 0,
                                          (double) avg_anonpgkb / avg_count,
                                          (double) avg_slabkb / avg_count,
                                          (double) avg_kstackkb / avg_count,
@@ -620,14 +626,14 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                if (!dispavg) {
                        /* Display instantaneous values */
                        printf("%-11s", timestamp[curr]);
-                       cprintf_u64(2, 9,
+                       cprintf_u64(unit, 2, 9,
                                    (unsigned long long) smc->frskb,
                                    (unsigned long long) (smc->tlskb - smc->frskb));
                        cprintf_pc(1, 9, 2,
                                   smc->tlskb ?
                                   SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
                                   : 0.0);
-                       cprintf_u64(1, 9,
+                       cprintf_u64(unit, 1, 9,
                                    (unsigned long long) smc->caskb);
                        cprintf_pc(1, 9, 2,
                                   (smc->tlskb - smc->frskb) ?
@@ -647,7 +653,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                else {
                        /* Display average values */
                        printf("%-11s", timestamp[curr]);
-                       cprintf_f(2, 9, 0,
+                       cprintf_f(unit, 2, 9, 0,
                                  (double) avg_frskb / avg_count,
                                  ((double) avg_tlskb / avg_count) -
                                  ((double) avg_frskb / avg_count));
@@ -657,7 +663,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr,
                                            (double) avg_tlskb / avg_count,
                                            (double) avg_tlskb / avg_count)
                                   : 0.0);
-                       cprintf_f(1, 9, 0,
+                       cprintf_f(unit, 1, 9, 0,
                                  (double) avg_caskb / avg_count);
                        cprintf_pc(1, 9, 2,
                                   (avg_tlskb != avg_frskb) ?
@@ -736,7 +742,7 @@ void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
        if (!dispavg) {
                /* Display instantaneous values */
                printf("%-11s", timestamp[curr]);
-               cprintf_u64(4, 9,
+               cprintf_u64(-1, 4, 9,
                            (unsigned long long) skc->dentry_stat,
                            (unsigned long long) skc->file_used,
                            (unsigned long long) skc->inode_used,
@@ -755,7 +761,7 @@ void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
        else {
                /* Display average values */
                printf("%-11s", timestamp[curr]);
-               cprintf_f(4, 9, 0,
+               cprintf_f(-1, 4, 9, 0,
                          (double) avg_dentry_stat / avg_count,
                          (double) avg_file_used   / avg_count,
                          (double) avg_inode_used  / avg_count,
@@ -831,14 +837,14 @@ void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
        if (!dispavg) {
                /* Display instantaneous values */
                printf("%-11s", timestamp[curr]);
-               cprintf_u64(2, 9,
+               cprintf_u64(-1, 2, 9,
                            (unsigned long long) sqc->nr_running,
                            (unsigned long long) sqc->nr_threads);
-               cprintf_f(3, 9, 2,
+               cprintf_f(-1, 3, 9, 2,
                          (double) sqc->load_avg_1  / 100,
                          (double) sqc->load_avg_5  / 100,
                          (double) sqc->load_avg_15 / 100);
-               cprintf_u64(1, 9,
+               cprintf_u64(-1, 1, 9,
                            (unsigned long long) sqc->procs_blocked);
                printf("\n");
 
@@ -853,14 +859,14 @@ void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
        else {
                /* Display average values */
                printf("%-11s", timestamp[curr]);
-               cprintf_f(2, 9, 0,
+               cprintf_f(-1, 2, 9, 0,
                          (double) avg_nr_running / avg_count,
                          (double) avg_nr_threads / avg_count);
-               cprintf_f(3, 9, 2,
+               cprintf_f(-1, 3, 9, 2,
                          (double) avg_load_avg_1  / (avg_count * 100),
                          (double) avg_load_avg_5  / (avg_count * 100),
                          (double) avg_load_avg_15 / (avg_count * 100));
-               cprintf_f(1, 9, 0,
+               cprintf_f(-1, 1, 9, 0,
                          (double) avg_procs_blocked / avg_count);
                printf("\n");
 
@@ -938,7 +944,7 @@ __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
                cprintf_in(IS_INT, "       %3d", "", ssc->line - 1);
 
                if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
-                       cprintf_f(6, 9, 2,
+                       cprintf_f(-1, 6, 9, 2,
                                  S_VALUE(ssp->rx,      ssc->rx,      itv),
                                  S_VALUE(ssp->tx,      ssc->tx,      itv),
                                  S_VALUE(ssp->frame,   ssc->frame,   itv),
@@ -972,6 +978,12 @@ __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
        struct stats_disk *sdc, *sdp;
        struct ext_disk_stats xds;
        char *dev_name, *persist_dev_name;
+       int unit = -1;
+
+       if (DISPLAY_UNIT(flags)) {
+               /* Default values unit is sectors */
+               unit = 0;
+       }
 
        if (dis) {
                print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
@@ -1014,10 +1026,12 @@ __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
                printf("%-11s", timestamp[curr]);
 
                cprintf_in(IS_STR, " %9s", dev_name, 0);
-               cprintf_f(7, 9, 2,
-                         S_VALUE(sdp->nr_ios, sdc->nr_ios,  itv),
+               cprintf_f(-1, 1, 9, 2,
+                         S_VALUE(sdp->nr_ios, sdc->nr_ios,  itv));
+               cprintf_f(unit, 2, 9, 2,
                          S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
-                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
+                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv));
+               cprintf_f(-1, 4, 9, 2,
                          /* See iostat for explanations */
                          xds.arqsz,
                          S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
@@ -1046,6 +1060,12 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
        int i, j;
        struct stats_net_dev *sndc, *sndp;
        double rxkb, txkb, ifutil;
+       int unit = -1;
+
+       if (DISPLAY_UNIT(flags)) {
+               /* Default values unit is bytes */
+               unit = 1;
+       }
 
        if (dis) {
                print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
@@ -1067,11 +1087,13 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
                rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
                txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
 
-               cprintf_f(7, 9, 2,
+               cprintf_f(-1, 2, 9, 2,
                          S_VALUE(sndp->rx_packets,    sndc->rx_packets,    itv),
-                         S_VALUE(sndp->tx_packets,    sndc->tx_packets,    itv),
-                         rxkb / 1024,
-                         txkb / 1024,
+                         S_VALUE(sndp->tx_packets,    sndc->tx_packets,    itv));
+               cprintf_f(unit, 2, 9, 2,
+                         unit < 0 ? rxkb / 1024 : rxkb,
+                         unit < 0 ? txkb / 1024 : txkb);
+               cprintf_f(-1, 3, 9, 2,
                          S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
                          S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
                          S_VALUE(sndp->multicast,     sndc->multicast,     itv));
@@ -1115,7 +1137,7 @@ __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
                printf("%-11s", timestamp[curr]);
                cprintf_in(IS_STR, " %9s", snedc->interface, 0);
 
-               cprintf_f(9, 9, 2,
+               cprintf_f(-1, 9, 9, 2,
                          S_VALUE(snedp->rx_errors,         snedc->rx_errors,         itv),
                          S_VALUE(snedp->tx_errors,         snedc->tx_errors,         itv),
                          S_VALUE(snedp->collisions,        snedc->collisions,        itv),
@@ -1152,7 +1174,7 @@ __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(6, 9, 2,
+       cprintf_f(-1, 6, 9, 2,
                  S_VALUE(snnp->nfs_rpccnt,     snnc->nfs_rpccnt,     itv),
                  S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
                  S_VALUE(snnp->nfs_readcnt,    snnc->nfs_readcnt,    itv),
@@ -1185,7 +1207,7 @@ __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(11, 9, 2,
+       cprintf_f(-1, 11, 9, 2,
                  S_VALUE(snndp->nfsd_rpccnt,    snndc->nfsd_rpccnt,    itv),
                  S_VALUE(snndp->nfsd_rpcbad,    snndc->nfsd_rpcbad,    itv),
                  S_VALUE(snndp->nfsd_netcnt,    snndc->nfsd_netcnt,    itv),
@@ -1230,7 +1252,7 @@ void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
        if (!dispavg) {
                /* Display instantaneous values */
                printf("%-11s", timestamp[curr]);
-               cprintf_u64(6, 9,
+               cprintf_u64(-1, 6, 9,
                            (unsigned long long) snsc->sock_inuse,
                            (unsigned long long) snsc->tcp_inuse,
                            (unsigned long long) snsc->udp_inuse,
@@ -1250,7 +1272,7 @@ void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
        else {
                /* Display average values */
                printf("%-11s", timestamp[curr]);
-               cprintf_f(6, 9, 0,
+               cprintf_f(-1, 6, 9, 0,
                          (double) avg_sock_inuse / avg_count,
                          (double) avg_tcp_inuse  / avg_count,
                          (double) avg_udp_inuse  / avg_count,
@@ -1322,7 +1344,7 @@ __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(8, 9, 2,
+       cprintf_f(-1, 8, 9, 2,
                  S_VALUE(snip->InReceives,    snic->InReceives,    itv),
                  S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
                  S_VALUE(snip->InDelivers,    snic->InDelivers,    itv),
@@ -1357,7 +1379,7 @@ __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(8, 9, 2,
+       cprintf_f(-1, 8, 9, 2,
                  S_VALUE(sneip->InHdrErrors,     sneic->InHdrErrors,     itv),
                  S_VALUE(sneip->InAddrErrors,    sneic->InAddrErrors,    itv),
                  S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
@@ -1392,7 +1414,7 @@ __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(14, 9, 2,
+       cprintf_f(-1, 14, 9, 2,
                  S_VALUE(snip->InMsgs,           snic->InMsgs,           itv),
                  S_VALUE(snip->OutMsgs,          snic->OutMsgs,          itv),
                  S_VALUE(snip->InEchos,          snic->InEchos,          itv),
@@ -1433,7 +1455,7 @@ __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(12, 9, 2,
+       cprintf_f(-1, 12, 9, 2,
                  S_VALUE(sneip->InErrors,        sneic->InErrors,        itv),
                  S_VALUE(sneip->OutErrors,       sneic->OutErrors,       itv),
                  S_VALUE(sneip->InDestUnreachs,  sneic->InDestUnreachs,  itv),
@@ -1472,7 +1494,7 @@ __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(4, 9, 2,
+       cprintf_f(-1, 4, 9, 2,
                  S_VALUE(sntp->ActiveOpens,  sntc->ActiveOpens,  itv),
                  S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
                  S_VALUE(sntp->InSegs,       sntc->InSegs,       itv),
@@ -1503,7 +1525,7 @@ __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(5, 9, 2,
+       cprintf_f(-1, 5, 9, 2,
                  S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
                  S_VALUE(snetp->EstabResets,  snetc->EstabResets,  itv),
                  S_VALUE(snetp->RetransSegs,  snetc->RetransSegs,  itv),
@@ -1535,7 +1557,7 @@ __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(4, 9, 2,
+       cprintf_f(-1, 4, 9, 2,
                  S_VALUE(snup->InDatagrams,  snuc->InDatagrams,  itv),
                  S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
                  S_VALUE(snup->NoPorts,      snuc->NoPorts,      itv),
@@ -1571,7 +1593,7 @@ void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
        if (!dispavg) {
                /* Display instantaneous values */
                printf("%-11s", timestamp[curr]);
-               cprintf_u64(4, 9,
+               cprintf_u64(-1, 4, 9,
                            (unsigned long long) snsc->tcp6_inuse,
                            (unsigned long long) snsc->udp6_inuse,
                            (unsigned long long) snsc->raw6_inuse,
@@ -1587,7 +1609,7 @@ void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
        else {
                /* Display average values */
                printf("%-11s", timestamp[curr]);
-               cprintf_f(4, 9, 0,
+               cprintf_f(-1, 4, 9, 0,
                          (double) avg_tcp6_inuse  / avg_count,
                          (double) avg_udp6_inuse  / avg_count,
                          (double) avg_raw6_inuse  / avg_count,
@@ -1656,7 +1678,7 @@ __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(10, 9, 2,
+       cprintf_f(-1, 10, 9, 2,
                  S_VALUE(snip->InReceives6,       snic->InReceives6,       itv),
                  S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
                  S_VALUE(snip->InDelivers6,       snic->InDelivers6,       itv),
@@ -1693,7 +1715,7 @@ __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(11, 9, 2,
+       cprintf_f(-1, 11, 9, 2,
                  S_VALUE(sneip->InHdrErrors6,     sneic->InHdrErrors6,     itv),
                  S_VALUE(sneip->InAddrErrors6,    sneic->InAddrErrors6,    itv),
                  S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
@@ -1731,7 +1753,7 @@ __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(17, 9, 2,
+       cprintf_f(-1, 17, 9, 2,
                  S_VALUE(snip->InMsgs6,                    snic->InMsgs6,                    itv),
                  S_VALUE(snip->OutMsgs6,                   snic->OutMsgs6,                   itv),
                  S_VALUE(snip->InEchos6,                   snic->InEchos6,                   itv),
@@ -1775,7 +1797,7 @@ __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(11, 9, 2,
+       cprintf_f(-1, 11, 9, 2,
                  S_VALUE(sneip->InErrors6,        sneic->InErrors6,        itv),
                  S_VALUE(sneip->InDestUnreachs6,  sneic->InDestUnreachs6,  itv),
                  S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
@@ -1813,7 +1835,7 @@ __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
        }
 
        printf("%-11s", timestamp[curr]);
-       cprintf_f(4, 9, 2,
+       cprintf_f(-1, 4, 9, 2,
                  S_VALUE(snup->InDatagrams6,  snuc->InDatagrams6,  itv),
                  S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
                  S_VALUE(snup->NoPorts6,      snuc->NoPorts6,      itv),
@@ -1887,7 +1909,7 @@ void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
 
                        if (!dispavg) {
                                /* Display instantaneous values */
-                               cprintf_f(1, 9, 2,
+                               cprintf_f(-1, 1, 9, 2,
                                          ((double) spc->cpufreq) / 100);
                                printf("\n");
                                /*
@@ -1898,7 +1920,7 @@ void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
                        }
                        else {
                                /* Display average values */
-                               cprintf_f(1, 9, 2,
+                               cprintf_f(-1, 1, 9, 2,
                                          (double) avg_cpufreq[i] / (100 * avg_count));
                                printf("\n");
                        }
@@ -1994,13 +2016,13 @@ void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
 
                if (dispavg) {
                        /* Display average values */
-                       cprintf_f(2, 9, 2,
+                       cprintf_f(-1, 2, 9, 2,
                                  (double) avg_fan[i] / avg_count,
                                  (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
                }
                else {
                        /* Display instantaneous values */
-                       cprintf_f(2, 9, 2,
+                       cprintf_f(-1, 2, 9, 2,
                                  spc->rpm,
                                  spc->rpm - spc->rpm_min);
                        avg_fan[i]     += spc->rpm;
@@ -2109,7 +2131,7 @@ void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
 
                if (dispavg) {
                        /* Display average values */
-                       cprintf_f(1, 9, 2, (double) avg_temp[i] / avg_count);
+                       cprintf_f(-1, 1, 9, 2, (double) avg_temp[i] / avg_count);
                        cprintf_pc(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
@@ -2117,7 +2139,7 @@ void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
                }
                else {
                        /* Display instantaneous values */
-                       cprintf_f(1, 9, 2, spc->temp);
+                       cprintf_f(-1, 1, 9, 2, spc->temp);
                        cprintf_pc(1, 9, 2,
                                   (spc->temp_max - spc->temp_min) ?
                                   (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
@@ -2234,7 +2256,7 @@ void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
 
                if (dispavg) {
                        /* Display average values */
-                       cprintf_f(1, 9, 2, (double) avg_in[i] / avg_count);
+                       cprintf_f(-1, 1, 9, 2, (double) avg_in[i] / avg_count);
                        cprintf_pc(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
@@ -2242,7 +2264,7 @@ void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
                }
                else {
                        /* Display instantaneous values */
-                       cprintf_f(1, 9, 2, spc->in);
+                       cprintf_f(-1, 1, 9, 2, spc->in);
                        cprintf_pc(1, 9, 2,
                                   (spc->in_max - spc->in_min) ?
                                   (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
@@ -2324,6 +2346,12 @@ void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
        static unsigned long long
                avg_frhkb = 0,
                avg_tlhkb = 0;
+       int unit = -1;
+
+       if (DISPLAY_UNIT(flags)) {
+               /* Default values unit is kB */
+               unit = 2;
+       }
 
        if (dis) {
                print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
@@ -2332,7 +2360,7 @@ void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
        if (!dispavg) {
                /* Display instantaneous values */
                printf("%-11s", timestamp[curr]);
-               cprintf_u64(2, 9,
+               cprintf_u64(unit, 2, 9,
                            (unsigned long long) smc->frhkb,
                            (unsigned long long) (smc->tlhkb - smc->frhkb));
                cprintf_pc(1, 9, 2,
@@ -2347,7 +2375,7 @@ void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
        else {
                /* Display average values */
                printf("%-11s", timestamp[curr]);
-               cprintf_f(2, 9, 0,
+               cprintf_f(unit, 2, 9, 0,
                          (double) avg_frhkb / avg_count,
                          ((double) avg_tlhkb / avg_count) -
                          ((double) avg_frhkb / avg_count));
@@ -2469,7 +2497,7 @@ void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
                        }
 
                        /* Display weighted frequency for current CPU */
-                       cprintf_f(1, 9, 2,
+                       cprintf_f(-1, 1, 9, 2,
                                  tis ? ((double) tisfreq) / tis : 0.0);
                        printf("\n");
                }
@@ -2512,7 +2540,7 @@ void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
                cprintf_x(2, 9,
                          suc->vendor_id,
                          suc->product_id);
-               cprintf_u64(1, 9,
+               cprintf_u64(-1, 1, 9,
                            /* bMaxPower is expressed in 2 mA units */
                            (unsigned long long) (suc->bmaxpower << 1));
 
@@ -2606,6 +2634,12 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int di
 {
        int i, j;
        struct stats_filesystem *sfc, *sfm;
+       int unit = -1;
+
+       if (DISPLAY_UNIT(flags)) {
+               /* Default values unit is B */
+               unit = 1;
+       }
 
        if (dis) {
                print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
@@ -2620,16 +2654,17 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int di
                        break;
 
                printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
-               cprintf_f(2, 9, 0,
-                         (double) sfc->f_bfree / 1024 / 1024,
-                         (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
+               cprintf_f(unit, 2, 9, 0,
+                         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(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,
                           sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
                           : 0.0);
-               cprintf_u64(2, 9,
+               cprintf_u64(-1, 2, 9,
                            (unsigned long long) sfc->f_ffree,
                            (unsigned long long) (sfc->f_files - sfc->f_ffree));
                cprintf_pc(1, 9, 2,
@@ -2722,7 +2757,7 @@ __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
                        break;
 
                printf("%-11s", timestamp[curr]);
-               cprintf_f(4, 9, 2,
+               cprintf_f(-1, 4, 9, 2,
                          S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
                          S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
                          S_VALUE(sfcp->f_rxwords,  sfcc->f_rxwords,  itv),
@@ -2787,7 +2822,7 @@ __print_funct_t print_softnet_stats(struct activity *a, int prev, int curr,
                                cprintf_in(IS_INT, " %7d", "", i - 1);
                        }
 
-                       cprintf_f(5, 9, 2,
+                       cprintf_f(-1, 5, 9, 2,
                                  S_VALUE(ssnp->processed,    ssnc->processed,    itv),
                                  S_VALUE(ssnp->dropped,      ssnc->dropped,      itv),
                                  S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
index a7614c10bad30ac7bb118cf669d0ec2b17708f34..aec6e7342534591a496488732bd7c305b6c7a6e1 100644 (file)
@@ -446,17 +446,17 @@ void tape_write_stats(struct calc_stats *tape, int i)
        sprintf(buffer, "st%i        ", i);
        buffer[5] = 0;
        cprintf_in(IS_STR, "%s", buffer, 0);
-       cprintf_u64(2, 7,
+       cprintf_u64(-1, 2, 7,
                    tape->reads_per_second,
                    tape->writes_per_second);
-       cprintf_u64(2, 11,
+       cprintf_u64(-1, 2, 11,
                    tape->kbytes_read_per_second / divisor,
                    tape->kbytes_written_per_second / divisor);
        cprintf_pc(3, 3, 0,
                   (double) tape->read_pct_wait,
                   (double) tape->write_pct_wait,
                   (double) tape->all_pct_wait);
-       cprintf_u64(2, 7,
+       cprintf_u64(-1, 2, 7,
                    tape->resids_per_second,
                    tape->other_per_second);
        printf("\n");