Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/systat/vmstat.c
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
#include <nlist.h> | #include <nlist.h> | ||||
#include <paths.h> | #include <paths.h> | ||||
#include <signal.h> | #include <signal.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <time.h> | #include <time.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <utmpx.h> | #include <utmpx.h> | ||||
#include <devstat.h> | |||||
#include "systat.h" | #include "systat.h" | ||||
#include "extern.h" | #include "extern.h" | ||||
#include "devs.h" | #include "devs.h" | ||||
static struct Info { | static struct Info { | ||||
long time[CPUSTATES]; | long time[CPUSTATES]; | ||||
uint64_t v_swtch; /* context switches */ | uint64_t v_swtch; /* context switches */ | ||||
uint64_t v_trap; /* calls to trap */ | uint64_t v_trap; /* calls to trap */ | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static struct Info { | ||||
int desiredvnodes; | int desiredvnodes; | ||||
long numvnodes; | long numvnodes; | ||||
long freevnodes; | long freevnodes; | ||||
int numdirtybuffers; | int numdirtybuffers; | ||||
} s, s1, s2, z; | } s, s1, s2, z; | ||||
static u_long kmem_size; | static u_long kmem_size; | ||||
static u_int v_page_count; | static u_int v_page_count; | ||||
struct statinfo cur, last, run; | |||||
#define total s.Total | #define total s.Total | ||||
#define nchtotal s.nchstats | #define nchtotal s.nchstats | ||||
#define oldnchtotal s1.nchstats | #define oldnchtotal s1.nchstats | ||||
static enum state { BOOT, TIME, RUN } state = TIME; | static enum state { BOOT, TIME, RUN } state = TIME; | ||||
enum divisor { IEC = 0, SI = HN_DIVISOR_1000 }; | enum divisor { IEC = 0, SI = HN_DIVISOR_1000 }; | ||||
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, struct statinfo *, struct statinfo *); | |||||
static void do_putuint64(uint64_t, int, int, int, int); | static void do_putuint64(uint64_t, int, int, int, int); | ||||
static void getinfo(struct Info *); | static void getinfo(struct Info *); | ||||
static void putint(int, int, int, int); | |||||
static void putuint64(uint64_t, int, int, int); | static void putuint64(uint64_t, int, int, int); | ||||
static void putfloat(double, int, int, int, int, int); | |||||
static void putlongdouble(long double, int, int, int, int, int); | |||||
static int ucount(void); | static int ucount(void); | ||||
static int ncpu; | static int ncpu; | ||||
static char buf[26]; | static char buf[26]; | ||||
static time_t t; | static time_t t; | ||||
static double etime; | static double etime; | ||||
static int nintr; | static int nintr; | ||||
static long *intrloc; | static long *intrloc; | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
initkre(void) | initkre(void) | ||||
{ | { | ||||
char *cp, *cp1, *cp2, *intrnamebuf, *nextcp; | char *cp, *cp1, *cp2, *intrnamebuf, *nextcp; | ||||
int i; | int i; | ||||
size_t sz; | size_t sz; | ||||
if ((num_devices = devstat_getnumdevs(NULL)) < 0) { | if (dsinit(MAXDRIVES) != 1) | ||||
warnx("%s", devstat_errbuf); | |||||
return(0); | return(0); | ||||
} | |||||
cur.dinfo = calloc(1, sizeof(struct devinfo)); | |||||
last.dinfo = calloc(1, sizeof(struct devinfo)); | |||||
run.dinfo = calloc(1, sizeof(struct devinfo)); | |||||
if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) | |||||
return(0); | |||||
if (nintr == 0) { | if (nintr == 0) { | ||||
if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { | if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { | ||||
error("sysctl(hw.intrcnt...) failed: %s", | error("sysctl(hw.intrcnt...) failed: %s", | ||||
strerror(errno)); | strerror(errno)); | ||||
return (0); | return (0); | ||||
} | } | ||||
nintr = sz / sizeof(u_long); | nintr = sz / sizeof(u_long); | ||||
intrloc = calloc(nintr, sizeof (long)); | intrloc = calloc(nintr, sizeof (long)); | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | labelkre(void) | ||||
mvprintw(VNSTATROW, VNSTATCOL + 8, "dtbuf"); | mvprintw(VNSTATROW, VNSTATCOL + 8, "dtbuf"); | ||||
mvprintw(VNSTATROW + 1, VNSTATCOL + 8, "desvn"); | mvprintw(VNSTATROW + 1, VNSTATCOL + 8, "desvn"); | ||||
mvprintw(VNSTATROW + 2, VNSTATCOL + 8, "numvn"); | mvprintw(VNSTATROW + 2, VNSTATCOL + 8, "numvn"); | ||||
mvprintw(VNSTATROW + 3, VNSTATCOL + 8, "frevn"); | mvprintw(VNSTATROW + 3, VNSTATCOL + 8, "frevn"); | ||||
mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); | mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); | ||||
mvprintw(NAMEIROW + 1, NAMEICOL, | mvprintw(NAMEIROW + 1, NAMEICOL, | ||||
" Calls hits %% hits %%"); | " Calls hits %% hits %%"); | ||||
mvprintw(DISKROW, DISKCOL, "Disks"); | dslabel(MAXDRIVES, DISKCOL, DISKROW); | ||||
mvprintw(DISKROW + 1, DISKCOL, "KB/t"); | |||||
mvprintw(DISKROW + 2, DISKCOL, "tps"); | |||||
mvprintw(DISKROW + 3, DISKCOL, "MB/s"); | |||||
mvprintw(DISKROW + 4, DISKCOL, "%%busy"); | |||||
/* | |||||
* For now, we don't support a fourth disk statistic. So there's | |||||
* no point in providing a label for it. If someone can think of a | |||||
* fourth useful disk statistic, there is room to add it. | |||||
*/ | |||||
/* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ | |||||
j = 0; | |||||
for (i = 0; i < num_devices && j < MAXDRIVES; i++) | |||||
if (dev_select[i].selected) { | |||||
char tmpstr[80]; | |||||
sprintf(tmpstr, "%s%d", dev_select[i].device_name, | |||||
dev_select[i].unit_number); | |||||
mvprintw(DISKROW, DISKCOL + 5 + 6 * j, | |||||
" %5.5s", tmpstr); | |||||
j++; | |||||
} | |||||
for (i = 0; i < nintr; i++) { | for (i = 0; i < nintr; i++) { | ||||
if (intrloc[i] == 0) | if (intrloc[i] == 0) | ||||
continue; | continue; | ||||
mvprintw(intrloc[i], INTSCOL + 6, "%-10.10s", intrname[i]); | mvprintw(intrloc[i], INTSCOL + 6, "%-10.10s", intrname[i]); | ||||
} | } | ||||
} | } | ||||
#define X(fld) {t=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=t;} | #define X(fld) {t=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=t;} | ||||
#define Q(fld) {t=cur.fld[i]; cur.fld[i]-=last.fld[i]; if(state==TIME) last.fld[i]=t;} | #define Q(fld) {t=cur_dev.fld[i]; cur_dev.fld[i]-=last_dev.fld[i]; if(state==TIME) last_dev.fld[i]=t;} | ||||
#define Y(fld) {t = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = t;} | #define Y(fld) {t = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = t;} | ||||
#define Z(fld) {t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ | #define Z(fld) {t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ | ||||
if(state == TIME) s1.nchstats.fld = t;} | if(state == TIME) s1.nchstats.fld = t;} | ||||
#define PUTRATE(fld, l, c, w) \ | #define PUTRATE(fld, l, c, w) \ | ||||
do { \ | do { \ | ||||
Y(fld); \ | Y(fld); \ | ||||
putint((int)((float)s.fld/etime + 0.5), l, c, w); \ | putint((int)((float)s.fld/etime + 0.5), l, c, w); \ | ||||
} while (0) | } while (0) | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | #define pgtokb(pg) ((pg) * (s.v_page_size / 1024)) | ||||
PUTRATE(v_swappgsin, PAGEROW + 3, PAGECOL + 19, 5); | PUTRATE(v_swappgsin, PAGEROW + 3, PAGECOL + 19, 5); | ||||
PUTRATE(v_swappgsout, PAGEROW + 3, PAGECOL + 25, 5); | PUTRATE(v_swappgsout, PAGEROW + 3, PAGECOL + 25, 5); | ||||
PUTRATE(v_swtch, GENSTATROW + 1, GENSTATCOL, 4); | PUTRATE(v_swtch, GENSTATROW + 1, GENSTATCOL, 4); | ||||
PUTRATE(v_trap, GENSTATROW + 1, GENSTATCOL + 5, 4); | PUTRATE(v_trap, GENSTATROW + 1, GENSTATCOL + 5, 4); | ||||
PUTRATE(v_syscall, GENSTATROW + 1, GENSTATCOL + 10, 4); | PUTRATE(v_syscall, GENSTATROW + 1, GENSTATCOL + 10, 4); | ||||
PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); | PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); | ||||
PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); | PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); | ||||
PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); | PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); | ||||
for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++) | |||||
if (dev_select[i].selected) { | |||||
switch(state) { | switch(state) { | ||||
case TIME: | case TIME: | ||||
dinfo(i, ++lc, &cur, &last); | dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev); | ||||
break; | break; | ||||
case RUN: | case RUN: | ||||
dinfo(i, ++lc, &cur, &run); | dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev); | ||||
break; | break; | ||||
case BOOT: | case BOOT: | ||||
dinfo(i, ++lc, &cur, NULL); | dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL); | ||||
break; | break; | ||||
} | } | ||||
} | |||||
putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); | putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); | ||||
putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); | putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); | ||||
putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); | putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); | ||||
putint(s.freevnodes, VNSTATROW + 3, VNSTATCOL, 7); | putint(s.freevnodes, VNSTATROW + 3, VNSTATCOL, 7); | ||||
putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 8); | putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 8); | ||||
putint((nchtotal.ncs_goodhits + nchtotal.ncs_neghits), | putint((nchtotal.ncs_goodhits + nchtotal.ncs_neghits), | ||||
NAMEIROW + 2, NAMEICOL + 9, 7); | NAMEIROW + 2, NAMEICOL + 9, 7); | ||||
#define nz(x) ((x) ? (x) : 1) | #define nz(x) ((x) ? (x) : 1) | ||||
Show All 9 Lines | |||||
int | int | ||||
cmdkre(const char *cmd, const char *args) | cmdkre(const char *cmd, const char *args) | ||||
{ | { | ||||
int retval; | int retval; | ||||
if (prefix(cmd, "run")) { | if (prefix(cmd, "run")) { | ||||
retval = 1; | retval = 1; | ||||
copyinfo(&s2, &s1); | copyinfo(&s2, &s1); | ||||
switch (devstat_getdevs(NULL, &run)) { | switch (devstat_getdevs(NULL, &run_dev)) { | ||||
case -1: | case -1: | ||||
errx(1, "%s", devstat_errbuf); | errx(1, "%s", devstat_errbuf); | ||||
break; | break; | ||||
case 1: | case 1: | ||||
num_devices = run.dinfo->numdevs; | num_devices = run_dev.dinfo->numdevs; | ||||
generation = run.dinfo->generation; | generation = run_dev.dinfo->generation; | ||||
retval = dscmd("refresh", NULL, MAXDRIVES, &cur); | retval = dscmd("refresh", NULL, MAXDRIVES, &cur_dev); | ||||
if (retval == 2) | if (retval == 2) | ||||
labelkre(); | labelkre(); | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
state = RUN; | state = RUN; | ||||
return (retval); | return (retval); | ||||
} | } | ||||
if (prefix(cmd, "boot")) { | if (prefix(cmd, "boot")) { | ||||
state = BOOT; | state = BOOT; | ||||
copyinfo(&z, &s1); | copyinfo(&z, &s1); | ||||
return (1); | return (1); | ||||
} | } | ||||
if (prefix(cmd, "time")) { | if (prefix(cmd, "time")) { | ||||
state = TIME; | state = TIME; | ||||
return (1); | return (1); | ||||
} | } | ||||
if (prefix(cmd, "zero")) { | if (prefix(cmd, "zero")) { | ||||
retval = 1; | retval = 1; | ||||
if (state == RUN) { | if (state == RUN) { | ||||
getinfo(&s1); | getinfo(&s1); | ||||
switch (devstat_getdevs(NULL, &run)) { | switch (devstat_getdevs(NULL, &run_dev)) { | ||||
case -1: | case -1: | ||||
errx(1, "%s", devstat_errbuf); | errx(1, "%s", devstat_errbuf); | ||||
break; | break; | ||||
case 1: | case 1: | ||||
num_devices = run.dinfo->numdevs; | num_devices = run_dev.dinfo->numdevs; | ||||
generation = run.dinfo->generation; | generation = run_dev.dinfo->generation; | ||||
retval = dscmd("refresh",NULL, MAXDRIVES, &cur); | retval = dscmd("refresh",NULL, MAXDRIVES, &cur_dev); | ||||
if (retval == 2) | if (retval == 2) | ||||
labelkre(); | labelkre(); | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return (retval); | return (retval); | ||||
} | } | ||||
retval = dscmd(cmd, args, MAXDRIVES, &cur); | retval = dscmd(cmd, args, MAXDRIVES, &cur_dev); | ||||
if (retval == 2) | if (retval == 2) | ||||
labelkre(); | labelkre(); | ||||
return(retval); | return(retval); | ||||
} | } | ||||
/* calculate number of users on the system */ | /* calculate number of users on the system */ | ||||
Show All 21 Lines | cputime(int indx) | ||||
lt = 0; | lt = 0; | ||||
for (i = 0; i < CPUSTATES; i++) | for (i = 0; i < CPUSTATES; i++) | ||||
lt += s.time[i]; | lt += s.time[i]; | ||||
if (lt == 0.0) | if (lt == 0.0) | ||||
lt = 1.0; | lt = 1.0; | ||||
return (s.time[indx] * 100.0 / lt); | return (s.time[indx] * 100.0 / lt); | ||||
} | } | ||||
static void | void | ||||
putint(int n, int l, int lc, int w) | putint(int n, int l, int lc, int w) | ||||
{ | { | ||||
do_putuint64(n, l, lc, w, SI); | do_putuint64(n, l, lc, w, SI); | ||||
} | } | ||||
static void | static void | ||||
putuint64(uint64_t n, int l, int lc, int w) | putuint64(uint64_t n, int l, int lc, int w) | ||||
Show All 29 Lines | #endif | ||||
if (snr != w) { | if (snr != w) { | ||||
while (w-- > 0) | while (w-- > 0) | ||||
addch('*'); | addch('*'); | ||||
return; | return; | ||||
} | } | ||||
addstr(b); | addstr(b); | ||||
} | } | ||||
static void | void | ||||
putfloat(double f, int l, int lc, int w, int d, int nz) | putfloat(double f, int l, int lc, int w, int d, int nz) | ||||
{ | { | ||||
int snr; | int snr; | ||||
char b[128]; | char b[128]; | ||||
move(l, lc); | move(l, lc); | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
while (--w >= 0) | while (--w >= 0) | ||||
Show All 15 Lines | #endif | ||||
if (snr != w) { | if (snr != w) { | ||||
while (--w >= 0) | while (--w >= 0) | ||||
addch('*'); | addch('*'); | ||||
return; | return; | ||||
} | } | ||||
addstr(b); | addstr(b); | ||||
} | } | ||||
static void | void | ||||
putlongdouble(long double f, int l, int lc, int w, int d, int nz) | putlongdouble(long double f, int l, int lc, int w, int d, int nz) | ||||
{ | { | ||||
int snr; | int snr; | ||||
char b[128]; | char b[128]; | ||||
move(l, lc); | move(l, lc); | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
while (--w >= 0) | while (--w >= 0) | ||||
Show All 23 Lines | |||||
static void | static void | ||||
getinfo(struct Info *ls) | getinfo(struct Info *ls) | ||||
{ | { | ||||
struct devinfo *tmp_dinfo; | struct devinfo *tmp_dinfo; | ||||
size_t size; | size_t size; | ||||
int mib[2]; | int mib[2]; | ||||
GETSYSCTL("kern.cp_time", ls->time); | GETSYSCTL("kern.cp_time", ls->time); | ||||
GETSYSCTL("kern.cp_time", cur.cp_time); | GETSYSCTL("kern.cp_time", cur_dev.cp_time); | ||||
GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch); | GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch); | ||||
GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap); | GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap); | ||||
GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall); | GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall); | ||||
GETSYSCTL("vm.stats.sys.v_intr", ls->v_intr); | GETSYSCTL("vm.stats.sys.v_intr", ls->v_intr); | ||||
GETSYSCTL("vm.stats.sys.v_soft", ls->v_soft); | GETSYSCTL("vm.stats.sys.v_soft", ls->v_soft); | ||||
GETSYSCTL("vm.stats.vm.v_vm_faults", ls->v_vm_faults); | GETSYSCTL("vm.stats.vm.v_vm_faults", ls->v_vm_faults); | ||||
GETSYSCTL("vm.stats.vm.v_io_faults", ls->v_io_faults); | GETSYSCTL("vm.stats.vm.v_io_faults", ls->v_io_faults); | ||||
GETSYSCTL("vm.stats.vm.v_cow_faults", ls->v_cow_faults); | GETSYSCTL("vm.stats.vm.v_cow_faults", ls->v_cow_faults); | ||||
Show All 36 Lines | if (sysctl(mib, 2, &ls->Total, &size, NULL, 0) < 0) { | ||||
error("Can't get kernel info: %s\n", strerror(errno)); | error("Can't get kernel info: %s\n", strerror(errno)); | ||||
bzero(&ls->Total, sizeof(ls->Total)); | bzero(&ls->Total, sizeof(ls->Total)); | ||||
} | } | ||||
size = sizeof(ncpu); | size = sizeof(ncpu); | ||||
if (sysctlbyname("hw.ncpu", &ncpu, &size, NULL, 0) < 0 || | if (sysctlbyname("hw.ncpu", &ncpu, &size, NULL, 0) < 0 || | ||||
size != sizeof(ncpu)) | size != sizeof(ncpu)) | ||||
ncpu = 1; | ncpu = 1; | ||||
tmp_dinfo = last.dinfo; | tmp_dinfo = last_dev.dinfo; | ||||
last.dinfo = cur.dinfo; | last_dev.dinfo = cur_dev.dinfo; | ||||
cur.dinfo = tmp_dinfo; | cur_dev.dinfo = tmp_dinfo; | ||||
last.snap_time = cur.snap_time; | last_dev.snap_time = cur_dev.snap_time; | ||||
switch (devstat_getdevs(NULL, &cur)) { | dsgetinfo(&cur_dev); | ||||
case -1: | |||||
errx(1, "%s", devstat_errbuf); | |||||
break; | |||||
case 1: | |||||
num_devices = cur.dinfo->numdevs; | |||||
generation = cur.dinfo->generation; | |||||
cmdkre("refresh", NULL); | |||||
break; | |||||
default: | |||||
break; | |||||
} | } | ||||
} | |||||
static void | static void | ||||
allocinfo(struct Info *ls) | allocinfo(struct Info *ls) | ||||
{ | { | ||||
ls->intrcnt = (long *) calloc(nintr, sizeof(long)); | ls->intrcnt = (long *) calloc(nintr, sizeof(long)); | ||||
if (ls->intrcnt == NULL) | if (ls->intrcnt == NULL) | ||||
errx(2, "out of memory"); | errx(2, "out of memory"); | ||||
} | } | ||||
static void | static void | ||||
copyinfo(struct Info *from, struct Info *to) | copyinfo(struct Info *from, struct Info *to) | ||||
{ | { | ||||
long *intrcnt; | long *intrcnt; | ||||
/* | /* | ||||
* time, wds, seek, and xfer are malloc'd so we have to | * time, wds, seek, and xfer are malloc'd so we have to | ||||
* save the pointers before the structure copy and then | * save the pointers before the structure copy and then | ||||
* copy by hand. | * copy by hand. | ||||
*/ | */ | ||||
intrcnt = to->intrcnt; | intrcnt = to->intrcnt; | ||||
*to = *from; | *to = *from; | ||||
bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); | bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); | ||||
} | |||||
static void | |||||
dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) | |||||
{ | |||||
long double transfers_per_second; | |||||
long double kb_per_transfer, mb_per_second; | |||||
long double elapsed_time, device_busy; | |||||
int di; | |||||
di = dev_select[dn].position; | |||||
if (then != NULL) { | |||||
/* Calculate relative to previous sample */ | |||||
elapsed_time = now->snap_time - then->snap_time; | |||||
} else { | |||||
/* Calculate relative to device creation */ | |||||
elapsed_time = now->snap_time - devstat_compute_etime( | |||||
&now->dinfo->devices[di].creation_time, NULL); | |||||
} | |||||
if (devstat_compute_statistics(&now->dinfo->devices[di], then ? | |||||
&then->dinfo->devices[di] : NULL, elapsed_time, | |||||
DSM_KB_PER_TRANSFER, &kb_per_transfer, | |||||
DSM_TRANSFERS_PER_SECOND, &transfers_per_second, | |||||
DSM_MB_PER_SECOND, &mb_per_second, | |||||
DSM_BUSY_PCT, &device_busy, | |||||
DSM_NONE) != 0) | |||||
errx(1, "%s", devstat_errbuf); | |||||
lc = DISKCOL + lc * 6; | |||||
putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); | |||||
putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); | |||||
putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); | |||||
putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); | |||||
} | } |