diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2017-05-26 15:56:59 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-06-15 19:18:05 +0000 |
commit | b9fb7ea63d6120faaeb75ffa0cafbc0ab0e4a619 (patch) | |
tree | 26b9da71e28d2db549b709fda71860e431924464 | |
parent | 79efd0081fc5e24f6878d87a6dd8eb5253693d8f (diff) |
debug/io-stats: Provide option to select stats output format
... as opposed to hardcoding it to "json" always.
Change-Id: I5e79473a514373145ad764f24bb6219a6983a4c6
BUG: 1458197
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: https://review.gluster.org/17451
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-rw-r--r-- | libglusterfs/src/globals.h | 2 | ||||
-rw-r--r-- | xlators/debug/io-stats/src/io-stats.c | 50 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 |
3 files changed, 47 insertions, 10 deletions
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index a23c45e4a62..9bbd104b618 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -86,6 +86,8 @@ #define GD_OP_VERSION_3_11_1 31101 /* Op-version for GlusterFS 3.11.1 */ +#define GD_OP_VERSION_3_12_0 31200 /* Op-version for GlusterFS 3.12.0 */ + #define GD_OP_VERSION_4_0_0 40000 /* Op-version for GlusterFS 4.0.0 */ #define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index d9d1e1dff10..881cf632bbb 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -130,6 +130,15 @@ struct ios_global_stats { struct timeval max_openfd_time; }; +typedef enum { + IOS_DUMP_TYPE_NONE = 0, + IOS_DUMP_TYPE_FILE = 1, + IOS_DUMP_TYPE_DICT = 2, + IOS_DUMP_TYPE_JSON_FILE = 3, + IOS_DUMP_TYPE_SAMPLES = 4, + IOS_DUMP_TYPE_MAX = 5 +} ios_dump_type_t; + struct ios_conf { gf_lock_t lock; struct ios_global_stats cumulative; @@ -161,6 +170,8 @@ struct ios_conf { * all of the cases where "xlator_name" is used as a *variable* name. */ char *unique_id; + ios_dump_type_t dump_format; + char *dump_format_str; }; @@ -173,15 +184,6 @@ struct ios_fd { struct timeval opened_at; }; -typedef enum { - IOS_DUMP_TYPE_NONE = 0, - IOS_DUMP_TYPE_FILE = 1, - IOS_DUMP_TYPE_DICT = 2, - IOS_DUMP_TYPE_JSON_FILE = 3, - IOS_DUMP_TYPE_SAMPLES = 4, - IOS_DUMP_TYPE_MAX = 5 -} ios_dump_type_t; - struct ios_dump_args { ios_dump_type_t type; union { @@ -3161,7 +3163,7 @@ _ios_dump_thread (xlator_t *this) { stats_logfp = fopen (stats_filename, "w+"); if (stats_logfp) { (void) ios_dump_args_init (&args, - IOS_DUMP_TYPE_JSON_FILE, + conf->dump_format, stats_logfp); io_stats_dump (this, &args, GF_CLI_INFO_ALL, _gf_false); fclose (stats_logfp); @@ -3773,6 +3775,19 @@ io_priv (xlator_t *this) return 0; } +static void +ios_set_log_format_code (struct ios_conf *conf) +{ + if (strcmp (conf->dump_format_str, "json") == 0) + conf->dump_format = IOS_DUMP_TYPE_JSON_FILE; + else if (strcmp (conf->dump_format_str, "text") == 0) + conf->dump_format = IOS_DUMP_TYPE_FILE; + else if (strcmp (conf->dump_format_str, "dict") == 0) + conf->dump_format = IOS_DUMP_TYPE_DICT; + else if (strcmp (conf->dump_format_str, "samples") == 0) + conf->dump_format = IOS_DUMP_TYPE_SAMPLES; +} + int reconfigure (xlator_t *this, dict_t *options) { @@ -3814,6 +3829,9 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("ios-sample-interval", conf->ios_sample_interval, options, int32, out); + GF_OPTION_RECONF ("ios-dump-format", conf->dump_format_str, options, + str, out); + ios_set_log_format_code (conf); GF_OPTION_RECONF ("ios-sample-buf-size", conf->ios_sample_buf_size, options, int32, out); GF_OPTION_RECONF ("sys-log-level", sys_log_str, options, str, out); @@ -3980,6 +3998,9 @@ init (xlator_t *this) GF_OPTION_INIT ("ios-sample-interval", conf->ios_sample_interval, int32, out); + GF_OPTION_INIT ("ios-dump-format", conf->dump_format_str, str, out); + ios_set_log_format_code (conf); + GF_OPTION_INIT ("ios-sample-buf-size", conf->ios_sample_buf_size, int32, out); @@ -4290,6 +4311,15 @@ struct volume_options options[] = { .description = "Interval in which we want to collect FOP latency " "samples. 2 means collect a sample every 2nd FOP." }, + { .key = {"ios-dump-format"}, + .type = GF_OPTION_TYPE_STR, + .default_value = "json", + .description = " The dump-format option specifies the format in which" + " to dump the statistics. Select between \"text\", " + "\"json\", \"dict\" and \"samples\". Default is " + "\"json\".", + .value = { "text", "json", "dict", "samples"} + }, { .key = { "ios-sample-buf-size" }, .type = GF_OPTION_TYPE_INT, .min = 1024, diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 496b8db69f6..8d315d606ba 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -1573,6 +1573,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { .option = "ios-sample-interval", .op_version = 1 }, + { .key = "diagnostics.stats-dump-format", + .voltype = "debug/io-stats", + .option = "ios-dump-format", + .op_version = GD_OP_VERSION_3_12_0, + }, { .key = "diagnostics.fop-sample-buf-size", .voltype = "debug/io-stats", .option = "ios-sample-buf-size", |