summaryrefslogtreecommitdiffstats
path: root/usr.sbin/gstat
diff options
context:
space:
mode:
authoraraujo <araujo@FreeBSD.org>2016-11-25 05:54:17 +0000
committeraraujo <araujo@FreeBSD.org>2016-11-25 05:54:17 +0000
commit7e1d7cd06cc4c2bc9179a377342f9c90f0f3f6e0 (patch)
treeb92fdc778a22f497f3d098439c7eedf3ee780b0d /usr.sbin/gstat
parentda711180e126400521ec0737a553061f9230d0bd (diff)
downloadFreeBSD-src-7e1d7cd06cc4c2bc9179a377342f9c90f0f3f6e0.zip
FreeBSD-src-7e1d7cd06cc4c2bc9179a377342f9c90f0f3f6e0.tar.gz
MFC r308443, r308459, r308462, r308478, r308786
r308443: Add -d flag that prints domain only. PR: 212875 Submitted by: Ben RUBSON <ben.rubson@gmail.com> Reviewed by: pi r308459: Fix missing '-' for the flags -s and -d on both manpage and usage. Reported by: garga, bde r308462: Add flag -B which does the same like batch mode but without exiting after print. Also add a new flag -s that add blocks size to statistics. PR: 198347, 212726 Submitted by: Ben RUBSON <ben.rubson@gmail.com> Tested by: pi MFC After: 2 weeks. r308478: We can't use protect(1) inside a jail(8)! To avoid have warning for services that are using oomprotect, oomprotect will only be applied on services that won't run inside jails. Reported by: allanjude MFC after: 2 weeks. r308786: rc.subr: Swap checks so we only fork sysctl if *_oomprotect is set.
Diffstat (limited to 'usr.sbin/gstat')
-rw-r--r--usr.sbin/gstat/gstat.810
-rw-r--r--usr.sbin/gstat/gstat.c53
2 files changed, 50 insertions, 13 deletions
diff --git a/usr.sbin/gstat/gstat.8 b/usr.sbin/gstat/gstat.8
index 6c0430e..0c8ce3f 100644
--- a/usr.sbin/gstat/gstat.8
+++ b/usr.sbin/gstat/gstat.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 3, 2014
+.Dd November 10, 2016
.Dt GSTAT 8
.Os
.Sh NAME
@@ -32,7 +32,7 @@
.Nd print statistics about GEOM disks
.Sh SYNOPSIS
.Nm
-.Op Fl abcdop
+.Op Fl abBcdops
.Op Fl f Ar filter
.Op Fl I Ar interval
.Sh DESCRIPTION
@@ -50,6 +50,10 @@ Only display providers that are at least 0.1% busy.
Batch mode.
Collect numbers, print and exit.
Default if stdout is not a tty.
+.It Fl B
+Endless batch mode.
+Same as batch mode, but does not exit after collecting
+the first set of data.
.It Fl c
Enable display of
.Xr geom 4
@@ -72,6 +76,8 @@ The format of the regular expression is described in
.It Fl o
Enable display of statistics for other operations
.Pq Dv BIO_FLUSH .
+.It Fl s
+Enable blocks' size statistics.
.It Fl I Ar interval
Refresh the
.Nm
diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c
index a360f8f..480cf3c 100644
--- a/usr.sbin/gstat/gstat.c
+++ b/usr.sbin/gstat/gstat.c
@@ -51,11 +51,11 @@
#include <sysexits.h>
#include <unistd.h>
-static int flag_a, flag_b, flag_c, flag_d, flag_o, flag_p;
+static int flag_a, flag_b, flag_B, flag_c, flag_d, flag_o, flag_p, flag_s;
static int flag_I = 1000000;
#define PRINTMSG(...) do { \
- if (flag_b && !loop) \
+ if ((flag_b && !loop) || (flag_B)) \
printf(__VA_ARGS__); \
else if (!flag_b) \
printw(__VA_ARGS__); \
@@ -88,7 +88,7 @@ main(int argc, char **argv)
char *p;
char f_s[100], pf_s[100], tmp_f_s[100];
const char *line;
- long double ld[13];
+ long double ld[16];
uint64_t u64;
EditLine *el;
History *hist;
@@ -104,7 +104,7 @@ main(int argc, char **argv)
flag_b = 1;
f_s[0] = '\0';
- while ((i = getopt(argc, argv, "abdcf:I:op")) != -1) {
+ while ((i = getopt(argc, argv, "abBdcf:I:ops")) != -1) {
switch (i) {
case 'a':
flag_a = 1;
@@ -112,6 +112,10 @@ main(int argc, char **argv)
case 'b':
flag_b = 1;
break;
+ case 'B':
+ flag_B = 1;
+ flag_b = 1;
+ break;
case 'c':
flag_c = 1;
break;
@@ -146,6 +150,9 @@ main(int argc, char **argv)
case 'p':
flag_p = 1;
break;
+ case 's':
+ flag_s = 1;
+ break;
case '?':
default:
usage();
@@ -208,7 +215,8 @@ main(int argc, char **argv)
geom_stats_snapshot_reset(sp);
geom_stats_snapshot_reset(sq);
- move(0,0);
+ if (!flag_b)
+ move(0,0);
PRINTMSG("dT: %5.3fs w: %.3fs", dt, (float)flag_I / 1000000);
if (f_s[0] != '\0') {
PRINTMSG(" filter: ");
@@ -231,10 +239,20 @@ main(int argc, char **argv)
}
PRINTMSG("\n");
PRINTMSG(" L(q) ops/s ");
- PRINTMSG(" r/s kBps ms/r ");
- PRINTMSG(" w/s kBps ms/w ");
- if (flag_d)
- PRINTMSG(" d/s kBps ms/d ");
+ if (flag_s) {
+ PRINTMSG(" r/s kB kBps ms/r ");
+ PRINTMSG(" w/s kB kBps ms/w ");
+ }
+ else {
+ PRINTMSG(" r/s kBps ms/r ");
+ PRINTMSG(" w/s kBps ms/w ");
+ }
+ if (flag_d) {
+ if (flag_s)
+ PRINTMSG(" d/s kB kBps ms/d ");
+ else
+ PRINTMSG(" d/s kBps ms/d ");
+ }
if (flag_o)
PRINTMSG(" o/s ms/o ");
PRINTMSG("%%busy Name\n");
@@ -298,6 +316,10 @@ main(int argc, char **argv)
DSM_TRANSFERS_PER_SECOND_OTHER, &ld[11],
DSM_MS_PER_TRANSACTION_OTHER, &ld[12],
+ DSM_KB_PER_TRANSFER_READ, &ld[13],
+ DSM_KB_PER_TRANSFER_WRITE, &ld[14],
+ DSM_KB_PER_TRANSFER_FREE, &ld[15],
+
DSM_NONE);
if (flag_a && ld[7] < 0.1) {
@@ -308,12 +330,16 @@ main(int argc, char **argv)
PRINTMSG(" %4ju", (uintmax_t)u64);
PRINTMSG(" %6.0f", (double)ld[0]);
PRINTMSG(" %6.0f", (double)ld[1]);
+ if (flag_s)
+ PRINTMSG(" %6.0f", (double)ld[13]);
PRINTMSG(" %6.0f", (double)ld[2] * 1024);
if (ld[3] > 1e3)
PRINTMSG(" %6.0f", (double)ld[3]);
else
PRINTMSG(" %6.1f", (double)ld[3]);
PRINTMSG(" %6.0f", (double)ld[4]);
+ if (flag_s)
+ PRINTMSG(" %6.0f", (double)ld[14]);
PRINTMSG(" %6.0f", (double)ld[5] * 1024);
if (ld[6] > 1e3)
PRINTMSG(" %6.0f", (double)ld[6]);
@@ -322,6 +348,8 @@ main(int argc, char **argv)
if (flag_d) {
PRINTMSG(" %6.0f", (double)ld[8]);
+ if (flag_s)
+ PRINTMSG(" %6.0f", (double)ld[15]);
PRINTMSG(" %6.0f", (double)ld[9] * 1024);
if (ld[10] > 1e3)
PRINTMSG(" %6.0f", (double)ld[10]);
@@ -373,7 +401,10 @@ main(int argc, char **argv)
/* We loop extra to make sure we get the information. */
if (!loop)
break;
- loop = 0;
+ if (!flag_B)
+ loop = 0;
+ else
+ fflush(stdout);
usleep(flag_I);
continue;
}
@@ -452,7 +483,7 @@ main(int argc, char **argv)
static void
usage(void)
{
- fprintf(stderr, "usage: gstat [-abcdp] [-f filter] [-I interval]\n");
+ fprintf(stderr, "usage: gstat [-abBcdps] [-f filter] [-I interval]\n");
exit(EX_USAGE);
/* NOTREACHED */
}
OpenPOWER on IntegriCloud