summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c8
-rw-r--r--xlators/debug/io-stats/src/io-stats.c37
2 files changed, 37 insertions, 8 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 26e78dca1..50a2631a2 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -3298,6 +3298,7 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
long int time_usec = 0;
struct tm *tm = NULL;
char timestr[256] = {0, };
+ char *openfd_str = NULL;
if (-1 == req->rpc_status) {
goto out;
@@ -3372,8 +3373,13 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
ret = dict_get_uint64 (dict, key, &max_nr_open);
if (ret)
goto out;
+ snprintf (key, sizeof (key), "%d-max-openfd-time", i);
+ ret = dict_get_str (dict, key, &openfd_str);
+ if (ret)
+ goto out;
cli_out ("Current open fds: %"PRIu64", Max open"
- " fds: %"PRIu64, nr_open, max_nr_open);
+ " fds: %"PRIu64", Max openfd time: %s", nr_open,
+ max_nr_open, openfd_str);
case GF_CLI_TOP_READ:
case GF_CLI_TOP_WRITE:
case GF_CLI_TOP_OPENDIR:
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 7747e7fb2..3a2032444 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -110,6 +110,7 @@ struct ios_global_stats {
struct ios_lat latency[GF_FOP_MAXVALUE];
uint64_t nr_opens;
uint64_t max_nr_opens;
+ struct timeval max_openfd_time;
};
@@ -598,6 +599,8 @@ io_stats_dump_global_to_logfp (xlator_t *this, struct ios_global_stats *stats,
int i = 0;
struct ios_stat_head *list_head = NULL;
struct ios_conf *conf = NULL;
+ struct tm *tm = NULL;
+ char timestr[256] = {0, };
conf = this->private;
@@ -640,9 +643,15 @@ io_stats_dump_global_to_logfp (xlator_t *this, struct ios_global_stats *stats,
if (interval == -1) {
LOCK (&conf->lock);
{
- ios_log (this, logfp, "Current open fd's: %"PRId64
- " Max open fd's: %"PRId64,conf->cumulative.nr_opens,
- conf->cumulative.max_nr_opens);
+ tm = localtime (&conf->cumulative.max_openfd_time.tv_sec);
+ strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm);
+ snprintf (timestr + strlen (timestr), 256 - strlen (timestr),
+ ".%"GF_PRI_SUSECONDS,
+ conf->cumulative.max_openfd_time.tv_usec);
+ ios_log (this, logfp, "Current open fd's: %"PRId64
+ " Max open fd's: %"PRId64" time %s",
+ conf->cumulative.nr_opens,
+ conf->cumulative.max_nr_opens, timestr);
}
UNLOCK (&conf->lock);
ios_log (this, logfp, "==========Open file stats========");
@@ -1018,6 +1027,8 @@ io_stats_dump_stats_to_dict (xlator_t *this, dict_t *resp,
struct ios_stat_list *entry = NULL;
int ret = -1;
ios_stats_thru_t index = IOS_STATS_THRU_MAX;
+ struct tm *tm = NULL;
+ char timestr[256] = {0, };
conf = this->private;
@@ -1031,7 +1042,16 @@ io_stats_dump_stats_to_dict (xlator_t *this, dict_t *resp,
if (ret)
goto out;
ret = dict_set_uint64 (resp, "max-open",
- conf->cumulative.max_nr_opens);
+ conf->cumulative.max_nr_opens);
+
+ tm = localtime (&conf->cumulative.max_openfd_time.tv_sec);
+ strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm);
+ snprintf (timestr + strlen (timestr), 256 - strlen (timestr),
+ ".%"GF_PRI_SUSECONDS,
+ conf->cumulative.max_openfd_time.tv_usec);
+
+ ret = dict_set_str (resp, "max-openfd-time",
+ timestr);
if (ret)
goto out;
}
@@ -1138,8 +1158,10 @@ io_stats_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
LOCK (&conf->lock);
{
conf->cumulative.nr_opens++;
- if (conf->cumulative.nr_opens > conf->cumulative.max_nr_opens)
+ if (conf->cumulative.nr_opens > conf->cumulative.max_nr_opens) {
conf->cumulative.max_nr_opens = conf->cumulative.nr_opens;
+ conf->cumulative.max_openfd_time = iosfd->opened_at;
+ }
}
UNLOCK (&conf->lock);
@@ -1198,11 +1220,12 @@ io_stats_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
LOCK (&conf->lock);
{
conf->cumulative.nr_opens++;
- if (conf->cumulative.nr_opens > conf->cumulative.max_nr_opens)
+ if (conf->cumulative.nr_opens > conf->cumulative.max_nr_opens) {
conf->cumulative.max_nr_opens = conf->cumulative.nr_opens;
+ conf->cumulative.max_openfd_time = iosfd->opened_at;
+ }
}
UNLOCK (&conf->lock);
-
if (iosstat) {
BUMP_STATS (iosstat, IOS_STATS_TYPE_OPEN);
iosstat = NULL;