Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1541034ybg; Thu, 4 Jun 2020 12:18:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMNjOSe0Db4bOMq63JnEfot52DVe8+RhzHR882BXKPvZ39EXfAjns5dtsmgOCvu0NpRVap X-Received: by 2002:a17:907:ab9:: with SMTP id bz25mr5089848ejc.39.1591298327529; Thu, 04 Jun 2020 12:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591298327; cv=none; d=google.com; s=arc-20160816; b=ZLxj4NW1Qh4hrlr0u3j9lkEk1SdGJZ6fIVbSuIubG+p4jvFUNeWmoe+LtAQOhYrkWq 6BdmGmbfJvYet0qzFSuy6K+MWcIQGu4YTQqyrWk0P6kUgM5ZYxifIlgCcsKLvRIEqh0N 40pgz9cN+TOXrkx/LtXHWYGZzbOPdOdr1ZeEr8dU+4AEJEeULmPMuLvQN3yKtcRGbaiS AjGFi+7ttVuQNOrH/P9rMYc/ubcj/Hs2ZUlZXJGI+mKTOjyhy8OJXSzyw+duNrR62aJi woKsqfgH0hdSzR14kK5ZmO+BgDN4CA28kPEeM8HxKLzmwIiw1KPSgu1XS3xdJyUmSUUh 2H5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aekG9mWmr6Bu9/zhemMbV6tEy9wacArwZKVmcDVcPxI=; b=ywz+hiw8FK/4iCA3tZ1KqH4endjoiV/FSXHxbW+47nfqNpAMqvF6YvAd0hl9lCvHmW K6gZ4BodeP3/av6FdWibGTH2jbkAJ3iCYfsfjZbkwcut+eQGytrzVVqgShfaRPQQ+7dl xIET/3478FBNdAEIEYLJbJNiDgbxWfde+pmBMrG3Vi5SG3qX8jwv9rIiH9WqO7Jdqgm4 QklcMdwulUSrOJumHfepvq9YKHpMHaJvStVipijFtQoVsVknLN805vePKzKVBlSNnNAN AsKPRv7Valr0dialn3O5SJgORqJYT+BX7SD+idhAZshV5n44rN0NQefCSTdK8rWvRl+4 VtrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c6tzGrcx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du21si1825991ejc.516.2020.06.04.12.18.08; Thu, 04 Jun 2020 12:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c6tzGrcx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbgFDSxQ (ORCPT + 99 others); Thu, 4 Jun 2020 14:53:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49586 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728476AbgFDSxQ (ORCPT ); Thu, 4 Jun 2020 14:53:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591296795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aekG9mWmr6Bu9/zhemMbV6tEy9wacArwZKVmcDVcPxI=; b=c6tzGrcx8F/J2+SRM046L/s81Q09WK3jXGGlJub2n/bIvAU+uCdTzdTQtbGABTdXVXhZr0 Od8xZHPxjbs+ihBAHer2kDeLUNpuzG8l9xZamEcwH4BLipKdsRHRpRd47MQE6k+rVlyRSy 7pq2Ti3J/+bQWmrKj343QewzDqoixg0= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-148-acFC1U7rNWiXdjNsqWp71g-1; Thu, 04 Jun 2020 14:53:13 -0400 X-MC-Unique: acFC1U7rNWiXdjNsqWp71g-1 Received: by mail-qk1-f199.google.com with SMTP id a6so5477081qka.9 for ; Thu, 04 Jun 2020 11:53:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aekG9mWmr6Bu9/zhemMbV6tEy9wacArwZKVmcDVcPxI=; b=ZrqYsh1Hc+KlCKwfeLDxSilV4vHyJKqKiyQdNDXqNLj19Zj4yrWL6RHNCDLjr8UdRK 2xd4td3wjOIYGTrJAvRD37UZYIGewydRNCSGMXjEVVP31puEB1tFlMGki7lUIlLzSswR bkbZU8aFcLlMIol6M8tILdBjZXFsm6FDd/O3yUccTslapb/T1kOATn4bpOvp6RTl6T/q I9qvHt385bhmbTTiBijtQQtzlBDqZooD7Q5f7bgn+vCC082edTnOXcQTYux9tUxv2dnH PMzuyRsjE1yyJSCSI/XaeqQTszWVtLeTJSHMyBCaMLEfXDKoE3Afy8/Pg9fPnTw3bBq2 Zrvg== X-Gm-Message-State: AOAM531sDYcfT9zpfvzFDbgc5elFw9/biTDQNnGPOJh+JZnLRvzBqHqo 4KW8742wvbCSk/+flOF2lltq44OtJEHfJ41DVEjDZnwxp80EprVXxw2TBA/UIq0i77iX9HnqGMR 6GAKaIdXAPIz1hiKIg86ueYS/9+8ID9nfZrjp X-Received: by 2002:a0c:fde4:: with SMTP id m4mr6135243qvu.207.1591296793145; Thu, 04 Jun 2020 11:53:13 -0700 (PDT) X-Received: by 2002:a0c:fde4:: with SMTP id m4mr6135223qvu.207.1591296792794; Thu, 04 Jun 2020 11:53:12 -0700 (PDT) MIME-Version: 1.0 References: <20200604175221.GA157967@fedora.rsable.com> <04942C45-9C31-424E-B5A1-C83553F786CE@oracle.com> In-Reply-To: <04942C45-9C31-424E-B5A1-C83553F786CE@oracle.com> From: Kenneth Dsouza Date: Fri, 5 Jun 2020 00:23:01 +0530 Message-ID: Subject: Re: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. To: Chuck Lever Cc: Rohan Sable , Linux NFS Mailing List , Steve Dickson , smayhew@redhat.com Content-Type: text/plain; charset="UTF-8" Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Using the datetime module? datetime.timedelta(seconds = n) Should print in below format 0:11:05 On Thu, Jun 4, 2020 at 11:45 PM Chuck Lever wrote: > > > > > On Jun 4, 2020, at 1:52 PM, Rohan Sable wrote: > > > > This patch adds printing of 'Age' in 'Sec' and 'Day:Hours:Min:Sec' like below to --nfs in mountstats : > > NFS mount age: 9479; 0 Day(s) 2 Hour(s) 37 Min(s) 59 Sec(s) > > > > Signed-off-by: Rohan Sable > > --- > > tools/mountstats/mountstats.py | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py > > index d565385d..c4f4f9e6 100755 > > --- a/tools/mountstats/mountstats.py > > +++ b/tools/mountstats/mountstats.py > > @@ -233,6 +233,16 @@ Nfsv4ops = [ > > 'COPY_NOTIFY' > > ] > > > > +# Function to convert sec from age to Day:Hours:Min:Sec. > > +def sec_conv(rem): > > + day = int(rem / (24 * 3600)) > > + rem %= (24 * 3600) > > + hrs = int(rem / 3600) > > + rem %= 3600 > > + min = int(rem / 60) > > + sec = rem % 60 > > + print(day, "Day(s)", hrs, "Hour(s)", min, "Min(s)", sec, "Sec(s)") > > + > > Just wondering if there's a Python module that can do this for us? > > > > class DeviceData: > > """DeviceData objects provide methods for parsing and displaying > > data for a single mount grabbed from /proc/self/mountstats > > @@ -391,6 +401,8 @@ class DeviceData: > > """Pretty-print the NFS options > > """ > > print(' NFS mount options: %s' % ','.join(self.__nfs_data['mountoptions'])) > > + print(' NFS mount age: %d' % self.__nfs_data['age'], end="; ") > > + sec_conv(self.__nfs_data['age']) > > print(' NFS server capabilities: %s' % ','.join(self.__nfs_data['servercapabilities'])) > > if 'nfsv4flags' in self.__nfs_data: > > print(' NFSv4 capability flags: %s' % ','.join(self.__nfs_data['nfsv4flags'])) > > -- > > 2.25.4 > > > > -- > Chuck Lever > > >