Lines 66-72
Link Here
|
66 |
#include <time.h> |
66 |
#include <time.h> |
67 |
#include <unistd.h> |
67 |
#include <unistd.h> |
68 |
#include <utmpx.h> |
68 |
#include <utmpx.h> |
69 |
#include <devstat.h> |
|
|
70 |
#include "systat.h" |
69 |
#include "systat.h" |
71 |
#include "extern.h" |
70 |
#include "extern.h" |
72 |
#include "devs.h" |
71 |
#include "devs.h" |
Lines 125-131
Link Here
|
125 |
static u_long kmem_size; |
124 |
static u_long kmem_size; |
126 |
static u_int v_page_count; |
125 |
static u_int v_page_count; |
127 |
|
126 |
|
128 |
struct statinfo cur, last, run; |
|
|
129 |
|
127 |
|
130 |
#define total s.Total |
128 |
#define total s.Total |
131 |
#define nchtotal s.nchstats |
129 |
#define nchtotal s.nchstats |
Lines 137-149
Link Here
|
137 |
static void allocinfo(struct Info *); |
135 |
static void allocinfo(struct Info *); |
138 |
static void copyinfo(struct Info *, struct Info *); |
136 |
static void copyinfo(struct Info *, struct Info *); |
139 |
static float cputime(int); |
137 |
static float cputime(int); |
140 |
static void dinfo(int, int, struct statinfo *, struct statinfo *); |
|
|
141 |
static void do_putuint64(uint64_t, int, int, int, int); |
138 |
static void do_putuint64(uint64_t, int, int, int, int); |
142 |
static void getinfo(struct Info *); |
139 |
static void getinfo(struct Info *); |
143 |
static void putint(int, int, int, int); |
|
|
144 |
static void putuint64(uint64_t, int, int, int); |
140 |
static void putuint64(uint64_t, int, int, int); |
145 |
static void putfloat(double, int, int, int, int, int); |
|
|
146 |
static void putlongdouble(long double, int, int, int, int, int); |
147 |
static int ucount(void); |
141 |
static int ucount(void); |
148 |
|
142 |
|
149 |
static int ncpu; |
143 |
static int ncpu; |
Lines 209-226
Link Here
|
209 |
int i; |
203 |
int i; |
210 |
size_t sz; |
204 |
size_t sz; |
211 |
|
205 |
|
212 |
if ((num_devices = devstat_getnumdevs(NULL)) < 0) { |
206 |
if (dsinit(MAXDRIVES) != 1) |
213 |
warnx("%s", devstat_errbuf); |
|
|
214 |
return(0); |
207 |
return(0); |
215 |
} |
|
|
216 |
|
208 |
|
217 |
cur.dinfo = calloc(1, sizeof(struct devinfo)); |
|
|
218 |
last.dinfo = calloc(1, sizeof(struct devinfo)); |
219 |
run.dinfo = calloc(1, sizeof(struct devinfo)); |
220 |
|
221 |
if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) |
222 |
return(0); |
223 |
|
224 |
if (nintr == 0) { |
209 |
if (nintr == 0) { |
225 |
if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { |
210 |
if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { |
226 |
error("sysctl(hw.intrcnt...) failed: %s", |
211 |
error("sysctl(hw.intrcnt...) failed: %s", |
Lines 371-397
Link Here
|
371 |
mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); |
356 |
mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); |
372 |
mvprintw(NAMEIROW + 1, NAMEICOL, |
357 |
mvprintw(NAMEIROW + 1, NAMEICOL, |
373 |
" Calls hits %% hits %%"); |
358 |
" Calls hits %% hits %%"); |
374 |
mvprintw(DISKROW, DISKCOL, "Disks"); |
359 |
dslabel(MAXDRIVES, DISKCOL, DISKROW); |
375 |
mvprintw(DISKROW + 1, DISKCOL, "KB/t"); |
|
|
376 |
mvprintw(DISKROW + 2, DISKCOL, "tps"); |
377 |
mvprintw(DISKROW + 3, DISKCOL, "MB/s"); |
378 |
mvprintw(DISKROW + 4, DISKCOL, "%%busy"); |
379 |
/* |
380 |
* For now, we don't support a fourth disk statistic. So there's |
381 |
* no point in providing a label for it. If someone can think of a |
382 |
* fourth useful disk statistic, there is room to add it. |
383 |
*/ |
384 |
/* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ |
385 |
j = 0; |
386 |
for (i = 0; i < num_devices && j < MAXDRIVES; i++) |
387 |
if (dev_select[i].selected) { |
388 |
char tmpstr[80]; |
389 |
sprintf(tmpstr, "%s%d", dev_select[i].device_name, |
390 |
dev_select[i].unit_number); |
391 |
mvprintw(DISKROW, DISKCOL + 5 + 6 * j, |
392 |
" %5.5s", tmpstr); |
393 |
j++; |
394 |
} |
395 |
|
360 |
|
396 |
for (i = 0; i < nintr; i++) { |
361 |
for (i = 0; i < nintr; i++) { |
397 |
if (intrloc[i] == 0) |
362 |
if (intrloc[i] == 0) |
Lines 401-407
Link Here
|
401 |
} |
366 |
} |
402 |
|
367 |
|
403 |
#define X(fld) {t=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=t;} |
368 |
#define X(fld) {t=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=t;} |
404 |
#define Q(fld) {t=cur.fld[i]; cur.fld[i]-=last.fld[i]; if(state==TIME) last.fld[i]=t;} |
369 |
#define Q(fld) {t=cur_dev.fld[i]; cur_dev.fld[i]-=last_dev.fld[i]; if(state==TIME) last_dev.fld[i]=t;} |
405 |
#define Y(fld) {t = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = t;} |
370 |
#define Y(fld) {t = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = t;} |
406 |
#define Z(fld) {t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ |
371 |
#define Z(fld) {t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ |
407 |
if(state == TIME) s1.nchstats.fld = t;} |
372 |
if(state == TIME) s1.nchstats.fld = t;} |
Lines 543-562
Link Here
|
543 |
PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); |
508 |
PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); |
544 |
PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); |
509 |
PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); |
545 |
PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); |
510 |
PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); |
546 |
for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++) |
511 |
switch(state) { |
547 |
if (dev_select[i].selected) { |
512 |
case TIME: |
548 |
switch(state) { |
513 |
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev); |
549 |
case TIME: |
514 |
break; |
550 |
dinfo(i, ++lc, &cur, &last); |
515 |
case RUN: |
551 |
break; |
516 |
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev); |
552 |
case RUN: |
517 |
break; |
553 |
dinfo(i, ++lc, &cur, &run); |
518 |
case BOOT: |
554 |
break; |
519 |
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL); |
555 |
case BOOT: |
520 |
break; |
556 |
dinfo(i, ++lc, &cur, NULL); |
521 |
} |
557 |
break; |
|
|
558 |
} |
559 |
} |
560 |
putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); |
522 |
putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); |
561 |
putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); |
523 |
putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); |
562 |
putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); |
524 |
putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); |
Lines 582-595
Link Here
|
582 |
if (prefix(cmd, "run")) { |
544 |
if (prefix(cmd, "run")) { |
583 |
retval = 1; |
545 |
retval = 1; |
584 |
copyinfo(&s2, &s1); |
546 |
copyinfo(&s2, &s1); |
585 |
switch (devstat_getdevs(NULL, &run)) { |
547 |
switch (devstat_getdevs(NULL, &run_dev)) { |
586 |
case -1: |
548 |
case -1: |
587 |
errx(1, "%s", devstat_errbuf); |
549 |
errx(1, "%s", devstat_errbuf); |
588 |
break; |
550 |
break; |
589 |
case 1: |
551 |
case 1: |
590 |
num_devices = run.dinfo->numdevs; |
552 |
num_devices = run_dev.dinfo->numdevs; |
591 |
generation = run.dinfo->generation; |
553 |
generation = run_dev.dinfo->generation; |
592 |
retval = dscmd("refresh", NULL, MAXDRIVES, &cur); |
554 |
retval = dscmd("refresh", NULL, MAXDRIVES, &cur_dev); |
593 |
if (retval == 2) |
555 |
if (retval == 2) |
594 |
labelkre(); |
556 |
labelkre(); |
595 |
break; |
557 |
break; |
Lines 612-625
Link Here
|
612 |
retval = 1; |
574 |
retval = 1; |
613 |
if (state == RUN) { |
575 |
if (state == RUN) { |
614 |
getinfo(&s1); |
576 |
getinfo(&s1); |
615 |
switch (devstat_getdevs(NULL, &run)) { |
577 |
switch (devstat_getdevs(NULL, &run_dev)) { |
616 |
case -1: |
578 |
case -1: |
617 |
errx(1, "%s", devstat_errbuf); |
579 |
errx(1, "%s", devstat_errbuf); |
618 |
break; |
580 |
break; |
619 |
case 1: |
581 |
case 1: |
620 |
num_devices = run.dinfo->numdevs; |
582 |
num_devices = run_dev.dinfo->numdevs; |
621 |
generation = run.dinfo->generation; |
583 |
generation = run_dev.dinfo->generation; |
622 |
retval = dscmd("refresh",NULL, MAXDRIVES, &cur); |
584 |
retval = dscmd("refresh",NULL, MAXDRIVES, &cur_dev); |
623 |
if (retval == 2) |
585 |
if (retval == 2) |
624 |
labelkre(); |
586 |
labelkre(); |
625 |
break; |
587 |
break; |
Lines 629-635
Link Here
|
629 |
} |
591 |
} |
630 |
return (retval); |
592 |
return (retval); |
631 |
} |
593 |
} |
632 |
retval = dscmd(cmd, args, MAXDRIVES, &cur); |
594 |
retval = dscmd(cmd, args, MAXDRIVES, &cur_dev); |
633 |
|
595 |
|
634 |
if (retval == 2) |
596 |
if (retval == 2) |
635 |
labelkre(); |
597 |
labelkre(); |
Lines 667-673
Link Here
|
667 |
return (s.time[indx] * 100.0 / lt); |
629 |
return (s.time[indx] * 100.0 / lt); |
668 |
} |
630 |
} |
669 |
|
631 |
|
670 |
static void |
632 |
void |
671 |
putint(int n, int l, int lc, int w) |
633 |
putint(int n, int l, int lc, int w) |
672 |
{ |
634 |
{ |
673 |
|
635 |
|
Lines 713-719
Link Here
|
713 |
addstr(b); |
675 |
addstr(b); |
714 |
} |
676 |
} |
715 |
|
677 |
|
716 |
static void |
678 |
void |
717 |
putfloat(double f, int l, int lc, int w, int d, int nz) |
679 |
putfloat(double f, int l, int lc, int w, int d, int nz) |
718 |
{ |
680 |
{ |
719 |
int snr; |
681 |
int snr; |
Lines 745-751
Link Here
|
745 |
addstr(b); |
707 |
addstr(b); |
746 |
} |
708 |
} |
747 |
|
709 |
|
748 |
static void |
710 |
void |
749 |
putlongdouble(long double f, int l, int lc, int w, int d, int nz) |
711 |
putlongdouble(long double f, int l, int lc, int w, int d, int nz) |
750 |
{ |
712 |
{ |
751 |
int snr; |
713 |
int snr; |
Lines 785-791
Link Here
|
785 |
int mib[2]; |
747 |
int mib[2]; |
786 |
|
748 |
|
787 |
GETSYSCTL("kern.cp_time", ls->time); |
749 |
GETSYSCTL("kern.cp_time", ls->time); |
788 |
GETSYSCTL("kern.cp_time", cur.cp_time); |
750 |
GETSYSCTL("kern.cp_time", cur_dev.cp_time); |
789 |
GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch); |
751 |
GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch); |
790 |
GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap); |
752 |
GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap); |
791 |
GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall); |
753 |
GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall); |
Lines 838-860
Link Here
|
838 |
size != sizeof(ncpu)) |
800 |
size != sizeof(ncpu)) |
839 |
ncpu = 1; |
801 |
ncpu = 1; |
840 |
|
802 |
|
841 |
tmp_dinfo = last.dinfo; |
803 |
tmp_dinfo = last_dev.dinfo; |
842 |
last.dinfo = cur.dinfo; |
804 |
last_dev.dinfo = cur_dev.dinfo; |
843 |
cur.dinfo = tmp_dinfo; |
805 |
cur_dev.dinfo = tmp_dinfo; |
844 |
|
806 |
|
845 |
last.snap_time = cur.snap_time; |
807 |
last_dev.snap_time = cur_dev.snap_time; |
846 |
switch (devstat_getdevs(NULL, &cur)) { |
808 |
dsgetinfo(&cur_dev); |
847 |
case -1: |
|
|
848 |
errx(1, "%s", devstat_errbuf); |
849 |
break; |
850 |
case 1: |
851 |
num_devices = cur.dinfo->numdevs; |
852 |
generation = cur.dinfo->generation; |
853 |
cmdkre("refresh", NULL); |
854 |
break; |
855 |
default: |
856 |
break; |
857 |
} |
858 |
} |
809 |
} |
859 |
|
810 |
|
860 |
static void |
811 |
static void |
Lines 881-918
Link Here
|
881 |
|
832 |
|
882 |
bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); |
833 |
bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); |
883 |
} |
834 |
} |
884 |
|
|
|
885 |
static void |
886 |
dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) |
887 |
{ |
888 |
long double transfers_per_second; |
889 |
long double kb_per_transfer, mb_per_second; |
890 |
long double elapsed_time, device_busy; |
891 |
int di; |
892 |
|
893 |
di = dev_select[dn].position; |
894 |
|
895 |
if (then != NULL) { |
896 |
/* Calculate relative to previous sample */ |
897 |
elapsed_time = now->snap_time - then->snap_time; |
898 |
} else { |
899 |
/* Calculate relative to device creation */ |
900 |
elapsed_time = now->snap_time - devstat_compute_etime( |
901 |
&now->dinfo->devices[di].creation_time, NULL); |
902 |
} |
903 |
|
904 |
if (devstat_compute_statistics(&now->dinfo->devices[di], then ? |
905 |
&then->dinfo->devices[di] : NULL, elapsed_time, |
906 |
DSM_KB_PER_TRANSFER, &kb_per_transfer, |
907 |
DSM_TRANSFERS_PER_SECOND, &transfers_per_second, |
908 |
DSM_MB_PER_SECOND, &mb_per_second, |
909 |
DSM_BUSY_PCT, &device_busy, |
910 |
DSM_NONE) != 0) |
911 |
errx(1, "%s", devstat_errbuf); |
912 |
|
913 |
lc = DISKCOL + lc * 6; |
914 |
putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); |
915 |
putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); |
916 |
putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); |
917 |
putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); |
918 |
} |