version 1.62, 2006/02/05 09:54:50 |
version 1.63, 2006/03/18 14:58:49 |
Line 58 __RCSID("$NetBSD$"); |
|
Line 58 __RCSID("$NetBSD$"); |
|
#include "dkstats.h" |
#include "dkstats.h" |
#include "tpstats.h" |
#include "tpstats.h" |
#include "utmpentry.h" |
#include "utmpentry.h" |
|
#include "vmstat.h" |
|
|
static struct Info { |
static struct Info { |
struct uvmexp_sysctl uvmexp; |
struct uvmexp_sysctl uvmexp; |
Line 68 static struct Info { |
|
Line 69 static struct Info { |
|
u_int64_t *evcnt; |
u_int64_t *evcnt; |
} s, s1, s2, z; |
} s, s1, s2, z; |
|
|
#define cnt s.Cnt |
enum display_mode display_mode = TIME; |
#define oldcnt s1.Cnt |
|
#define total s.Total |
|
#define nchtotal s.nchstats |
|
#define oldnchtotal s1.nchstats |
|
|
|
static enum state { BOOT, TIME, RUN } state = TIME; |
|
|
|
static void allocinfo(struct Info *); |
static void allocinfo(struct Info *); |
static void copyinfo(struct Info *, struct Info *); |
static void copyinfo(struct Info *, struct Info *); |
static float cputime(int); |
static float cputime(int); |
static void dinfo(int, int, int); |
static void dinfo(int, int, int); |
static void tinfo(int, int, int); |
static void tinfo(int, int, int); |
static void getinfo(struct Info *, enum state); |
static void getinfo(struct Info *); |
static void putint(int, int, int, int); |
|
static void putfloat(double, int, int, int, int, int); |
|
static int ucount(void); |
static int ucount(void); |
|
|
static char buf[26]; |
static char buf[26]; |
static u_int64_t temp; |
static u_int64_t temp; |
static double etime; |
double etime; |
static float hertz; |
static float hertz; |
static int nintr; |
static int nintr; |
static long *intrloc; |
static long *intrloc; |
Line 262 initvmstat(void) |
|
Line 255 initvmstat(void) |
|
allocinfo(&s2); |
allocinfo(&s2); |
allocinfo(&z); |
allocinfo(&z); |
|
|
getinfo(&s2, RUN); |
getinfo(&s2); |
copyinfo(&s2, &s1); |
copyinfo(&s2, &s1); |
return(1); |
return(1); |
} |
} |
Line 275 fetchvmstat(void) |
|
Line 268 fetchvmstat(void) |
|
time(&now); |
time(&now); |
strlcpy(buf, ctime(&now), sizeof(buf)); |
strlcpy(buf, ctime(&now), sizeof(buf)); |
buf[19] = '\0'; |
buf[19] = '\0'; |
getinfo(&s, state); |
getinfo(&s); |
} |
} |
|
|
static void |
static void |
Line 326 print_ie_title(int i) |
|
Line 319 print_ie_title(int i) |
|
} |
} |
|
|
void |
void |
labelvmstat(void) |
labelvmstat_top(void) |
{ |
{ |
int i; |
|
|
|
clear(); |
clear(); |
mvprintw(STATROW, STATCOL + 4, "users Load"); |
|
mvprintw(MEMROW, MEMCOL, " memory totals (in kB)"); |
|
mvprintw(MEMROW + 1, MEMCOL, " real virtual free"); |
|
mvprintw(MEMROW + 2, MEMCOL, "Active"); |
|
mvprintw(MEMROW + 3, MEMCOL, "All"); |
|
|
|
mvprintw(PAGEROW, PAGECOL, " PAGING SWAPPING "); |
|
mvprintw(PAGEROW + 1, PAGECOL, " in out in out "); |
|
mvprintw(PAGEROW + 2, PAGECOL, "ops"); |
|
mvprintw(PAGEROW + 3, PAGECOL, "pages"); |
|
|
|
mvprintw(INTSROW, INTSCOL + 9, "Interrupts"); |
mvprintw(STATROW, STATCOL + 4, "users Load"); |
|
|
mvprintw(VMSTATROW + 0, VMSTATCOL + 10, "forks"); |
|
mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw"); |
|
mvprintw(VMSTATROW + 2, VMSTATCOL + 10, "fksvm"); |
|
mvprintw(VMSTATROW + 3, VMSTATCOL + 10, "pwait"); |
|
mvprintw(VMSTATROW + 4, VMSTATCOL + 10, "relck"); |
|
mvprintw(VMSTATROW + 5, VMSTATCOL + 10, "rlkok"); |
|
mvprintw(VMSTATROW + 6, VMSTATCOL + 10, "noram"); |
|
mvprintw(VMSTATROW + 7, VMSTATCOL + 10, "ndcpy"); |
|
mvprintw(VMSTATROW + 8, VMSTATCOL + 10, "fltcp"); |
|
mvprintw(VMSTATROW + 9, VMSTATCOL + 10, "zfod"); |
|
mvprintw(VMSTATROW + 10, VMSTATCOL + 10, "cow"); |
|
mvprintw(VMSTATROW + 11, VMSTATCOL + 10, "fmin"); |
|
mvprintw(VMSTATROW + 12, VMSTATCOL + 10, "ftarg"); |
|
mvprintw(VMSTATROW + 13, VMSTATCOL + 10, "itarg"); |
|
mvprintw(VMSTATROW + 14, VMSTATCOL + 10, "wired"); |
|
mvprintw(VMSTATROW + 15, VMSTATCOL + 10, "pdfre"); |
|
if (LINES - 1 > VMSTATROW + 16) |
|
mvprintw(VMSTATROW + 16, VMSTATCOL + 10, "pdscn"); |
|
|
|
mvprintw(GENSTATROW, GENSTATCOL, " Csw Trp Sys Int Sof Flt"); |
mvprintw(GENSTATROW, GENSTATCOL, " Csw Trp Sys Int Sof Flt"); |
|
|
mvprintw(GRAPHROW, GRAPHCOL, |
mvprintw(GRAPHROW, GRAPHCOL, |
" . %% Sy . %% Us . %% Ni . %% In . %% Id"); |
" . %% Sy . %% Us . %% Ni . %% In . %% Id"); |
Line 371 labelvmstat(void) |
|
Line 334 labelvmstat(void) |
|
mvprintw(GRAPHROW + 1, GRAPHCOL, |
mvprintw(GRAPHROW + 1, GRAPHCOL, |
"| | | | | | | | | | |"); |
"| | | | | | | | | | |"); |
|
|
|
mvprintw(PAGEROW, PAGECOL + 8, "PAGING SWAPPING "); |
|
mvprintw(PAGEROW + 1, PAGECOL, " in out in out "); |
|
mvprintw(PAGEROW + 2, PAGECOL + 2, "ops"); |
|
mvprintw(PAGEROW + 3, PAGECOL, "pages"); |
|
} |
|
|
|
void |
|
labelvmstat(void) |
|
{ |
|
int i; |
|
|
|
/* Top few lines first */ |
|
|
|
labelvmstat_top(); |
|
|
|
/* Left hand column */ |
|
|
|
mvprintw(MEMROW, MEMCOL, " memory totals (in kB)"); |
|
mvprintw(MEMROW + 1, MEMCOL, " real virtual free"); |
|
mvprintw(MEMROW + 2, MEMCOL, "Active"); |
|
mvprintw(MEMROW + 3, MEMCOL, "All"); |
|
|
mvprintw(NAMEIROW, NAMEICOL, "Namei Sys-cache Proc-cache"); |
mvprintw(NAMEIROW, NAMEICOL, "Namei Sys-cache Proc-cache"); |
mvprintw(NAMEIROW + 1, NAMEICOL, |
mvprintw(NAMEIROW + 1, NAMEICOL, |
" Calls hits %% hits %%"); |
" Calls hits %% hits %%"); |
|
|
mvprintw(DISKROW, DISKCOL, "Disks:"); |
mvprintw(DISKROW, DISKCOL, "Disks:"); |
if (disk_horiz) { |
if (disk_horiz) { |
mvprintw(DISKROW + 1, DISKCOL + 1, "seeks"); |
mvprintw(DISKROW + 1, DISKCOL + 1, "seeks"); |
Line 386 labelvmstat(void) |
|
Line 372 labelvmstat(void) |
|
mvprintw(DISKROW, DISKCOL + 1 + 3 * DISKCOLWIDTH, "bytes"); |
mvprintw(DISKROW, DISKCOL + 1 + 3 * DISKCOLWIDTH, "bytes"); |
mvprintw(DISKROW, DISKCOL + 1 + 4 * DISKCOLWIDTH, "%%busy"); |
mvprintw(DISKROW, DISKCOL + 1 + 4 * DISKCOLWIDTH, "%%busy"); |
} |
} |
|
|
|
/* Middle column */ |
|
|
|
mvprintw(INTSROW, INTSCOL + 9, "Interrupts"); |
for (i = 0; i < nintr; i++) { |
for (i = 0; i < nintr; i++) { |
if (intrloc[i] == 0) |
if (intrloc[i] == 0) |
continue; |
continue; |
Line 397 labelvmstat(void) |
|
Line 387 labelvmstat(void) |
|
continue; |
continue; |
print_ie_title(i); |
print_ie_title(i); |
} |
} |
|
|
|
/* Right hand column */ |
|
|
|
mvprintw(VMSTATROW + 0, VMSTATCOL + 10, "forks"); |
|
mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw"); |
|
mvprintw(VMSTATROW + 2, VMSTATCOL + 10, "fksvm"); |
|
mvprintw(VMSTATROW + 3, VMSTATCOL + 10, "pwait"); |
|
mvprintw(VMSTATROW + 4, VMSTATCOL + 10, "relck"); |
|
mvprintw(VMSTATROW + 5, VMSTATCOL + 10, "rlkok"); |
|
mvprintw(VMSTATROW + 6, VMSTATCOL + 10, "noram"); |
|
mvprintw(VMSTATROW + 7, VMSTATCOL + 10, "ndcpy"); |
|
mvprintw(VMSTATROW + 8, VMSTATCOL + 10, "fltcp"); |
|
mvprintw(VMSTATROW + 9, VMSTATCOL + 10, "zfod"); |
|
mvprintw(VMSTATROW + 10, VMSTATCOL + 10, "cow"); |
|
mvprintw(VMSTATROW + 11, VMSTATCOL + 10, "fmin"); |
|
mvprintw(VMSTATROW + 12, VMSTATCOL + 10, "ftarg"); |
|
mvprintw(VMSTATROW + 13, VMSTATCOL + 10, "itarg"); |
|
mvprintw(VMSTATROW + 14, VMSTATCOL + 10, "wired"); |
|
mvprintw(VMSTATROW + 15, VMSTATCOL + 10, "pdfre"); |
|
|
|
if (LINES - 1 > VMSTATROW + 16) |
|
mvprintw(VMSTATROW + 16, VMSTATCOL + 10, "pdscn"); |
} |
} |
|
|
#define X(fld) {temp=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=temp;} |
#define X(s, s1, fld) {temp = (s).fld[i]; (s).fld[i] -= (s1).fld[i]; \ |
#define Y(fld) {temp = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = temp;} |
if (display_mode == TIME) (s1).fld[i] = temp;} |
#define Z(fld) {temp = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ |
#define Z(s, s1, fld) {temp = (s).nchstats.fld; \ |
if(state == TIME) s1.nchstats.fld = temp;} |
(s).nchstats.fld -= (s1).nchstats.fld; \ |
#define PUTRATE(fld, l, c, w) {Y(fld); putint((int)((float)s.fld/etime + 0.5), l, c, w);} |
if (display_mode == TIME) (s1).nchstats.fld = temp;} |
|
#define PUTRATE(s, s1, fld, l, c, w) \ |
|
{temp = (s).fld; (s).fld -= (s1).fld; \ |
|
if (display_mode == TIME) (s1).fld = temp; \ |
|
putint((int)((float)(s).fld/etime + 0.5), l, c, w);} |
#define MAXFAIL 5 |
#define MAXFAIL 5 |
|
|
static char cpuchar[CPUSTATES] = { '=' , '>', '-', '%', ' ' }; |
static char cpuchar[CPUSTATES] = { '=' , '>', '-', '%', ' ' }; |
static char cpuorder[CPUSTATES] = { CP_SYS, CP_USER, CP_NICE, CP_INTR, CP_IDLE }; |
static char cpuorder[CPUSTATES] = { CP_SYS, CP_USER, CP_NICE, CP_INTR, CP_IDLE }; |
|
|
void |
void |
showvmstat(void) |
show_vmstat_top(vmtotal_t *Total, uvmexp_sysctl_t *uvm, uvmexp_sysctl_t *uvm1) |
{ |
{ |
float f1, f2; |
float f1, f2; |
int psiz, inttotal; |
int psiz; |
|
int i, l, c; |
|
struct { |
|
struct uvmexp_sysctl *uvmexp; |
|
} us, us1; |
|
|
|
us.uvmexp = uvm; |
|
us1.uvmexp = uvm1; |
|
|
|
putint(ucount(), STATROW, STATCOL, 3); |
|
putfloat(avenrun[0], STATROW, STATCOL + 17, 6, 2, 0); |
|
putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0); |
|
putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0); |
|
mvaddstr(STATROW, STATCOL + 53, buf); |
|
|
|
putint(Total->t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3); |
|
putint(Total->t_dw, PROCSROW + 1, PROCSCOL + 6, 3); |
|
putint(Total->t_sl, PROCSROW + 1, PROCSCOL + 9, 3); |
|
putint(Total->t_sw, PROCSROW + 1, PROCSCOL + 12, 3); |
|
|
|
PUTRATE(us, us1, uvmexp->swtch, GENSTATROW + 1, GENSTATCOL - 1, 7); |
|
PUTRATE(us, us1, uvmexp->traps, GENSTATROW + 1, GENSTATCOL + 6, 7); |
|
PUTRATE(us, us1, uvmexp->syscalls, GENSTATROW + 1, GENSTATCOL + 13, 7); |
|
PUTRATE(us, us1, uvmexp->intrs, GENSTATROW + 1, GENSTATCOL + 20, 6); |
|
PUTRATE(us, us1, uvmexp->softs, GENSTATROW + 1, GENSTATCOL + 26, 6); |
|
PUTRATE(us, us1, uvmexp->faults, GENSTATROW + 1, GENSTATCOL + 32, 7); |
|
|
|
/* Last CPU state not calculated yet. */ |
|
for (f2 = 0.0, psiz = 0, c = 0; c < CPUSTATES; c++) { |
|
i = cpuorder[c]; |
|
f1 = cputime(i); |
|
f2 += f1; |
|
l = (int) ((f2 + 1.0) / 2.0) - psiz; |
|
if (c == 0) |
|
putfloat(f1, GRAPHROW, GRAPHCOL + 1, 5, 1, 0); |
|
else |
|
putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c + 1, 5, 1, 0); |
|
mvhline(GRAPHROW + 2, psiz, cpuchar[c], l); |
|
psiz += l; |
|
} |
|
|
|
PUTRATE(us, us1, uvmexp->pageins, PAGEROW + 2, PAGECOL + 5, 5); |
|
PUTRATE(us, us1, uvmexp->pdpageouts, PAGEROW + 2, PAGECOL + 10, 5); |
|
PUTRATE(us, us1, uvmexp->swapins, PAGEROW + 2, PAGECOL + 15, 5); |
|
PUTRATE(us, us1, uvmexp->swapouts, PAGEROW + 2, PAGECOL + 20, 5); |
|
PUTRATE(us, us1, uvmexp->pgswapin, PAGEROW + 3, PAGECOL + 5, 5); |
|
PUTRATE(us, us1, uvmexp->pgswapout, PAGEROW + 3, PAGECOL + 10, 5); |
|
} |
|
|
|
void |
|
showvmstat(void) |
|
{ |
|
int inttotal; |
int i, l, r, c; |
int i, l, r, c; |
static int failcnt = 0; |
static int failcnt = 0; |
static int relabel = 0; |
static int relabel = 0; |
Line 426 showvmstat(void) |
|
Line 494 showvmstat(void) |
|
} |
} |
|
|
cpuswap(); |
cpuswap(); |
if (state == TIME) { |
if (display_mode == TIME) { |
dkswap(); |
dkswap(); |
tpswap(); |
tpswap(); |
etime = cur.cp_etime; |
etime = cur.cp_etime; |
Line 447 showvmstat(void) |
|
Line 515 showvmstat(void) |
|
} else |
} else |
etime = 1.0; |
etime = 1.0; |
|
|
failcnt = 0; |
show_vmstat_top(&s.Total, &s.uvmexp, &s1.uvmexp); |
inttotal = 0; |
|
for (i = 0; i < nintr; i++) { |
|
if (s.intrcnt[i] == 0) |
|
continue; |
|
if (intrloc[i] == 0) { |
|
if (nextintsrow == LINES) |
|
continue; |
|
intrloc[i] = nextintsrow++; |
|
mvprintw(intrloc[i], INTSCOL + 9, "%-.*s", |
|
INTSCOLEND - (INTSCOL + 9), intrname[i]); |
|
} |
|
X(intrcnt); |
|
l = (int)((float)s.intrcnt[i]/etime + 0.5); |
|
inttotal += l; |
|
putint(l, intrloc[i], INTSCOL, 8); |
|
} |
|
for (i = 0; i < nevcnt; i++) { |
|
if (s.evcnt[i] == 0) |
|
continue; |
|
if (ie_head[i].ie_loc == 0) { |
|
if (nextintsrow == LINES) |
|
continue; |
|
ie_head[i].ie_loc = nextintsrow++; |
|
print_ie_title(i); |
|
} |
|
X(evcnt); |
|
l = (int)((float)s.evcnt[i]/etime + 0.5); |
|
inttotal += l; |
|
putint(l, ie_head[i].ie_loc, INTSCOL, 8); |
|
} |
|
putint(inttotal, INTSROW, INTSCOL, 8); |
|
Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss); |
|
Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes); |
|
s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits + |
|
nchtotal.ncs_miss + nchtotal.ncs_long; |
|
if (state == TIME) |
|
s1.nchcount = s.nchcount; |
|
|
|
psiz = 0; |
|
f2 = 0.0; |
|
|
|
/* |
|
* Last CPU state not calculated yet. |
|
*/ |
|
for (c = 0; c < CPUSTATES; c++) { |
|
i = cpuorder[c]; |
|
f1 = cputime(i); |
|
f2 += f1; |
|
l = (int) ((f2 + 1.0) / 2.0) - psiz; |
|
if (c == 0) |
|
putfloat(f1, GRAPHROW, GRAPHCOL + 1, 5, 1, 0); |
|
else |
|
putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c + 1, 5, 1, 0); |
|
mvhline(GRAPHROW + 2, psiz, cpuchar[c], l); |
|
psiz += l; |
|
} |
|
|
|
putint(ucount(), STATROW, STATCOL, 3); |
/* Memory totals */ |
putfloat(avenrun[0], STATROW, STATCOL + 17, 6, 2, 0); |
|
putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0); |
|
putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0); |
|
mvaddstr(STATROW, STATCOL + 53, buf); |
|
#define pgtokb(pg) ((pg) * (s.uvmexp.pagesize / 1024)) |
#define pgtokb(pg) ((pg) * (s.uvmexp.pagesize / 1024)) |
|
|
putint(pgtokb(s.uvmexp.active), MEMROW + 2, MEMCOL + 6, 8); |
putint(pgtokb(s.uvmexp.active), MEMROW + 2, MEMCOL + 6, 8); |
putint(pgtokb(s.uvmexp.active + s.uvmexp.swpginuse), /* XXX */ |
putint(pgtokb(s.uvmexp.active + s.uvmexp.swpginuse), /* XXX */ |
MEMROW + 2, MEMCOL + 15, 8); |
MEMROW + 2, MEMCOL + 15, 8); |
Line 521 showvmstat(void) |
|
Line 528 showvmstat(void) |
|
putint(pgtokb(s.uvmexp.free), MEMROW + 2, MEMCOL + 24, 8); |
putint(pgtokb(s.uvmexp.free), MEMROW + 2, MEMCOL + 24, 8); |
putint(pgtokb(s.uvmexp.free + s.uvmexp.swpages - s.uvmexp.swpginuse), |
putint(pgtokb(s.uvmexp.free + s.uvmexp.swpages - s.uvmexp.swpginuse), |
MEMROW + 3, MEMCOL + 24, 8); |
MEMROW + 3, MEMCOL + 24, 8); |
putint(total.t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3); |
#undef pgtokb |
putint(total.t_dw, PROCSROW + 1, PROCSCOL + 6, 3); |
|
putint(total.t_sl, PROCSROW + 1, PROCSCOL + 9, 3); |
/* Namei cache */ |
putint(total.t_sw, PROCSROW + 1, PROCSCOL + 12, 3); |
Z(s, s1, ncs_goodhits); Z(s, s1, ncs_badhits); Z(s, s1, ncs_miss); |
PUTRATE(uvmexp.forks, VMSTATROW + 0, VMSTATCOL + 3, 6); |
Z(s, s1, ncs_long); Z(s, s1, ncs_pass2); Z(s, s1, ncs_2passes); |
PUTRATE(uvmexp.forks_ppwait, VMSTATROW + 1, VMSTATCOL + 3, 6); |
s.nchcount = s.nchstats.ncs_goodhits + s.nchstats.ncs_badhits + |
PUTRATE(uvmexp.forks_sharevm, VMSTATROW + 2, VMSTATCOL + 3, 6); |
s.nchstats.ncs_miss + s.nchstats.ncs_long; |
PUTRATE(uvmexp.fltpgwait, VMSTATROW + 3, VMSTATCOL + 4, 5); |
if (display_mode == TIME) |
PUTRATE(uvmexp.fltrelck, VMSTATROW + 4, VMSTATCOL + 3, 6); |
s1.nchcount = s.nchcount; |
PUTRATE(uvmexp.fltrelckok, VMSTATROW + 5, VMSTATCOL + 3, 6); |
|
PUTRATE(uvmexp.fltnoram, VMSTATROW + 6, VMSTATCOL + 3, 6); |
putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9); |
PUTRATE(uvmexp.fltamcopy, VMSTATROW + 7, VMSTATCOL + 3, 6); |
putint(s.nchstats.ncs_goodhits, NAMEIROW + 2, NAMEICOL + 9, 9); |
PUTRATE(uvmexp.flt_prcopy, VMSTATROW + 8, VMSTATCOL + 3, 6); |
#define nz(x) ((x) ? (x) : 1) |
PUTRATE(uvmexp.flt_przero, VMSTATROW + 9, VMSTATCOL + 3, 6); |
putfloat(s.nchstats.ncs_goodhits * 100.0 / nz(s.nchcount), |
PUTRATE(uvmexp.flt_acow, VMSTATROW + 10, VMSTATCOL, 9); |
NAMEIROW + 2, NAMEICOL + 19, 4, 0, 1); |
putint(s.uvmexp.freemin, VMSTATROW + 11, VMSTATCOL, 9); |
putint(s.nchstats.ncs_pass2, NAMEIROW + 2, NAMEICOL + 23, 9); |
putint(s.uvmexp.freetarg, VMSTATROW + 12, VMSTATCOL, 9); |
putfloat(s.nchstats.ncs_pass2 * 100.0 / nz(s.nchcount), |
putint(s.uvmexp.inactarg, VMSTATROW + 13, VMSTATCOL, 9); |
NAMEIROW + 2, NAMEICOL + 34, 4, 0, 1); |
putint(s.uvmexp.wired, VMSTATROW + 14, VMSTATCOL, 9); |
#undef nz |
PUTRATE(uvmexp.pdfreed, VMSTATROW + 15, VMSTATCOL, 9); |
|
if (LINES - 1 > VMSTATROW + 16) |
|
PUTRATE(uvmexp.pdscans, VMSTATROW + 16, VMSTATCOL, 9); |
|
|
|
PUTRATE(uvmexp.pageins, PAGEROW + 2, PAGECOL + 5, 5); |
/* Disks */ |
PUTRATE(uvmexp.pdpageouts, PAGEROW + 2, PAGECOL + 10, 5); |
|
PUTRATE(uvmexp.swapins, PAGEROW + 2, PAGECOL + 15, 5); |
|
PUTRATE(uvmexp.swapouts, PAGEROW + 2, PAGECOL + 20, 5); |
|
PUTRATE(uvmexp.pgswapin, PAGEROW + 3, PAGECOL + 5, 5); |
|
PUTRATE(uvmexp.pgswapout, PAGEROW + 3, PAGECOL + 10, 5); |
|
|
|
PUTRATE(uvmexp.swtch, GENSTATROW + 1, GENSTATCOL, 5); |
|
PUTRATE(uvmexp.traps, GENSTATROW + 1, GENSTATCOL + 5, 6); |
|
PUTRATE(uvmexp.syscalls, GENSTATROW + 1, GENSTATCOL + 11, 6); |
|
PUTRATE(uvmexp.intrs, GENSTATROW + 1, GENSTATCOL + 17, 5); |
|
PUTRATE(uvmexp.softs, GENSTATROW + 1, GENSTATCOL + 22, 5); |
|
PUTRATE(uvmexp.faults, GENSTATROW + 1, GENSTATCOL + 27, 6); |
|
for (l = 0, i = 0, r = DISKROW, c = DISKCOL; |
for (l = 0, i = 0, r = DISKROW, c = DISKCOL; |
i < (dk_ndrive + tp_ndrive); i++) { |
i < (dk_ndrive + tp_ndrive); i++) { |
if (i < dk_ndrive) { |
if (i < dk_ndrive) { |
Line 609 showvmstat(void) |
|
Line 601 showvmstat(void) |
|
} |
} |
} |
} |
last_disks = l; |
last_disks = l; |
putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9); |
|
putint(nchtotal.ncs_goodhits, NAMEIROW + 2, NAMEICOL + 9, 9); |
/* Interrupts */ |
#define nz(x) ((x) ? (x) : 1) |
failcnt = 0; |
putfloat(nchtotal.ncs_goodhits * 100.0 / nz(s.nchcount), |
inttotal = 0; |
NAMEIROW + 2, NAMEICOL + 19, 4, 0, 1); |
for (i = 0; i < nintr; i++) { |
putint(nchtotal.ncs_pass2, NAMEIROW + 2, NAMEICOL + 23, 9); |
if (s.intrcnt[i] == 0) |
putfloat(nchtotal.ncs_pass2 * 100.0 / nz(s.nchcount), |
continue; |
NAMEIROW + 2, NAMEICOL + 34, 4, 0, 1); |
if (intrloc[i] == 0) { |
#undef nz |
if (nextintsrow == LINES) |
|
continue; |
|
intrloc[i] = nextintsrow++; |
|
mvprintw(intrloc[i], INTSCOL + 9, "%-.*s", |
|
INTSCOLEND - (INTSCOL + 9), intrname[i]); |
|
} |
|
X(s, s1, intrcnt); |
|
l = (int)((float)s.intrcnt[i]/etime + 0.5); |
|
inttotal += l; |
|
putint(l, intrloc[i], INTSCOL, 8); |
|
} |
|
|
|
for (i = 0; i < nevcnt; i++) { |
|
if (s.evcnt[i] == 0) |
|
continue; |
|
if (ie_head[i].ie_loc == 0) { |
|
if (nextintsrow == LINES) |
|
continue; |
|
ie_head[i].ie_loc = nextintsrow++; |
|
print_ie_title(i); |
|
} |
|
X(s, s1, evcnt); |
|
l = (int)((float)s.evcnt[i]/etime + 0.5); |
|
inttotal += l; |
|
putint(l, ie_head[i].ie_loc, INTSCOL, 8); |
|
} |
|
putint(inttotal, INTSROW, INTSCOL, 8); |
|
|
|
PUTRATE(s, s1, uvmexp.forks, VMSTATROW + 0, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.forks_ppwait, VMSTATROW + 1, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.forks_sharevm, VMSTATROW + 2, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.fltpgwait, VMSTATROW + 3, VMSTATCOL + 4, 5); |
|
PUTRATE(s, s1, uvmexp.fltrelck, VMSTATROW + 4, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.fltrelckok, VMSTATROW + 5, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.fltnoram, VMSTATROW + 6, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.fltamcopy, VMSTATROW + 7, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.flt_prcopy, VMSTATROW + 8, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.flt_przero, VMSTATROW + 9, VMSTATCOL + 3, 6); |
|
PUTRATE(s, s1, uvmexp.flt_acow, VMSTATROW + 10, VMSTATCOL, 9); |
|
putint(s.uvmexp.freemin, VMSTATROW + 11, VMSTATCOL, 9); |
|
putint(s.uvmexp.freetarg, VMSTATROW + 12, VMSTATCOL, 9); |
|
putint(s.uvmexp.inactarg, VMSTATROW + 13, VMSTATCOL, 9); |
|
putint(s.uvmexp.wired, VMSTATROW + 14, VMSTATCOL, 9); |
|
PUTRATE(s, s1, uvmexp.pdfreed, VMSTATROW + 15, VMSTATCOL, 9); |
|
if (LINES - 1 > VMSTATROW + 16) |
|
PUTRATE(s, s1, uvmexp.pdscans, VMSTATROW + 16, VMSTATCOL, 9); |
|
|
} |
} |
|
|
void |
void |
vmstat_boot(char *args) |
vmstat_boot(char *args) |
{ |
{ |
copyinfo(&z, &s1); |
copyinfo(&z, &s1); |
state = BOOT; |
display_mode = BOOT; |
} |
} |
|
|
void |
void |
vmstat_run(char *args) |
vmstat_run(char *args) |
{ |
{ |
copyinfo(&s1, &s2); |
copyinfo(&s1, &s2); |
state = RUN; |
display_mode = RUN; |
} |
} |
|
|
void |
void |
vmstat_time(char *args) |
vmstat_time(char *args) |
{ |
{ |
state = TIME; |
display_mode = TIME; |
} |
} |
|
|
void |
void |
vmstat_zero(char *args) |
vmstat_zero(char *args) |
{ |
{ |
if (state == RUN) |
if (display_mode == RUN) |
getinfo(&s1, RUN); |
getinfo(&s1); |
} |
} |
|
|
/* calculate number of users on the system */ |
/* calculate number of users on the system */ |
Line 686 cputime(int indx) |
|
Line 724 cputime(int indx) |
|
return (cur.cp_time[indx] * 100.0 / t); |
return (cur.cp_time[indx] * 100.0 / t); |
} |
} |
|
|
static void |
void |
puthumanint(u_int64_t n, int l, int c, int w) |
puthumanint(u_int64_t n, int l, int c, int w) |
{ |
{ |
char b[128]; |
char b[128]; |
Line 701 puthumanint(u_int64_t n, int l, int c, i |
|
Line 739 puthumanint(u_int64_t n, int l, int c, i |
|
hline('*', w); |
hline('*', w); |
return; |
return; |
} |
} |
hline(' ', w - strlen(b)); |
printw("%*s", w, b); |
mvaddstr(l, c + w - strlen(b), b); |
|
} |
} |
|
|
static void |
void |
putint(int n, int l, int c, int w) |
putint(int n, int l, int c, int w) |
{ |
{ |
char b[128]; |
char b[128]; |
Line 718 putint(int n, int l, int c, int w) |
|
Line 755 putint(int n, int l, int c, int w) |
|
} |
} |
(void)snprintf(b, sizeof b, "%*d", w, n); |
(void)snprintf(b, sizeof b, "%*d", w, n); |
if (strlen(b) > w) { |
if (strlen(b) > w) { |
hline('*', w); |
if (display_mode == TIME) |
|
hline('*', w); |
|
else |
|
puthumanint(n, l, c, w); |
return; |
return; |
} |
} |
addstr(b); |
addstr(b); |
} |
} |
|
|
static void |
void |
putfloat(double f, int l, int c, int w, int d, int nz) |
putfloat(double f, int l, int c, int w, int d, int nz) |
{ |
{ |
char b[128]; |
char b[128]; |
Line 744 putfloat(double f, int l, int c, int w, |
|
Line 784 putfloat(double f, int l, int c, int w, |
|
} |
} |
|
|
static void |
static void |
getinfo(struct Info *stats, enum state st) |
getinfo(struct Info *stats) |
{ |
{ |
int mib[2]; |
int mib[2]; |
size_t size; |
size_t size; |