Skip to content

Commit

Permalink
Define constants for metrics units
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien GODARD <[email protected]>
  • Loading branch information
sysstat committed Jun 7, 2017
1 parent 754d680 commit 83313c0
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 117 deletions.
6 changes: 3 additions & 3 deletions cifsiostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ void write_cifs_stat(int curr, unsigned long long itv, int fctr,
rbytes /= fctr;
wbytes /= fctr;
}
cprintf_f(DISPLAY_UNIT(flags) ? 1 : -1, 2, 12, 2,
cprintf_f(DISPLAY_UNIT(flags) ? UNIT_BYTE : NO_UNIT, 2, 12, 2,
rbytes, wbytes);
cprintf_f(-1, 2, 9, 2,
cprintf_f(NO_UNIT, 2, 9, 2,
S_VALUE(ionj->rd_ops, ioni->rd_ops, itv),
S_VALUE(ionj->wr_ops, ioni->wr_ops, itv));
cprintf_f(-1, 3, 12, 2,
cprintf_f(NO_UNIT, 3, 12, 2,
S_VALUE(ionj->fopens, ioni->fopens, itv),
S_VALUE(ionj->fcloses, ioni->fcloses, itv),
S_VALUE(ionj->fdeletes, ioni->fdeletes, itv));
Expand Down
1 change: 0 additions & 1 deletion common.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

/* 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;
Expand Down
9 changes: 9 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@

#define DISP_HDR 1

/* Index in units array (see common.c) */
#define NO_UNIT -1
#define UNIT_SECTOR 0
#define UNIT_BYTE 1
#define UNIT_KILOBYTE 2

#define NR_UNITS 8


/* Timestamp buffer length */
#define TIMESTAMP_LEN 64

Expand Down
32 changes: 16 additions & 16 deletions iostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,25 +1025,25 @@ void write_plain_ext_stat(unsigned long long itv, int fctr,

if (DISPLAY_SHORT_OUTPUT(flags)) {
/* tps */
cprintf_f(-1, 1, 8, 2,
cprintf_f(NO_UNIT, 1, 8, 2,
S_VALUE(ioj->rd_ios + ioj->wr_ios, ioi->rd_ios + ioi->wr_ios, itv));
/* kB/s */
if (!DISPLAY_UNIT(flags)) {
xios->sectors /= fctr;
}
cprintf_f(DISPLAY_UNIT(flags) ? 0 : -1, 1, 9, 2,
cprintf_f(DISPLAY_UNIT(flags) ? UNIT_SECTOR : NO_UNIT, 1, 9, 2,
xios->sectors);
/* rqm/s */
cprintf_f(-1, 1, 8, 2,
cprintf_f(NO_UNIT, 1, 8, 2,
S_VALUE(ioj->rd_merges + ioj->wr_merges, ioi->rd_merges + ioi->wr_merges, itv));
/* await */
cprintf_f(-1, 1, 7, 2,
cprintf_f(NO_UNIT, 1, 7, 2,
xds->await);
/* aqu-sz */
cprintf_f(-1, 1, 6, 2,
cprintf_f(NO_UNIT, 1, 6, 2,
S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
/* areq-sz (in kB, not sectors) */
cprintf_f(-1, 1, 8, 2,
cprintf_f(NO_UNIT, 1, 8, 2,
xds->arqsz / 2);
/*
* %util
Expand All @@ -1058,34 +1058,34 @@ void write_plain_ext_stat(unsigned long long itv, int fctr,
}
else {
/* r/s w/s */
cprintf_f(-1, 2, 7, 2,
cprintf_f(NO_UNIT, 2, 7, 2,
S_VALUE(ioj->rd_ios, ioi->rd_ios, itv),
S_VALUE(ioj->wr_ios, ioi->wr_ios, itv));
/* rkB/s wkB/s */
if (!DISPLAY_UNIT(flags)) {
xios->rsectors /= fctr;
xios->wsectors /= fctr;
}
cprintf_f(DISPLAY_UNIT(flags) ? 0 : -1, 2, 9, 2,
cprintf_f(DISPLAY_UNIT(flags) ? UNIT_SECTOR : NO_UNIT, 2, 9, 2,
xios->rsectors, xios->wsectors);
/* rrqm/s wrqm/s */
cprintf_f(-1, 2, 8, 2,
cprintf_f(NO_UNIT, 2, 8, 2,
S_VALUE(ioj->rd_merges, ioi->rd_merges, itv),
S_VALUE(ioj->wr_merges, ioi->wr_merges, itv));
/* %rrqm %wrqm */
cprintf_pc(2, 6, 2,
xios->rrqm_pc, xios->wrqm_pc);
/* r_await w_await */
cprintf_f(-1, 2, 7, 2,
cprintf_f(NO_UNIT, 2, 7, 2,
xios->r_await, xios->w_await);
/* aqu-sz */
cprintf_f(-1, 1, 6, 2,
cprintf_f(NO_UNIT, 1, 6, 2,
S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
/* rareq-sz wareq-sz (in kB, not sectors) */
cprintf_f(-1, 2, 8, 2,
cprintf_f(NO_UNIT, 2, 8, 2,
xios->rarqsz / 2, xios->warqsz / 2);
/* svctm - The ticks output is biased to output 1000 ticks per second */
cprintf_f(-1, 1, 6, 2, xds->svctm);
cprintf_f(NO_UNIT, 1, 6, 2, xds->svctm);
/*
* %util
* Again: Ticks in milliseconds.
Expand Down Expand Up @@ -1308,17 +1308,17 @@ void write_plain_basic_stat(unsigned long long itv, int fctr,
else {
cprintf_in(IS_STR, "%-13s", devname, 0);
}
cprintf_f(-1, 1, 8, 2,
cprintf_f(NO_UNIT, 1, 8, 2,
S_VALUE(ioj->rd_ios + ioj->wr_ios, ioi->rd_ios + ioi->wr_ios, itv));
rsectors = S_VALUE(ioj->rd_sectors, ioi->rd_sectors, itv);
wsectors = S_VALUE(ioj->wr_sectors, ioi->wr_sectors, itv);
if (!DISPLAY_UNIT(flags)) {
rsectors /= fctr;
wsectors /= fctr;
}
cprintf_f(DISPLAY_UNIT(flags) ? 0 : -1, 2, 12, 2,
cprintf_f(DISPLAY_UNIT(flags) ? UNIT_SECTOR : NO_UNIT, 2, 12, 2,
rsectors, wsectors);
cprintf_u64(DISPLAY_UNIT(flags) ? 0 : -1, 2, 10,
cprintf_u64(DISPLAY_UNIT(flags) ? UNIT_SECTOR : NO_UNIT, 2, 10,
DISPLAY_UNIT(flags) ? (unsigned long long) rd_sec
: (unsigned long long) rd_sec / fctr,
DISPLAY_UNIT(flags) ? (unsigned long long) wr_sec
Expand Down
12 changes: 6 additions & 6 deletions mpstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,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, 1, 9, 2,
cprintf_f(NO_UNIT, 1, 9, 2,
S_VALUE(st_irq[prev]->irq_nr, st_irq[curr]->irq_nr, itv));
printf("\n");
}
Expand Down Expand Up @@ -1097,7 +1097,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, 1, 9, 2, 0.0);
cprintf_f(NO_UNIT, 1, 9, 2, 0.0);
printf("\n");
}
continue;
Expand All @@ -1111,12 +1111,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, 1, 9, 2, 0.0);
cprintf_f(NO_UNIT, 1, 9, 2, 0.0);
printf("\n");
}
else {
/* Display total number of interrupts for current CPU */
cprintf_f(-1, 1, 9, 2,
cprintf_f(NO_UNIT, 1, 9, 2,
S_VALUE(sip->irq_nr, sic->irq_nr, itv));
printf("\n");
}
Expand Down Expand Up @@ -1381,15 +1381,15 @@ 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, 1, colwidth[j], 2,
cprintf_f(NO_UNIT, 1, colwidth[j], 2,
S_VALUE(q->interrupt, p->interrupt, itv));
}
else {
/*
* Instead of printing "N/A", assume that previous value
* for this new interrupt was zero.
*/
cprintf_f(-1, 1, colwidth[j], 2,
cprintf_f(NO_UNIT, 1, colwidth[j], 2,
S_VALUE(0, p->interrupt, itv));
}
}
Expand Down

0 comments on commit 83313c0

Please sign in to comment.