aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-09-28 16:30:54 -0700
committerBrian Behlendorf <[email protected]>2010-10-12 14:55:01 -0700
commitc5343ba71b9fea6e3636be25a16173092f2042ba (patch)
tree15d74a04d92e697719cd247f793b26ccbcac0415 /cmd
parent312c07edfdbdbabfab7f721797bba8eade5dcdeb (diff)
Fix 'zpool events' formatting for awk
To make the 'zpool events' output simple to parse with awk the extra newline after embedded nvlists has been dropped. This allows the entire event to be parsed as a single whitespace seperated record. The -H option has been added to operate in scripted mode. For the 'zpool events' command this means don't print the header. The usage of -H is consistent with scripted mode for other zpool commands.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zpool/zpool_main.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 3859bf737..1e9b3b69e 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -241,7 +241,7 @@ get_usage(zpool_help_t idx) {
"\tupgrade -v\n"
"\tupgrade [-V version] <-a | pool ...>\n"));
case HELP_EVENTS:
- return (gettext("\tevents [-vfc]\n"));
+ return (gettext("\tevents [-vHfc]\n"));
case HELP_GET:
return (gettext("\tget <\"all\" | property[,...]> "
"<pool> ...\n"));
@@ -4228,6 +4228,7 @@ zpool_do_history(int argc, char **argv)
typedef struct ev_opts {
int verbose;
+ int scripted;
int follow;
int clear;
} ev_opts_t;
@@ -4342,7 +4343,7 @@ zpool_do_events_nvprint(nvlist_t *nvl, int depth)
printf(gettext("(embedded nvlist)\n"));
(void) nvpair_value_nvlist(nvp, &cnv);
zpool_do_events_nvprint(cnv, depth + 8);
- printf(gettext("%*s(end %s)\n"), depth, "", name);
+ printf(gettext("%*s(end %s)"), depth, "", name);
break;
case DATA_TYPE_NVLIST_ARRAY: {
@@ -4472,7 +4473,8 @@ zpool_do_events_next(ev_opts_t *opts)
cleanup_fd = open(ZFS_DEV, O_RDWR);
VERIFY(cleanup_fd >= 0);
- (void) printf(gettext("%-30s %s\n"), "TIME", "CLASS");
+ if (!opts->scripted)
+ (void) printf(gettext("%-30s %s\n"), "TIME", "CLASS");
while (1) {
ret = zpool_events_next(g_zfs, &nvl, &dropped,
@@ -4523,11 +4525,14 @@ zpool_do_events(int argc, char **argv)
int c;
/* check options */
- while ((c = getopt(argc, argv, "vfc")) != -1) {
+ while ((c = getopt(argc, argv, "vHfc")) != -1) {
switch (c) {
case 'v':
opts.verbose = 1;
break;
+ case 'H':
+ opts.scripted = 1;
+ break;
case 'f':
opts.follow = 1;
break;