diff options
author | Raghavendra Bhat <raghavendrabhat@gluster.com> | 2011-07-20 12:35:14 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-20 06:15:23 -0700 |
commit | c6053cac7794dfd9bf693e91cd76c2a45d7859eb (patch) | |
tree | 3d5a383221a908c5ce2db53caf0c05fdb6d2e1dc /xlators/debug | |
parent | a7e38564ec859afc15274a0d9a16d6e04ed3f6e2 (diff) |
debug/io-stats: print the time at which maximum fds were open in gluster top
Change-Id: I257bc29945d5acf8fb316f396fb011a2ab652d7a
BUG: 3076
Reviewed-on: http://review.gluster.com/54
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shishir Gowda <shishirng@gluster.com>
Diffstat (limited to 'xlators/debug')
-rw-r--r-- | xlators/debug/io-stats/src/io-stats.c | 37 |
1 files changed, 30 insertions, 7 deletions
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; |