* [PATCH] mountstats: Sort RPC statistics by operation count
@ 2014-11-04 22:14 Chuck Lever
2014-12-06 22:24 ` Steve Dickson
0 siblings, 1 reply; 2+ messages in thread
From: Chuck Lever @ 2014-11-04 22:14 UTC (permalink / raw)
To: linux-nfs
Sort the RPC statistics in descending order by operation count, so
that the most frequently executed operation appears at the top of
the listing (a la `top`).
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
Hey folks-
Any opinions about this? I considered adding a "--sort" command line
option to enable sorting, but instead made it always-on.
Could also use --sort to specify which individual statistic is used
for sorting (op count, RTT, retransmit rate, and so forth).
Try: watch -d "mountstats --rpc /mnt/your-mount-here"
tools/mountstats/mountstats.py | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index 9a6ec43..f75103c 100644
--- a/tools/mountstats/mountstats.py
+++ b/tools/mountstats/mountstats.py
@@ -24,6 +24,7 @@ MA 02110-1301 USA
"""
import sys, os, time
+from operator import itemgetter
Mountstats_version = '0.2'
@@ -262,27 +263,29 @@ class DeviceData:
"""
sends = self.__rpc_data['rpcsends']
- # XXX: these should be sorted by 'count'
- print()
+ allstats = []
for op in self.__rpc_data['ops']:
- stats = self.__rpc_data[op]
- count = stats[0]
- retrans = stats[1] - count
+ allstats.append([op] + self.__rpc_data[op])
+
+ print()
+ for stats in sorted(allstats, key=itemgetter(1), reverse=True):
+ count = stats[1]
if count != 0:
- print('%s:' % op)
+ print('%s:' % stats[0])
print('\t%d ops (%d%%)' % \
(count, ((count * 100) / sends)), end=' ')
+ retrans = stats[2] - count
if retrans != 0:
print('\t%d retrans (%d%%)' % (retrans, ((retrans * 100) / count)), end=' ')
- print('\t%d major timeouts' % stats[2])
+ print('\t%d major timeouts' % stats[3])
else:
print('')
print('\tavg bytes sent per op: %d\tavg bytes received per op: %d' % \
- (stats[3] / count, stats[4] / count))
- print('\tbacklog wait: %f' % (float(stats[5]) / count), end=' ')
- print('\tRTT: %f' % (float(stats[6]) / count), end=' ')
+ (stats[4] / count, stats[5] / count))
+ print('\tbacklog wait: %f' % (float(stats[6]) / count), end=' ')
+ print('\tRTT: %f' % (float(stats[7]) / count), end=' ')
print('\ttotal execute time: %f (milliseconds)' % \
- (float(stats[7]) / count))
+ (float(stats[8]) / count))
def compare_iostats(self, old_stats):
"""Return the difference between two sets of stats
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mountstats: Sort RPC statistics by operation count
2014-11-04 22:14 [PATCH] mountstats: Sort RPC statistics by operation count Chuck Lever
@ 2014-12-06 22:24 ` Steve Dickson
0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2014-12-06 22:24 UTC (permalink / raw)
To: Chuck Lever, linux-nfs
Hey Chuck,
First of all, my apologies for taking so long to get to this...
On 11/04/2014 05:14 PM, Chuck Lever wrote:
> Sort the RPC statistics in descending order by operation count, so
> that the most frequently executed operation appears at the top of
> the listing (a la `top`).
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> Hey folks-
>
> Any opinions about this? I considered adding a "--sort" command line
> option to enable sorting, but instead made it always-on.
>
> Could also use --sort to specify which individual statistic is used
> for sorting (op count, RTT, retransmit rate, and so forth).
This is an interesting idea... But let me get in Scott's patches
and then we can build from there...
>
> Try: watch -d "mountstats --rpc /mnt/your-mount-here"
I had better luck with watch -n 0 "mountstats --rpc /mnt/your-mount-here"
But the output looks much better... Nice work!
Committed...
steved.
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
> index 9a6ec43..f75103c 100644
> --- a/tools/mountstats/mountstats.py
> +++ b/tools/mountstats/mountstats.py
> @@ -24,6 +24,7 @@ MA 02110-1301 USA
> """
>
> import sys, os, time
> +from operator import itemgetter
>
> Mountstats_version = '0.2'
>
> @@ -262,27 +263,29 @@ class DeviceData:
> """
> sends = self.__rpc_data['rpcsends']
>
> - # XXX: these should be sorted by 'count'
> - print()
> + allstats = []
> for op in self.__rpc_data['ops']:
> - stats = self.__rpc_data[op]
> - count = stats[0]
> - retrans = stats[1] - count
> + allstats.append([op] + self.__rpc_data[op])
> +
> + print()
> + for stats in sorted(allstats, key=itemgetter(1), reverse=True):
> + count = stats[1]
> if count != 0:
> - print('%s:' % op)
> + print('%s:' % stats[0])
> print('\t%d ops (%d%%)' % \
> (count, ((count * 100) / sends)), end=' ')
> + retrans = stats[2] - count
> if retrans != 0:
> print('\t%d retrans (%d%%)' % (retrans, ((retrans * 100) / count)), end=' ')
> - print('\t%d major timeouts' % stats[2])
> + print('\t%d major timeouts' % stats[3])
> else:
> print('')
> print('\tavg bytes sent per op: %d\tavg bytes received per op: %d' % \
> - (stats[3] / count, stats[4] / count))
> - print('\tbacklog wait: %f' % (float(stats[5]) / count), end=' ')
> - print('\tRTT: %f' % (float(stats[6]) / count), end=' ')
> + (stats[4] / count, stats[5] / count))
> + print('\tbacklog wait: %f' % (float(stats[6]) / count), end=' ')
> + print('\tRTT: %f' % (float(stats[7]) / count), end=' ')
> print('\ttotal execute time: %f (milliseconds)' % \
> - (float(stats[7]) / count))
> + (float(stats[8]) / count))
>
> def compare_iostats(self, old_stats):
> """Return the difference between two sets of stats
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-06 22:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 22:14 [PATCH] mountstats: Sort RPC statistics by operation count Chuck Lever
2014-12-06 22:24 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox