summaryrefslogtreecommitdiffstats
path: root/xlators/debug
diff options
context:
space:
mode:
authorDawit Alemu <dalemu@redhat.com>2013-11-14 12:52:14 -0500
committerAnand Avati <avati@redhat.com>2013-12-03 18:09:29 -0800
commit133c370ec5e2688b6734acb087fe3769cb900a74 (patch)
tree14e72f63bcfc8612c3f07166465e95614457b6db /xlators/debug
parente4b9a74f46bca3894d686ce87042168c4304f07b (diff)
cli: Add an option to fetch just incremental or cumulative I/0
information 'volume profile info' fetches both cumulative and incremental I/O statistics. There isn't a way to fetch just cumulative or incremental statistics. This change introduces two optional arguments, namely "incremental" and "cumulative", that can be tacked on to 'volume profile info'. In other words, the new command format is volume profile <VOLNAME> {start | info [incremental | cumulative] | stop} [nfs] 'volume profile info incremental' - fetches incremental stats 'volume profile info cumulative' - fetches cumulative stats 'volume profile info' - fetches incremental and cumulative stats Change-Id: I5ddb45d990542ea611d23d251efebfec46f472d0 BUG: 1030580 Signed-off-by: Dawit Alemu <dalemu@redhat.com> Reviewed-on: http://review.gluster.org/6264 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/debug')
-rw-r--r--xlators/debug/io-stats/src/Makefile.am4
-rw-r--r--xlators/debug/io-stats/src/io-stats.c55
2 files changed, 40 insertions, 19 deletions
diff --git a/xlators/debug/io-stats/src/Makefile.am b/xlators/debug/io-stats/src/Makefile.am
index 332d790..dff294c 100644
--- a/xlators/debug/io-stats/src/Makefile.am
+++ b/xlators/debug/io-stats/src/Makefile.am
@@ -9,7 +9,9 @@ io_stats_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS = io-stats-mem-types.h
-AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src
+AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
+ -I$(top_srcdir)/rpc/xdr/src \
+ -I$(top_srcdir)/rpc/rpc-lib/src
AM_CFLAGS = -Wall $(GF_CFLAGS)
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 3ca5775..65aeee5 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include "defaults.h"
#include "logging.h"
+#include "cli1-xdr.h"
#define MAX_LIST_MEMBERS 100
@@ -917,7 +918,8 @@ ios_dump_args_init (struct ios_dump_args *args, ios_dump_type_t type,
}
int
-io_stats_dump (xlator_t *this, struct ios_dump_args *args)
+io_stats_dump (xlator_t *this, struct ios_dump_args *args,
+ gf1_cli_stats_op op)
{
struct ios_conf *conf = NULL;
struct ios_global_stats cumulative = {0, };
@@ -935,18 +937,30 @@ io_stats_dump (xlator_t *this, struct ios_dump_args *args)
gettimeofday (&now, NULL);
LOCK (&conf->lock);
{
- cumulative = conf->cumulative;
- incremental = conf->incremental;
+ if (op == GF_CLI_STATS_INFO ||
+ op == GF_CLI_STATS_INFO_CUMULATIVE)
+ cumulative = conf->cumulative;
- increment = conf->increment++;
+ if (op == GF_CLI_STATS_INFO ||
+ op == GF_CLI_STATS_INFO_INCREMENTAL) {
+ incremental = conf->incremental;
- memset (&conf->incremental, 0, sizeof (conf->incremental));
- conf->incremental.started_at = now;
+ increment = conf->increment++;
+
+ memset (&conf->incremental, 0,
+ sizeof (conf->incremental));
+ conf->incremental.started_at = now;
+ }
}
UNLOCK (&conf->lock);
- io_stats_dump_global (this, &cumulative, &now, -1, args);
- io_stats_dump_global (this, &incremental, &now, increment, args);
+ if (op == GF_CLI_STATS_INFO ||
+ op == GF_CLI_STATS_INFO_CUMULATIVE)
+ io_stats_dump_global (this, &cumulative, &now, -1, args);
+
+ if (op == GF_CLI_STATS_INFO ||
+ op == GF_CLI_STATS_INFO_INCREMENTAL)
+ io_stats_dump_global (this, &incremental, &now, increment, args);
return 0;
}
@@ -2207,7 +2221,7 @@ conditional_dump (dict_t *dict, char *key, data_t *value, void *data)
}
(void) ios_dump_args_init (&args, IOS_DUMP_TYPE_FILE,
logfp);
- io_stats_dump (this, &args);
+ io_stats_dump (this, &args, GF_CLI_STATS_INFO);
fclose (logfp);
}
return 0;
@@ -2773,7 +2787,7 @@ notify (xlator_t *this, int32_t event, void *data, ...)
struct ios_dump_args args = {0};
dict_t *output = NULL;
dict_t *dict = NULL;
- int32_t top_op = 0;
+ int32_t op = 0;
int32_t list_cnt = 0;
double throughput = 0;
double time = 0;
@@ -2787,7 +2801,7 @@ notify (xlator_t *this, int32_t event, void *data, ...)
case GF_EVENT_TRANSLATOR_INFO:
ret = dict_get_str_boolean (dict, "clear-stats", _gf_false);
if (ret) {
- ret = dict_set_int32 (output, "top-op", top_op);
+ ret = dict_set_int32 (output, "top-op", op);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Failed to set top-op in dict");
@@ -2807,15 +2821,15 @@ notify (xlator_t *this, int32_t event, void *data, ...)
goto out;
}
- ret = dict_get_int32 (dict, "top-op", &top_op);
+ ret = dict_get_int32 (dict, "top-op", &op);
if (!ret) {
ret = dict_get_int32 (dict, "list-cnt", &list_cnt);
- if (top_op > IOS_STATS_TYPE_NONE &&
- top_op < IOS_STATS_TYPE_MAX)
+ if (op > IOS_STATS_TYPE_NONE &&
+ op < IOS_STATS_TYPE_MAX)
ret = io_stats_dump_stats_to_dict (this, output,
- top_op, list_cnt);
- if (top_op == IOS_STATS_TYPE_READ_THROUGHPUT ||
- top_op == IOS_STATS_TYPE_WRITE_THROUGHPUT) {
+ op, list_cnt);
+ if (op == IOS_STATS_TYPE_READ_THROUGHPUT ||
+ op == IOS_STATS_TYPE_WRITE_THROUGHPUT) {
ret = dict_get_double (dict, "throughput",
&throughput);
if (!ret) {
@@ -2836,9 +2850,14 @@ notify (xlator_t *this, int32_t event, void *data, ...)
}
} else {
+ ret = dict_get_int32 (dict, "info-op", &op);
+ if (ret || op < GF_CLI_STATS_INFO ||
+ GF_CLI_STATS_INFO_CUMULATIVE < op)
+ op = GF_CLI_STATS_INFO;
+
(void) ios_dump_args_init (&args, IOS_DUMP_TYPE_DICT,
output);
- ret = io_stats_dump (this, &args);
+ ret = io_stats_dump (this, &args, op);
}
break;
default: