From patchwork Tue Nov 4 22:14:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 5231151 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7BF86C11AC for ; Tue, 4 Nov 2014 22:14:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9ACDE2015E for ; Tue, 4 Nov 2014 22:14:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE42F20155 for ; Tue, 4 Nov 2014 22:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751421AbaKDWOi (ORCPT ); Tue, 4 Nov 2014 17:14:38 -0500 Received: from mail-ig0-f176.google.com ([209.85.213.176]:58971 "EHLO mail-ig0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751368AbaKDWOi (ORCPT ); Tue, 4 Nov 2014 17:14:38 -0500 Received: by mail-ig0-f176.google.com with SMTP id l13so8246673iga.15 for ; Tue, 04 Nov 2014 14:14:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=KSTS7oS8j/mqeFATeiZ33mKurEZvUZlCRIiDLKEMnv0=; b=BR0QahmTAUBwjg7oreXQCWsMVsWubrBV4X3soaNdMlnB4FL2tjt9G+sRgqI35H8l/U p8wSLheLhM2hIgU/2qMHRsKu+qeKWkejNfzvbs2vfvqkhaczePIBBOm6JsdcEnNo+WHE Cep/C3RjcGbKLuLrfuceyHsKNfsYmSVEWVUd5u6bp6Iv4et8XMluwNuOb0S+gsaOBSnj 2WQFdN7PwLF8BowK3MtCQ0Ft25LjkhSxHWp8Bl/10uaB/kFMEiE80mhR1zX3zOcjMtH0 6Qo/GITaDmQRe/jkDkNDUp2iA5BEF/9AknvcycNVOER0gPZy/U8G5y7KTy7Gy76N6/c8 2pOA== X-Received: by 10.42.207.76 with SMTP id fx12mr722014icb.17.1415139277490; Tue, 04 Nov 2014 14:14:37 -0800 (PST) Received: from manet.1015granger.net ([2604:8800:100:81fc:82ee:73ff:fe43:d64f]) by mx.google.com with ESMTPSA id c18sm728530ioe.22.2014.11.04.14.14.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Nov 2014 14:14:37 -0800 (PST) Subject: [PATCH] mountstats: Sort RPC statistics by operation count From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 04 Nov 2014 17:14:35 -0500 Message-ID: <20141104221043.13019.51333.stgit@manet.1015granger.net> User-Agent: StGit/0.17.1-3-g7d0f MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) -- 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 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