systat -zarc to display disk activities like -vm
PR: 213310 Submitted by: ota MFH: 4 weeks Differential Revision: https://reviews.freebsd.org/D18726
This commit is contained in:
+118
-8
@@ -2,6 +2,7 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998 Kenneth D. Merry.
|
* Copyright (c) 1998 Kenneth D. Merry.
|
||||||
|
* 2015 Yoshihiro Ota
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -69,7 +70,6 @@ static const char sccsid[] = "@(#)disks.c 8.1 (Berkeley) 6/6/93";
|
|||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <devstat.h>
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -84,6 +84,8 @@ typedef enum {
|
|||||||
DS_MATCHTYPE_PATTERN
|
DS_MATCHTYPE_PATTERN
|
||||||
} last_match_type;
|
} last_match_type;
|
||||||
|
|
||||||
|
struct statinfo cur_dev, last_dev, run_dev;
|
||||||
|
|
||||||
last_match_type last_type;
|
last_match_type last_type;
|
||||||
struct device_selection *dev_select;
|
struct device_selection *dev_select;
|
||||||
long generation;
|
long generation;
|
||||||
@@ -101,10 +103,8 @@ static int dsselect(const char *args, devstat_select_mode select_mode,
|
|||||||
int maxshowdevs, struct statinfo *s1);
|
int maxshowdevs, struct statinfo *s1);
|
||||||
|
|
||||||
int
|
int
|
||||||
dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
|
dsinit(int maxshowdevs)
|
||||||
struct statinfo *s3 __unused)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that the userland devstat version matches the kernel
|
* Make sure that the userland devstat version matches the kernel
|
||||||
* devstat version. If not, exit and print a message informing
|
* devstat version. If not, exit and print a message informing
|
||||||
@@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
|
|||||||
if (devstat_checkversion(NULL) < 0)
|
if (devstat_checkversion(NULL) < 0)
|
||||||
errx(1, "%s", devstat_errbuf);
|
errx(1, "%s", devstat_errbuf);
|
||||||
|
|
||||||
|
if( cur_dev.dinfo ) // init was alreay ran
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
if ((num_devices = devstat_getnumdevs(NULL)) < 0) {
|
||||||
|
warnx("%s", devstat_errbuf);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_dev.dinfo = calloc(1, sizeof(struct devinfo));
|
||||||
|
last_dev.dinfo = calloc(1, sizeof(struct devinfo));
|
||||||
|
run_dev.dinfo = calloc(1, sizeof(struct devinfo));
|
||||||
|
|
||||||
generation = 0;
|
generation = 0;
|
||||||
num_devices = 0;
|
num_devices = 0;
|
||||||
num_selected = 0;
|
num_selected = 0;
|
||||||
@@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
|
|||||||
select_generation = 0;
|
select_generation = 0;
|
||||||
last_type = DS_MATCHTYPE_NONE;
|
last_type = DS_MATCHTYPE_NONE;
|
||||||
|
|
||||||
if (devstat_getdevs(NULL, s1) == -1)
|
if (devstat_getdevs(NULL, &cur_dev) == -1)
|
||||||
errx(1, "%s", devstat_errbuf);
|
errx(1, "%s", devstat_errbuf);
|
||||||
|
|
||||||
num_devices = s1->dinfo->numdevs;
|
num_devices = cur_dev.dinfo->numdevs;
|
||||||
generation = s1->dinfo->generation;
|
generation = cur_dev.dinfo->generation;
|
||||||
|
|
||||||
dev_select = NULL;
|
dev_select = NULL;
|
||||||
|
|
||||||
@@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
|
|||||||
* or 1. If we get back -1, though, there is an error.
|
* or 1. If we get back -1, though, there is an error.
|
||||||
*/
|
*/
|
||||||
if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
|
if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
|
||||||
&select_generation, generation, s1->dinfo->devices, num_devices,
|
&select_generation, generation, cur_dev.dinfo->devices, num_devices,
|
||||||
NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1)
|
NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1)
|
||||||
errx(1, "%d %s", __LINE__, devstat_errbuf);
|
errx(1, "%d %s", __LINE__, devstat_errbuf);
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dsgetinfo(struct statinfo* dev)
|
||||||
|
{
|
||||||
|
switch (devstat_getdevs(NULL, dev)) {
|
||||||
|
case -1:
|
||||||
|
errx(1, "%s", devstat_errbuf);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
num_devices = dev->dinfo->numdevs;
|
||||||
|
generation = dev->dinfo->generation;
|
||||||
|
cmdkre("refresh", NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo *s1)
|
dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo *s1)
|
||||||
{
|
{
|
||||||
@@ -331,3 +361,83 @@ dsselect(const char *args, devstat_select_mode select_mode, int maxshowdevs,
|
|||||||
}
|
}
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dslabel(int maxdrives, int diskcol, int diskrow)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
mvprintw(diskrow, diskcol, "Disks");
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dsshow2(int diskcol, int diskrow, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then)
|
||||||
|
{
|
||||||
|
dsshow2(diskcol, diskrow, dn, lc, now, then);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct statinfo *then)
|
||||||
|
{
|
||||||
|
int i, lc;
|
||||||
|
|
||||||
|
for (i = 0, lc = 0; i < num_devices && lc < maxdrives; i++)
|
||||||
|
if (dev_select[i].selected)
|
||||||
|
dsshow3(diskcol, diskrow, i, ++lc, now, then);
|
||||||
|
}
|
||||||
|
|||||||
+15
-1
@@ -2,6 +2,7 @@
|
|||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998 David E. O'Brien
|
* Copyright (c) 1998 David E. O'Brien
|
||||||
|
* 2015 Yoshihiro Ota
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -28,5 +29,18 @@
|
|||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *);
|
#ifndef DEVS_H
|
||||||
|
#define DEVS_H
|
||||||
|
|
||||||
|
#include <devstat.h>
|
||||||
|
|
||||||
|
int dsinit(int);
|
||||||
|
void dsgetinfo(struct statinfo *);
|
||||||
int dscmd(const char *, const char *, int, struct statinfo *);
|
int dscmd(const char *, const char *, int, struct statinfo *);
|
||||||
|
|
||||||
|
void dslabel(int, int, int);
|
||||||
|
void dsshow(int, int, int, struct statinfo *, struct statinfo *);
|
||||||
|
|
||||||
|
extern struct statinfo cur_dev, last_dev, run_dev;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
+19
-27
@@ -79,8 +79,6 @@ static const char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
|
|||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
#include "devs.h"
|
#include "devs.h"
|
||||||
|
|
||||||
struct statinfo cur, last;
|
|
||||||
|
|
||||||
static int linesperregion;
|
static int linesperregion;
|
||||||
static double etime;
|
static double etime;
|
||||||
static int numbers = 0; /* default display bar graphs */
|
static int numbers = 0; /* default display bar graphs */
|
||||||
@@ -111,17 +109,11 @@ closeiostat(WINDOW *w)
|
|||||||
int
|
int
|
||||||
initiostat(void)
|
initiostat(void)
|
||||||
{
|
{
|
||||||
if ((num_devices = devstat_getnumdevs(NULL)) < 0)
|
|
||||||
return(0);
|
|
||||||
|
|
||||||
cur.dinfo = calloc(1, sizeof(struct devinfo));
|
|
||||||
last.dinfo = calloc(1, sizeof(struct devinfo));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This value for maxshowdevs (100) is bogus. I'm not sure exactly
|
* This value for maxshowdevs (100) is bogus. I'm not sure exactly
|
||||||
* how to calculate it, though.
|
* how to calculate it, though.
|
||||||
*/
|
*/
|
||||||
if (dsinit(100, &cur, &last, NULL) != 1)
|
if (dsinit(7) != 1)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
@@ -133,17 +125,17 @@ fetchiostat(void)
|
|||||||
struct devinfo *tmp_dinfo;
|
struct devinfo *tmp_dinfo;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(cur.cp_time);
|
len = sizeof(cur_dev.cp_time);
|
||||||
if (sysctlbyname("kern.cp_time", &cur.cp_time, &len, NULL, 0)
|
if (sysctlbyname("kern.cp_time", &cur_dev.cp_time, &len, NULL, 0)
|
||||||
|| len != sizeof(cur.cp_time)) {
|
|| len != sizeof(cur_dev.cp_time)) {
|
||||||
perror("kern.cp_time");
|
perror("kern.cp_time");
|
||||||
exit (1);
|
exit (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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here what we want to do is refresh our device stats.
|
* Here what we want to do is refresh our device stats.
|
||||||
@@ -152,7 +144,7 @@ fetchiostat(void)
|
|||||||
* the selection process again, in case a device that we
|
* the selection process again, in case a device that we
|
||||||
* were previously displaying has gone away.
|
* were previously displaying has gone away.
|
||||||
*/
|
*/
|
||||||
switch (devstat_getdevs(NULL, &cur)) {
|
switch (devstat_getdevs(NULL, &cur_dev)) {
|
||||||
case -1:
|
case -1:
|
||||||
errx(1, "%s", devstat_errbuf);
|
errx(1, "%s", devstat_errbuf);
|
||||||
break;
|
break;
|
||||||
@@ -162,8 +154,8 @@ fetchiostat(void)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
num_devices = cur.dinfo->numdevs;
|
num_devices = cur_dev.dinfo->numdevs;
|
||||||
generation = cur.dinfo->generation;
|
generation = cur_dev.dinfo->generation;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,11 +252,11 @@ showiostat(void)
|
|||||||
long t;
|
long t;
|
||||||
int i, row, _col;
|
int i, row, _col;
|
||||||
|
|
||||||
#define X(fld) t = cur.fld[i]; cur.fld[i] -= last.fld[i]; last.fld[i] = t
|
#define X(fld) t = cur_dev.fld[i]; cur_dev.fld[i] -= last_dev.fld[i]; last_dev.fld[i] = t
|
||||||
etime = 0;
|
etime = 0;
|
||||||
for(i = 0; i < CPUSTATES; i++) {
|
for(i = 0; i < CPUSTATES; i++) {
|
||||||
X(cp_time);
|
X(cp_time);
|
||||||
etime += cur.cp_time[i];
|
etime += cur_dev.cp_time[i];
|
||||||
}
|
}
|
||||||
if (etime == 0.0)
|
if (etime == 0.0)
|
||||||
etime = 1.0;
|
etime = 1.0;
|
||||||
@@ -313,10 +305,10 @@ devstats(int row, int _col, int dn)
|
|||||||
|
|
||||||
di = dev_select[dn].position;
|
di = dev_select[dn].position;
|
||||||
|
|
||||||
busy_seconds = cur.snap_time - last.snap_time;
|
busy_seconds = cur_dev.snap_time - last_dev.snap_time;
|
||||||
|
|
||||||
if (devstat_compute_statistics(&cur.dinfo->devices[di],
|
if (devstat_compute_statistics(&cur_dev.dinfo->devices[di],
|
||||||
&last.dinfo->devices[di], busy_seconds,
|
&last_dev.dinfo->devices[di], busy_seconds,
|
||||||
DSM_KB_PER_TRANSFER, &kb_per_transfer,
|
DSM_KB_PER_TRANSFER, &kb_per_transfer,
|
||||||
DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
|
DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
|
||||||
DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) != 0)
|
DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) != 0)
|
||||||
@@ -349,12 +341,12 @@ stat1(int row, int o)
|
|||||||
|
|
||||||
dtime = 0.0;
|
dtime = 0.0;
|
||||||
for (i = 0; i < CPUSTATES; i++)
|
for (i = 0; i < CPUSTATES; i++)
|
||||||
dtime += cur.cp_time[i];
|
dtime += cur_dev.cp_time[i];
|
||||||
if (dtime == 0.0)
|
if (dtime == 0.0)
|
||||||
dtime = 1.0;
|
dtime = 1.0;
|
||||||
wmove(wnd, row, INSET);
|
wmove(wnd, row, INSET);
|
||||||
#define CPUSCALE 0.5
|
#define CPUSCALE 0.5
|
||||||
histogram(100.0 * cur.cp_time[o] / dtime, 50, CPUSCALE);
|
histogram(100.0 * cur_dev.cp_time[o] / dtime, 50, CPUSCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -388,7 +380,7 @@ cmdiostat(const char *cmd, const char *args)
|
|||||||
numbers = 1;
|
numbers = 1;
|
||||||
else if (prefix(cmd, "bars"))
|
else if (prefix(cmd, "bars"))
|
||||||
numbers = 0;
|
numbers = 0;
|
||||||
else if (!dscmd(cmd, args, 100, &cur))
|
else if (!dscmd(cmd, args, 100, &cur_dev))
|
||||||
return (0);
|
return (0);
|
||||||
wclear(wnd);
|
wclear(wnd);
|
||||||
labeliostat();
|
labeliostat();
|
||||||
|
|||||||
+16
-1
@@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1980, 1992, 1993
|
* Copyright (c) 1980, 1992, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
* Copyright (c) 2017 Yoshihiro Ota
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -55,6 +56,7 @@ static const char sccsid[] = "@(#)swap.c 8.3 (Berkeley) 4/29/95";
|
|||||||
|
|
||||||
#include "systat.h"
|
#include "systat.h"
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
#include "devs.h"
|
||||||
|
|
||||||
kvm_t *kd;
|
kvm_t *kd;
|
||||||
|
|
||||||
@@ -137,13 +139,15 @@ initswap(void)
|
|||||||
oulen = ulen;
|
oulen = ulen;
|
||||||
|
|
||||||
once = 1;
|
once = 1;
|
||||||
|
|
||||||
|
dsinit(12);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fetchswap(void)
|
fetchswap(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
okvnsw = kvnsw;
|
okvnsw = kvnsw;
|
||||||
if ((kvnsw = kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) {
|
if ((kvnsw = kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) {
|
||||||
error("systat: kvm_getswapinfo failed");
|
error("systat: kvm_getswapinfo failed");
|
||||||
@@ -153,6 +157,15 @@ fetchswap(void)
|
|||||||
odlen = dlen;
|
odlen = dlen;
|
||||||
oulen = ulen;
|
oulen = ulen;
|
||||||
calclens();
|
calclens();
|
||||||
|
|
||||||
|
struct devinfo *tmp_dinfo;
|
||||||
|
|
||||||
|
tmp_dinfo = last_dev.dinfo;
|
||||||
|
last_dev.dinfo = cur_dev.dinfo;
|
||||||
|
cur_dev.dinfo = tmp_dinfo;
|
||||||
|
|
||||||
|
last_dev.snap_time = cur_dev.snap_time;
|
||||||
|
dsgetinfo( &cur_dev );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -178,6 +191,7 @@ labelswap(void)
|
|||||||
name = kvmsw[i].ksw_devname;
|
name = kvmsw[i].ksw_devname;
|
||||||
mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name);
|
mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name);
|
||||||
}
|
}
|
||||||
|
dslabel(12, 0, 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -217,4 +231,5 @@ showswap(void)
|
|||||||
waddch(wnd, 'X');
|
waddch(wnd, 'X');
|
||||||
wclrtoeol(wnd);
|
wclrtoeol(wnd);
|
||||||
}
|
}
|
||||||
|
dsshow(12, 0, 18, &cur_dev, &last_dev);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,3 +68,7 @@ extern int use_kvm;
|
|||||||
#define NVAL(indx) namelist[(indx)].n_value
|
#define NVAL(indx) namelist[(indx)].n_value
|
||||||
#define NPTR(indx) (void *)NVAL((indx))
|
#define NPTR(indx) (void *)NVAL((indx))
|
||||||
#define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len))
|
#define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len))
|
||||||
|
|
||||||
|
extern void putint(int, int, int, int);
|
||||||
|
extern void putfloat(double, int, int, int, int, int);
|
||||||
|
extern void putlongdouble(long double, int, int, int, int, int);
|
||||||
|
|||||||
+32
-116
@@ -66,7 +66,6 @@ static const char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
|
|||||||
#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"
|
||||||
@@ -125,7 +124,6 @@ static struct Info {
|
|||||||
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
|
||||||
@@ -137,13 +135,9 @@ 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;
|
||||||
@@ -209,16 +203,7 @@ initkre(void)
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
return(0);
|
||||||
|
|
||||||
if (nintr == 0) {
|
if (nintr == 0) {
|
||||||
@@ -371,27 +356,7 @@ labelkre(void)
|
|||||||
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)
|
||||||
@@ -401,7 +366,7 @@ labelkre(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#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;}
|
||||||
@@ -543,20 +508,17 @@ showkre(void)
|
|||||||
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++)
|
switch(state) {
|
||||||
if (dev_select[i].selected) {
|
case TIME:
|
||||||
switch(state) {
|
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev);
|
||||||
case TIME:
|
break;
|
||||||
dinfo(i, ++lc, &cur, &last);
|
case RUN:
|
||||||
break;
|
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev);
|
||||||
case RUN:
|
break;
|
||||||
dinfo(i, ++lc, &cur, &run);
|
case BOOT:
|
||||||
break;
|
dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL);
|
||||||
case BOOT:
|
break;
|
||||||
dinfo(i, ++lc, &cur, NULL);
|
}
|
||||||
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);
|
||||||
@@ -582,14 +544,14 @@ cmdkre(const char *cmd, const char *args)
|
|||||||
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;
|
||||||
@@ -612,14 +574,14 @@ cmdkre(const char *cmd, const char *args)
|
|||||||
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;
|
||||||
@@ -629,7 +591,7 @@ cmdkre(const char *cmd, const char *args)
|
|||||||
}
|
}
|
||||||
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();
|
||||||
@@ -667,7 +629,7 @@ cputime(int indx)
|
|||||||
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -713,7 +675,7 @@ do_putuint64(uint64_t n, int l, int lc, int w, int div)
|
|||||||
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;
|
||||||
@@ -745,7 +707,7 @@ putfloat(double f, int l, int lc, int w, int d, int nz)
|
|||||||
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;
|
||||||
@@ -785,7 +747,7 @@ getinfo(struct Info *ls)
|
|||||||
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);
|
||||||
@@ -838,23 +800,12 @@ getinfo(struct Info *ls)
|
|||||||
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
|
||||||
@@ -881,38 +832,3 @@ copyinfo(struct Info *from, struct Info *to)
|
|||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|||||||
+44
-27
@@ -1,6 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2014
|
* Copyright (c) 2014 - 2017 Yoshihiro Ota
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -33,11 +32,14 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
/* #include <stdlib.h> */
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
#include "systat.h"
|
#include "systat.h"
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
#include "devs.h"
|
||||||
|
|
||||||
struct zfield{
|
struct zfield{
|
||||||
uint64_t arcstats;
|
uint64_t arcstats;
|
||||||
@@ -77,21 +79,23 @@ closezarc(WINDOW *w)
|
|||||||
void
|
void
|
||||||
labelzarc(void)
|
labelzarc(void)
|
||||||
{
|
{
|
||||||
|
int row = 1;
|
||||||
wmove(wnd, 0, 0); wclrtoeol(wnd);
|
wmove(wnd, 0, 0); wclrtoeol(wnd);
|
||||||
mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s",
|
mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s",
|
||||||
"rate", "hits", "misses", "total hits", "total misses");
|
"rate", "hits", "misses", "total hits", "total misses");
|
||||||
#define L(row, str) mvwprintw(wnd, row, 5, str); \
|
#define L(str) mvwprintw(wnd, row, 5, #str); \
|
||||||
mvwprintw(wnd, row, 31, ":"); \
|
mvwprintw(wnd, row, 31, ":"); \
|
||||||
mvwprintw(wnd, row, 31+4, "%%")
|
mvwprintw(wnd, row, 31+4, "%%"); ++row
|
||||||
L(1, "arcstats");
|
L(arcstats);
|
||||||
L(2, "arcstats.demand_data");
|
L(arcstats.demand_data);
|
||||||
L(3, "arcstats.demand_metadata");
|
L(arcstats.demand_metadata);
|
||||||
L(4, "arcstats.prefetch_data");
|
L(arcstats.prefetch_data);
|
||||||
L(5, "arcstats.prefetch_metadata");
|
L(arcstats.prefetch_metadata);
|
||||||
L(6, "zfetchstats");
|
L(zfetchstats);
|
||||||
L(7, "arcstats.l2");
|
L(arcstats.l2);
|
||||||
L(8, "vdev_cache_stats");
|
L(vdev_cache_stats);
|
||||||
#undef L
|
#undef L
|
||||||
|
dslabel(12, 0, 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int calc(uint64_t hits, uint64_t misses)
|
static int calc(uint64_t hits, uint64_t misses)
|
||||||
@@ -131,6 +135,7 @@ domode(struct zarcstats *delta, struct zarcstats *rate)
|
|||||||
void
|
void
|
||||||
showzarc(void)
|
showzarc(void)
|
||||||
{
|
{
|
||||||
|
int row = 1;
|
||||||
struct zarcstats delta, rate;
|
struct zarcstats delta, rate;
|
||||||
|
|
||||||
memset(&delta, 0, sizeof delta);
|
memset(&delta, 0, sizeof delta);
|
||||||
@@ -138,34 +143,37 @@ showzarc(void)
|
|||||||
|
|
||||||
domode(&delta, &rate);
|
domode(&delta, &rate);
|
||||||
|
|
||||||
#define DO(stat, row, col, fmt) \
|
#define DO(stat, col, fmt) \
|
||||||
mvwprintw(wnd, row, col, fmt, stat)
|
mvwprintw(wnd, row, col, fmt, stat)
|
||||||
#define R(row, stat) DO(rate.hits.stat, row, 31+1, "%3"PRIu64)
|
#define R(stat) DO(rate.hits.stat, 31+1, "%3"PRIu64)
|
||||||
#define H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7"PRIu64); \
|
#define H(stat) DO(delta.hits.stat, 31+1+5, "%7"PRIu64); \
|
||||||
DO(curstat.hits.stat, row, 31+1+5+8+8, "%12"PRIu64)
|
DO(curstat.hits.stat, 31+1+5+8+8, "%12"PRIu64)
|
||||||
#define M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7"PRIu64); \
|
#define M(stat) DO(delta.misses.stat, 31+1+5+8, "%7"PRIu64); \
|
||||||
DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12"PRIu64)
|
DO(curstat.misses.stat, 31+1+5+8+8+13, "%12"PRIu64)
|
||||||
#define E(row, stat) R(row, stat); H(row, stat); M(row, stat);
|
#define E(stat) R(stat); H(stat); M(stat); ++row
|
||||||
E(1, arcstats);
|
E(arcstats);
|
||||||
E(2, arcstats_demand_data);
|
E(arcstats_demand_data);
|
||||||
E(3, arcstats_demand_metadata);
|
E(arcstats_demand_metadata);
|
||||||
E(4, arcstats_prefetch_data);
|
E(arcstats_prefetch_data);
|
||||||
E(5, arcstats_prefetch_metadata);
|
E(arcstats_prefetch_metadata);
|
||||||
E(6, zfetchstats);
|
E(zfetchstats);
|
||||||
E(7, arcstats_l2);
|
E(arcstats_l2);
|
||||||
E(8, vdev_cache_stats);
|
E(vdev_cache_stats);
|
||||||
#undef DO
|
#undef DO
|
||||||
#undef E
|
#undef E
|
||||||
#undef M
|
#undef M
|
||||||
#undef H
|
#undef H
|
||||||
#undef R
|
#undef R
|
||||||
|
dsshow(12, 0, 18, &cur_dev, &last_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
initzarc(void)
|
initzarc(void)
|
||||||
{
|
{
|
||||||
|
dsinit(12);
|
||||||
getinfo(&initstat);
|
getinfo(&initstat);
|
||||||
curstat = oldstat = initstat;
|
curstat = oldstat = initstat;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +186,15 @@ resetzarc(void)
|
|||||||
static void
|
static void
|
||||||
getinfo(struct zarcstats *ls)
|
getinfo(struct zarcstats *ls)
|
||||||
{
|
{
|
||||||
|
struct devinfo *tmp_dinfo;
|
||||||
|
|
||||||
|
tmp_dinfo = last_dev.dinfo;
|
||||||
|
last_dev.dinfo = cur_dev.dinfo;
|
||||||
|
cur_dev.dinfo = tmp_dinfo;
|
||||||
|
|
||||||
|
last_dev.snap_time = cur_dev.snap_time;
|
||||||
|
dsgetinfo( &cur_dev );
|
||||||
|
|
||||||
size_t size = sizeof( ls->hits.arcstats );
|
size_t size = sizeof( ls->hits.arcstats );
|
||||||
if ( sysctlbyname("kstat.zfs.misc.arcstats.hits",
|
if ( sysctlbyname("kstat.zfs.misc.arcstats.hits",
|
||||||
&ls->hits.arcstats, &size, NULL, 0 ) != 0 )
|
&ls->hits.arcstats, &size, NULL, 0 ) != 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user