Fiddle with screen layout to generate room for longer labels on the

interrupt count fields.
(approved by christos)
This commit is contained in:
dsl 2003-02-17 19:30:33 +00:00
parent 34592076d4
commit c4ccc4eaf4

View File

@ -1,4 +1,4 @@
/* $NetBSD: vmstat.c,v 1.47 2003/02/13 08:09:33 dsl Exp $ */ /* $NetBSD: vmstat.c,v 1.48 2003/02/17 19:30:33 dsl Exp $ */
/*- /*-
* Copyright (c) 1983, 1989, 1992, 1993 * Copyright (c) 1983, 1989, 1992, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif #endif
__RCSID("$NetBSD: vmstat.c,v 1.47 2003/02/13 08:09:33 dsl Exp $"); __RCSID("$NetBSD: vmstat.c,v 1.48 2003/02/17 19:30:33 dsl Exp $");
#endif /* not lint */ #endif /* not lint */
/* /*
@ -136,19 +136,20 @@ static struct nlist namelist[] = {
*/ */
#define STATROW 0 /* uses 1 row and 68 cols */ #define STATROW 0 /* uses 1 row and 68 cols */
#define STATCOL 2 #define STATCOL 2
#define MEMROW 2 /* uses 4 rows and 31 cols */ #define MEMROW 9 /* uses 4 rows and 31 cols */
#define MEMCOL 0 #define MEMCOL 0
#define PAGEROW 2 /* uses 4 rows and 26 cols */ #define PAGEROW 2 /* uses 4 rows and 26 cols */
#define PAGECOL 36 #define PAGECOL 54
#define INTSROW 2 /* uses all rows to bottom and 17 cols */ #define INTSROW 9 /* uses all rows to bottom and 17 cols */
#define INTSCOL 63 #define INTSCOL 40
#define PROCSROW 7 /* uses 2 rows and 20 cols */ #define INTSCOLEND (VMSTATCOL - 0)
#define PROCSROW 2 /* uses 2 rows and 20 cols */
#define PROCSCOL 0 #define PROCSCOL 0
#define GENSTATROW 7 /* uses 2 rows and 30 cols */ #define GENSTATROW 2 /* uses 2 rows and 30 cols */
#define GENSTATCOL 18 #define GENSTATCOL 18
#define VMSTATROW 7 /* uses 17 rows and 12 cols */ #define VMSTATROW 7 /* uses 17 rows and 15 cols */
#define VMSTATCOL 48 #define VMSTATCOL 64
#define GRAPHROW 10 /* uses 3 rows and 51 cols */ #define GRAPHROW 5 /* uses 3 rows and 51 cols */
#define GRAPHCOL 0 #define GRAPHCOL 0
#define NAMEIROW 14 /* uses 3 rows and 38 cols */ #define NAMEIROW 14 /* uses 3 rows and 38 cols */
#define NAMEICOL 0 #define NAMEICOL 0
@ -255,7 +256,7 @@ initvmstat(void)
/* event counter interrupt counts */ /* event counter interrupt counts */
get_interrupt_events(); get_interrupt_events();
nextintsrow = INTSROW + 2; nextintsrow = INTSROW + 1;
allocinfo(&s); allocinfo(&s);
allocinfo(&s1); allocinfo(&s1);
allocinfo(&s2); allocinfo(&s2);
@ -282,7 +283,7 @@ print_ie_title(int i)
{ {
int width, name_width, group_width; int width, name_width, group_width;
width = COLS - (INTSCOL + 9); width = INTSCOLEND - (INTSCOL + 9);
if (width <= 0) if (width <= 0)
return; return;
@ -341,8 +342,7 @@ labelvmstat(void)
mvprintw(PAGEROW + 2, PAGECOL, "ops"); mvprintw(PAGEROW + 2, PAGECOL, "ops");
mvprintw(PAGEROW + 3, PAGECOL, "pages"); mvprintw(PAGEROW + 3, PAGECOL, "pages");
mvprintw(INTSROW, INTSCOL + 3, " Interrupts"); mvprintw(INTSROW, INTSCOL + 9, "Interrupts");
mvprintw(INTSROW + 1, INTSCOL + 9, "total");
mvprintw(VMSTATROW + 0, VMSTATCOL + 10, "forks"); mvprintw(VMSTATROW + 0, VMSTATCOL + 10, "forks");
mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw"); mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw");
@ -390,7 +390,7 @@ labelvmstat(void)
if (intrloc[i] == 0) if (intrloc[i] == 0)
continue; continue;
mvprintw(intrloc[i], INTSCOL + 9, "%-.*s", mvprintw(intrloc[i], INTSCOL + 9, "%-.*s",
COLS - (INTSCOL + 9), intrname[i]); INTSCOLEND - (INTSCOL + 9), intrname[i]);
} }
for (i = 0; i < nevcnt; i++) { for (i = 0; i < nevcnt; i++) {
if (ie_head[i].ie_loc == 0) if (ie_head[i].ie_loc == 0)
@ -447,7 +447,7 @@ showvmstat(void)
continue; continue;
intrloc[i] = nextintsrow++; intrloc[i] = nextintsrow++;
mvprintw(intrloc[i], INTSCOL + 9, "%-.*s", mvprintw(intrloc[i], INTSCOL + 9, "%-.*s",
COLS - (INTSCOL + 9), intrname[i]); INTSCOLEND - (INTSCOL + 9), intrname[i]);
} }
X(intrcnt); X(intrcnt);
l = (int)((float)s.intrcnt[i]/etime + 0.5); l = (int)((float)s.intrcnt[i]/etime + 0.5);
@ -468,7 +468,7 @@ showvmstat(void)
inttotal += l; inttotal += l;
putint(l, ie_head[i].ie_loc, INTSCOL, 8); putint(l, ie_head[i].ie_loc, INTSCOL, 8);
} }
putint(inttotal, INTSROW + 1, INTSCOL, 8); putint(inttotal, INTSROW, INTSCOL, 8);
Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss); Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss);
Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes); Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes);
s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits + s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits +
@ -636,7 +636,8 @@ puthumanint(u_int64_t n, int l, int c, int w)
{ {
char b[128]; char b[128];
move(l, c); if (move(l, c) != OK)
return;
if (n == 0) { if (n == 0) {
hline(' ', w); hline(' ', w);
return; return;
@ -646,8 +647,7 @@ puthumanint(u_int64_t n, int l, int c, int w)
return; return;
} }
hline(' ', w - strlen(b)); hline(' ', w - strlen(b));
move(l, c + w - strlen(b)); mvaddstr(l, c + w - strlen(b), b);
addstr(b);
} }
static void static void
@ -655,7 +655,8 @@ putint(int n, int l, int c, int w)
{ {
char b[128]; char b[128];
move(l, c); if (move(l, c) != OK)
return;
if (n == 0) { if (n == 0) {
hline(' ', w); hline(' ', w);
return; return;
@ -673,7 +674,8 @@ putfloat(double f, int l, int c, int w, int d, int nz)
{ {
char b[128]; char b[128];
move(l, c); if (move(l, c) != OK)
return;
if (nz && f == 0.0) { if (nz && f == 0.0) {
hline(' ', w); hline(' ', w);
return; return;