FreeBSD Bugzilla – Attachment 154239 Details for
Bug 198347
[patch] continuous batch mode for gstat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
print headers only once
gstat-B-2.patch (text/plain), 3.83 KB, created by
Robert Schulze
on 2015-03-12 09:59:25 UTC
(
hide
)
Description:
print headers only once
Filename:
MIME Type:
Creator:
Robert Schulze
Created:
2015-03-12 09:59:25 UTC
Size:
3.83 KB
patch
obsolete
>diff -Naur gstat.orig/gstat.8 gstat/gstat.8 >--- gstat.orig/gstat.8 2015-03-06 09:39:41.000000000 +0000 >+++ gstat/gstat.8 2015-03-06 10:05:51.000000000 +0000 >@@ -32,7 +32,7 @@ > .Nd print statistics about GEOM disks > .Sh SYNOPSIS > .Nm >-.Op Fl abcdop >+.Op Fl abBcdop > .Op Fl f Ar filter > .Op Fl I Ar interval > .Sh DESCRIPTION >@@ -50,6 +50,10 @@ > 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 dont exit after collecting >+the first set of data. > .It Fl c > Enable display of > .Xr geom 4 >diff -Naur gstat.orig/gstat.c gstat/gstat.c >--- gstat.orig/gstat.c 2015-03-06 09:39:41.000000000 +0000 >+++ gstat/gstat.c 2015-03-12 09:53:10.000000000 +0000 >@@ -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_c, flag_d, flag_o, flag_p, flag_B; > 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__); \ >@@ -99,12 +99,13 @@ > maxx = -1; > curx = -1; > loop = 1; >+ > /* Turn on batch mode if output is not tty. */ > if (!isatty(fileno(stdout))) > flag_b = 1; > > f_s[0] = '\0'; >- while ((i = getopt(argc, argv, "abdcf:I:op")) != -1) { >+ while ((i = getopt(argc, argv, "abBdcf:I:op")) != -1) { > switch (i) { > case 'a': > flag_a = 1; >@@ -112,6 +113,10 @@ > case 'b': > flag_b = 1; > break; >+ case 'B': >+ flag_B = 1; >+ flag_b = 1; >+ break; > case 'c': > flag_c = 1; > break; >@@ -208,36 +213,41 @@ > > geom_stats_snapshot_reset(sp); > geom_stats_snapshot_reset(sq); >- move(0,0); >- PRINTMSG("dT: %5.3fs w: %.3fs", dt, (float)flag_I / 1000000); >- if (f_s[0] != '\0') { >- PRINTMSG(" filter: "); >- if (!flag_b) { >- getyx(stdscr, cury, curx); >- getmaxyx(stdscr, maxy, maxx); >+ if (!flag_b) >+ move(0,0); >+ >+ if (!flag_B || (flag_B && loop)) { >+ PRINTMSG("dT: %5.3fs w: %.3fs", dt, (float)flag_I / 1000000); >+ if (f_s[0] != '\0') { >+ PRINTMSG(" filter: "); >+ if (!flag_b) { >+ getyx(stdscr, cury, curx); >+ getmaxyx(stdscr, maxy, maxx); >+ } >+ strncpy(pf_s, f_s, sizeof(pf_s)); >+ max_flen = maxx - curx - 1; >+ if ((int)strlen(f_s) > max_flen && max_flen >= 0) { >+ if (max_flen > 3) >+ pf_s[max_flen - 3] = '.'; >+ if (max_flen > 2) >+ pf_s[max_flen - 2] = '.'; >+ if (max_flen > 1) >+ pf_s[max_flen - 1] = '.'; >+ pf_s[max_flen] = '\0'; >+ } >+ PRINTMSG("%s", pf_s); > } >- strncpy(pf_s, f_s, sizeof(pf_s)); >- max_flen = maxx - curx - 1; >- if ((int)strlen(f_s) > max_flen && max_flen >= 0) { >- if (max_flen > 3) >- pf_s[max_flen - 3] = '.'; >- if (max_flen > 2) >- pf_s[max_flen - 2] = '.'; >- if (max_flen > 1) >- pf_s[max_flen - 1] = '.'; >- pf_s[max_flen] = '\0'; >+ 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_o) >+ PRINTMSG(" o/s ms/o "); >+ PRINTMSG("%%busy Name\n"); > } >- PRINTMSG("%s", pf_s); >- } >- 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_o) >- PRINTMSG(" o/s ms/o "); >- PRINTMSG("%%busy Name\n"); >+ > for (;;) { > gsp = geom_stats_snapshot_next(sp); > gsq = geom_stats_snapshot_next(sq); >@@ -366,12 +376,14 @@ > if (!flag_b) > clrtoeol(); > PRINTMSG("\n"); >+ if (flag_B) >+ fflush(stdout); > *gsq = *gsp; > } > geom_stats_snapshot_free(sp); > if (flag_b) { > /* We loop extra to make sure we get the information. */ >- if (!loop) >+ if (!loop && !flag_B) > break; > loop = 0; > usleep(flag_I);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 198347
:
153890
| 154239