|
Lines 51-61
Link Here
|
| 51 |
#include <sysexits.h> |
51 |
#include <sysexits.h> |
| 52 |
#include <unistd.h> |
52 |
#include <unistd.h> |
| 53 |
|
53 |
|
| 54 |
static int flag_a, flag_b, flag_c, flag_d, flag_o, flag_p; |
54 |
static int flag_a, flag_b, flag_c, flag_d, flag_o, flag_p, flag_B; |
| 55 |
static int flag_I = 1000000; |
55 |
static int flag_I = 1000000; |
| 56 |
|
56 |
|
| 57 |
#define PRINTMSG(...) do { \ |
57 |
#define PRINTMSG(...) do { \ |
| 58 |
if (flag_b && !loop) \ |
58 |
if ((flag_b && !loop) || (flag_B)) \ |
| 59 |
printf(__VA_ARGS__); \ |
59 |
printf(__VA_ARGS__); \ |
| 60 |
else if (!flag_b) \ |
60 |
else if (!flag_b) \ |
| 61 |
printw(__VA_ARGS__); \ |
61 |
printw(__VA_ARGS__); \ |
|
Lines 99-110
Link Here
|
| 99 |
maxx = -1; |
99 |
maxx = -1; |
| 100 |
curx = -1; |
100 |
curx = -1; |
| 101 |
loop = 1; |
101 |
loop = 1; |
|
|
102 |
|
| 102 |
/* Turn on batch mode if output is not tty. */ |
103 |
/* Turn on batch mode if output is not tty. */ |
| 103 |
if (!isatty(fileno(stdout))) |
104 |
if (!isatty(fileno(stdout))) |
| 104 |
flag_b = 1; |
105 |
flag_b = 1; |
| 105 |
|
106 |
|
| 106 |
f_s[0] = '\0'; |
107 |
f_s[0] = '\0'; |
| 107 |
while ((i = getopt(argc, argv, "abdcf:I:op")) != -1) { |
108 |
while ((i = getopt(argc, argv, "abBdcf:I:op")) != -1) { |
| 108 |
switch (i) { |
109 |
switch (i) { |
| 109 |
case 'a': |
110 |
case 'a': |
| 110 |
flag_a = 1; |
111 |
flag_a = 1; |
|
Lines 112-117
Link Here
|
| 112 |
case 'b': |
113 |
case 'b': |
| 113 |
flag_b = 1; |
114 |
flag_b = 1; |
| 114 |
break; |
115 |
break; |
|
|
116 |
case 'B': |
| 117 |
flag_B = 1; |
| 118 |
flag_b = 1; |
| 119 |
break; |
| 115 |
case 'c': |
120 |
case 'c': |
| 116 |
flag_c = 1; |
121 |
flag_c = 1; |
| 117 |
break; |
122 |
break; |
|
Lines 208-243
Link Here
|
| 208 |
|
213 |
|
| 209 |
geom_stats_snapshot_reset(sp); |
214 |
geom_stats_snapshot_reset(sp); |
| 210 |
geom_stats_snapshot_reset(sq); |
215 |
geom_stats_snapshot_reset(sq); |
| 211 |
move(0,0); |
216 |
if (!flag_b) |
| 212 |
PRINTMSG("dT: %5.3fs w: %.3fs", dt, (float)flag_I / 1000000); |
217 |
move(0,0); |
| 213 |
if (f_s[0] != '\0') { |
218 |
|
| 214 |
PRINTMSG(" filter: "); |
219 |
if (!flag_B || (flag_B && loop)) { |
| 215 |
if (!flag_b) { |
220 |
PRINTMSG("dT: %5.3fs w: %.3fs", dt, (float)flag_I / 1000000); |
| 216 |
getyx(stdscr, cury, curx); |
221 |
if (f_s[0] != '\0') { |
| 217 |
getmaxyx(stdscr, maxy, maxx); |
222 |
PRINTMSG(" filter: "); |
|
|
223 |
if (!flag_b) { |
| 224 |
getyx(stdscr, cury, curx); |
| 225 |
getmaxyx(stdscr, maxy, maxx); |
| 226 |
} |
| 227 |
strncpy(pf_s, f_s, sizeof(pf_s)); |
| 228 |
max_flen = maxx - curx - 1; |
| 229 |
if ((int)strlen(f_s) > max_flen && max_flen >= 0) { |
| 230 |
if (max_flen > 3) |
| 231 |
pf_s[max_flen - 3] = '.'; |
| 232 |
if (max_flen > 2) |
| 233 |
pf_s[max_flen - 2] = '.'; |
| 234 |
if (max_flen > 1) |
| 235 |
pf_s[max_flen - 1] = '.'; |
| 236 |
pf_s[max_flen] = '\0'; |
| 237 |
} |
| 238 |
PRINTMSG("%s", pf_s); |
| 218 |
} |
239 |
} |
| 219 |
strncpy(pf_s, f_s, sizeof(pf_s)); |
240 |
PRINTMSG("\n"); |
| 220 |
max_flen = maxx - curx - 1; |
241 |
PRINTMSG(" L(q) ops/s "); |
| 221 |
if ((int)strlen(f_s) > max_flen && max_flen >= 0) { |
242 |
PRINTMSG(" r/s kBps ms/r "); |
| 222 |
if (max_flen > 3) |
243 |
PRINTMSG(" w/s kBps ms/w "); |
| 223 |
pf_s[max_flen - 3] = '.'; |
244 |
if (flag_d) |
| 224 |
if (max_flen > 2) |
245 |
PRINTMSG(" d/s kBps ms/d "); |
| 225 |
pf_s[max_flen - 2] = '.'; |
246 |
if (flag_o) |
| 226 |
if (max_flen > 1) |
247 |
PRINTMSG(" o/s ms/o "); |
| 227 |
pf_s[max_flen - 1] = '.'; |
248 |
PRINTMSG("%%busy Name\n"); |
| 228 |
pf_s[max_flen] = '\0'; |
|
|
| 229 |
} |
249 |
} |
| 230 |
PRINTMSG("%s", pf_s); |
250 |
|
| 231 |
} |
|
|
| 232 |
PRINTMSG("\n"); |
| 233 |
PRINTMSG(" L(q) ops/s "); |
| 234 |
PRINTMSG(" r/s kBps ms/r "); |
| 235 |
PRINTMSG(" w/s kBps ms/w "); |
| 236 |
if (flag_d) |
| 237 |
PRINTMSG(" d/s kBps ms/d "); |
| 238 |
if (flag_o) |
| 239 |
PRINTMSG(" o/s ms/o "); |
| 240 |
PRINTMSG("%%busy Name\n"); |
| 241 |
for (;;) { |
251 |
for (;;) { |
| 242 |
gsp = geom_stats_snapshot_next(sp); |
252 |
gsp = geom_stats_snapshot_next(sp); |
| 243 |
gsq = geom_stats_snapshot_next(sq); |
253 |
gsq = geom_stats_snapshot_next(sq); |
|
Lines 366-377
Link Here
|
| 366 |
if (!flag_b) |
376 |
if (!flag_b) |
| 367 |
clrtoeol(); |
377 |
clrtoeol(); |
| 368 |
PRINTMSG("\n"); |
378 |
PRINTMSG("\n"); |
|
|
379 |
if (flag_B) |
| 380 |
fflush(stdout); |
| 369 |
*gsq = *gsp; |
381 |
*gsq = *gsp; |
| 370 |
} |
382 |
} |
| 371 |
geom_stats_snapshot_free(sp); |
383 |
geom_stats_snapshot_free(sp); |
| 372 |
if (flag_b) { |
384 |
if (flag_b) { |
| 373 |
/* We loop extra to make sure we get the information. */ |
385 |
/* We loop extra to make sure we get the information. */ |
| 374 |
if (!loop) |
386 |
if (!loop && !flag_B) |
| 375 |
break; |
387 |
break; |
| 376 |
loop = 0; |
388 |
loop = 0; |
| 377 |
usleep(flag_I); |
389 |
usleep(flag_I); |