Lines 63-69
Link Here
|
63 |
#include <time.h> |
63 |
#include <time.h> |
64 |
#include <unistd.h> |
64 |
#include <unistd.h> |
65 |
#include <utmpx.h> |
65 |
#include <utmpx.h> |
66 |
#include <devstat.h> |
|
|
67 |
#include "systat.h" |
66 |
#include "systat.h" |
68 |
#include "extern.h" |
67 |
#include "extern.h" |
69 |
#include "devs.h" |
68 |
#include "devs.h" |
Lines 122-128
Link Here
|
122 |
static u_long kmem_size; |
121 |
static u_long kmem_size; |
123 |
static u_int v_page_count; |
122 |
static u_int v_page_count; |
124 |
|
123 |
|
125 |
struct statinfo cur, last, run; |
|
|
126 |
|
124 |
|
127 |
#define total s.Total |
125 |
#define total s.Total |
128 |
#define nchtotal s.nchstats |
126 |
#define nchtotal s.nchstats |
Lines 133-143
Link Here
|
133 |
static void allocinfo(struct Info *); |
131 |
static void allocinfo(struct Info *); |
134 |
static void copyinfo(struct Info *, struct Info *); |
132 |
static void copyinfo(struct Info *, struct Info *); |
135 |
static float cputime(int); |
133 |
static float cputime(int); |
136 |
static void dinfo(int, int, struct statinfo *, struct statinfo *); |
|
|
137 |
static void getinfo(struct Info *); |
134 |
static void getinfo(struct Info *); |
138 |
static void putint(int, int, int, int); |
|
|
139 |
static void putfloat(double, int, int, int, int, int); |
140 |
static void putlongdouble(long double, int, int, int, int, int); |
141 |
static int ucount(void); |
135 |
static int ucount(void); |
142 |
|
136 |
|
143 |
static int ncpu; |
137 |
static int ncpu; |
Lines 203-220
Link Here
|
203 |
int i; |
197 |
int i; |
204 |
size_t sz; |
198 |
size_t sz; |
205 |
|
199 |
|
206 |
if ((num_devices = devstat_getnumdevs(NULL)) < 0) { |
200 |
if (dsinit(MAXDRIVES) != 1) |
207 |
warnx("%s", devstat_errbuf); |
|
|
208 |
return(0); |
201 |
return(0); |
209 |
} |
|
|
210 |
|
202 |
|
211 |
cur.dinfo = calloc(1, sizeof(struct devinfo)); |
|
|
212 |
last.dinfo = calloc(1, sizeof(struct devinfo)); |
213 |
run.dinfo = calloc(1, sizeof(struct devinfo)); |
214 |
|
215 |
if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) |
216 |
return(0); |
217 |
|
218 |
if (nintr == 0) { |
203 |
if (nintr == 0) { |
219 |
if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { |
204 |
if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { |
220 |
error("sysctl(hw.intrcnt...) failed: %s", |
205 |
error("sysctl(hw.intrcnt...) failed: %s", |
Lines 312-318
Link Here
|
312 |
|
297 |
|
313 |
clear(); |
298 |
clear(); |
314 |
mvprintw(STATROW, STATCOL + 6, "users Load"); |
299 |
mvprintw(STATROW, STATCOL + 6, "users Load"); |
315 |
mvprintw(STATROW + 1, STATCOL + 3, "Mem usage: %%Phy %%Kmem"); |
300 |
mvprintw(STATROW + 1, STATCOL + 3, "Mem usage: %%Phy %%Kmem %%VM"); |
316 |
mvprintw(MEMROW, MEMCOL, "Mem: KB REAL VIRTUAL"); |
301 |
mvprintw(MEMROW, MEMCOL, "Mem: KB REAL VIRTUAL"); |
317 |
mvprintw(MEMROW + 1, MEMCOL, " Tot Share Tot Share"); |
302 |
mvprintw(MEMROW + 1, MEMCOL, " Tot Share Tot Share"); |
318 |
mvprintw(MEMROW + 2, MEMCOL, "Act"); |
303 |
mvprintw(MEMROW + 2, MEMCOL, "Act"); |
Lines 365-391
Link Here
|
365 |
mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); |
350 |
mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); |
366 |
mvprintw(NAMEIROW + 1, NAMEICOL, |
351 |
mvprintw(NAMEIROW + 1, NAMEICOL, |
367 |
" Calls hits %% hits %%"); |
352 |
" Calls hits %% hits %%"); |
368 |
mvprintw(DISKROW, DISKCOL, "Disks"); |
353 |
dslabel(MAXDRIVES, DISKCOL, DISKROW); |
369 |
mvprintw(DISKROW + 1, DISKCOL, "KB/t"); |
|
|
370 |
mvprintw(DISKROW + 2, DISKCOL, "tps"); |
371 |
mvprintw(DISKROW + 3, DISKCOL, "MB/s"); |
372 |
mvprintw(DISKROW + 4, DISKCOL, "%%busy"); |
373 |
/* |
374 |
* For now, we don't support a fourth disk statistic. So there's |
375 |
* no point in providing a label for it. If someone can think of a |
376 |
* fourth useful disk statistic, there is room to add it. |
377 |
*/ |
378 |
/* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ |
379 |
j = 0; |
380 |
for (i = 0; i < num_devices && j < MAXDRIVES; i++) |
381 |
if (dev_select[i].selected) { |
382 |
char tmpstr[80]; |
383 |
sprintf(tmpstr, "%s%d", dev_select[i].device_name, |
384 |
dev_select[i].unit_number); |
385 |
mvprintw(DISKROW, DISKCOL + 5 + 6 * j, |
386 |
" %5.5s", tmpstr); |
387 |
j++; |
388 |
} |
389 |
|
354 |
|
390 |
for (i = 0; i < nintr; i++) { |
355 |
for (i = 0; i < nintr; i++) { |
391 |
if (intrloc[i] == 0) |
356 |
if (intrloc[i] == 0) |
Lines 488-493
Link Here
|
488 |
STATROW + 1, STATCOL + 15, 2, 0, 1); |
453 |
STATROW + 1, STATCOL + 15, 2, 0, 1); |
489 |
putfloat(100.0 * s.v_kmem_map_size / kmem_size, |
454 |
putfloat(100.0 * s.v_kmem_map_size / kmem_size, |
490 |
STATROW + 1, STATCOL + 22, 2, 0, 1); |
455 |
STATROW + 1, STATCOL + 22, 2, 0, 1); |
|
|
456 |
putfloat(100.0 * total.t_avm / total.t_vm, |
457 |
STATROW + 1, STATCOL + 30, 2, 0, 1); |
491 |
|
458 |
|
492 |
putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7); |
459 |
putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7); |
493 |
putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7); |
460 |
putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7); |
Lines 537-556
Link Here
|
537 |
PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); |
504 |
PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); |
538 |
PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); |
505 |
PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); |
539 |
PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); |
506 |
PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); |
540 |
for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++) |
507 |
switch(state) { |
541 |
if (dev_select[i].selected) { |
508 |
case TIME: |
542 |
switch(state) { |
509 |
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur, &last); |
543 |
case TIME: |
510 |
break; |
544 |
dinfo(i, ++lc, &cur, &last); |
511 |
case RUN: |
545 |
break; |
512 |
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur, &run); |
546 |
case RUN: |
513 |
break; |
547 |
dinfo(i, ++lc, &cur, &run); |
514 |
case BOOT: |
548 |
break; |
515 |
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur, NULL); |
549 |
case BOOT: |
516 |
break; |
550 |
dinfo(i, ++lc, &cur, NULL); |
517 |
} |
551 |
break; |
|
|
552 |
} |
553 |
} |
554 |
putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); |
518 |
putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); |
555 |
putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); |
519 |
putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); |
556 |
putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); |
520 |
putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); |
Lines 661-667
Link Here
|
661 |
return (s.time[indx] * 100.0 / lt); |
625 |
return (s.time[indx] * 100.0 / lt); |
662 |
} |
626 |
} |
663 |
|
627 |
|
664 |
static void |
628 |
void |
665 |
putint(int n, int l, int lc, int w) |
629 |
putint(int n, int l, int lc, int w) |
666 |
{ |
630 |
{ |
667 |
int snr; |
631 |
int snr; |
Lines 691-697
Link Here
|
691 |
addstr(b); |
655 |
addstr(b); |
692 |
} |
656 |
} |
693 |
|
657 |
|
694 |
static void |
658 |
void |
695 |
putfloat(double f, int l, int lc, int w, int d, int nz) |
659 |
putfloat(double f, int l, int lc, int w, int d, int nz) |
696 |
{ |
660 |
{ |
697 |
int snr; |
661 |
int snr; |
Lines 723-729
Link Here
|
723 |
addstr(b); |
687 |
addstr(b); |
724 |
} |
688 |
} |
725 |
|
689 |
|
726 |
static void |
690 |
void |
727 |
putlongdouble(long double f, int l, int lc, int w, int d, int nz) |
691 |
putlongdouble(long double f, int l, int lc, int w, int d, int nz) |
728 |
{ |
692 |
{ |
729 |
int snr; |
693 |
int snr; |
Lines 821-838
Link Here
|
821 |
cur.dinfo = tmp_dinfo; |
785 |
cur.dinfo = tmp_dinfo; |
822 |
|
786 |
|
823 |
last.snap_time = cur.snap_time; |
787 |
last.snap_time = cur.snap_time; |
824 |
switch (devstat_getdevs(NULL, &cur)) { |
788 |
dsgetinfo(&cur); |
825 |
case -1: |
|
|
826 |
errx(1, "%s", devstat_errbuf); |
827 |
break; |
828 |
case 1: |
829 |
num_devices = cur.dinfo->numdevs; |
830 |
generation = cur.dinfo->generation; |
831 |
cmdkre("refresh", NULL); |
832 |
break; |
833 |
default: |
834 |
break; |
835 |
} |
836 |
} |
789 |
} |
837 |
|
790 |
|
838 |
static void |
791 |
static void |
Lines 859-896
Link Here
|
859 |
|
812 |
|
860 |
bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); |
813 |
bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); |
861 |
} |
814 |
} |
862 |
|
|
|
863 |
static void |
864 |
dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) |
865 |
{ |
866 |
long double transfers_per_second; |
867 |
long double kb_per_transfer, mb_per_second; |
868 |
long double elapsed_time, device_busy; |
869 |
int di; |
870 |
|
871 |
di = dev_select[dn].position; |
872 |
|
873 |
if (then != NULL) { |
874 |
/* Calculate relative to previous sample */ |
875 |
elapsed_time = now->snap_time - then->snap_time; |
876 |
} else { |
877 |
/* Calculate relative to device creation */ |
878 |
elapsed_time = now->snap_time - devstat_compute_etime( |
879 |
&now->dinfo->devices[di].creation_time, NULL); |
880 |
} |
881 |
|
882 |
if (devstat_compute_statistics(&now->dinfo->devices[di], then ? |
883 |
&then->dinfo->devices[di] : NULL, elapsed_time, |
884 |
DSM_KB_PER_TRANSFER, &kb_per_transfer, |
885 |
DSM_TRANSFERS_PER_SECOND, &transfers_per_second, |
886 |
DSM_MB_PER_SECOND, &mb_per_second, |
887 |
DSM_BUSY_PCT, &device_busy, |
888 |
DSM_NONE) != 0) |
889 |
errx(1, "%s", devstat_errbuf); |
890 |
|
891 |
lc = DISKCOL + lc * 6; |
892 |
putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); |
893 |
putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); |
894 |
putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); |
895 |
putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); |
896 |
} |