summaryrefslogtreecommitdiffstats
path: root/xlators/debug/io-stats
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/debug/io-stats')
-rw-r--r--xlators/debug/io-stats/src/io-stats.c50
1 files changed, 40 insertions, 10 deletions
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,