summaryrefslogtreecommitdiff
path: root/tools/mountstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2014-12-06 17:22:14 -0500
committerSteve Dickson <steved@redhat.com>2014-12-06 17:22:14 -0500
commit4ac215e53e7d1ae54da2930f2d77eff74092040d (patch)
treec7c1c1c82911dfebc532ab044e4a71cad5a73637 /tools/mountstats
parentd6ef125c4be83de1d94727bf6be74cd7c0bf424c (diff)
downloadnfs-utils-4ac215e53e7d1ae54da2930f2d77eff74092040d.tar.gz
mountstats: Sort RPC statistics by operation count
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> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'tools/mountstats')
-rw-r--r--tools/mountstats/mountstats.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index e6a456c..247a64a 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