Linux NFS development
 help / color / mirror / Atom feed
From: Rohan Sable <rsable@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: rsable@redhat.com, steved@redhat.com
Subject: [PATCH] mountstats: Adding Day:Hour:Min:Sec format along with age to "mountstats --raw" for ease of understanding.
Date: Tue, 2 Jun 2020 14:59:19 +0530	[thread overview]
Message-ID: <20200602092919.GA42177@fedora.rsable.com> (raw)

The output will look something like this :

From :
age:    2215

To   :
age:    2267; 0 Day(s) 0 Hour(s) 37 Min(s) 47 Sec(s)

Signed-off-by: Rohan Sable <rsable@redhat.com>
---
 tools/mountstats/mountstats.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index 6ac83ccb..d9b5af1b 100755
--- a/tools/mountstats/mountstats.py
+++ b/tools/mountstats/mountstats.py
@@ -228,6 +228,15 @@ Nfsv4ops = [
     'CLONE'
 ]
 
+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)")
+
 class DeviceData:
     """DeviceData objects provide methods for parsing and displaying
     data for a single mount grabbed from /proc/self/mountstats
@@ -349,7 +358,8 @@ class DeviceData:
             (self.__nfs_data['export'], self.__nfs_data['mountpoint'], \
             self.__nfs_data['fstype'], self.__nfs_data['statvers']))
         print('\topts:\t%s' % ','.join(self.__nfs_data['mountoptions']))
-        print('\tage:\t%d' % self.__nfs_data['age'])
+        print('\tage:\t%d' % self.__nfs_data['age'], end="; ")
+        sec_conv(self.__nfs_data['age'])
         print('\tcaps:\t%s' % ','.join(self.__nfs_data['servercapabilities']))
         print('\tsec:\tflavor=%d,pseudoflavor=%d' % (self.__nfs_data['flavor'], \
             self.__nfs_data['pseudoflavor']))
-- 
2.25.4


             reply	other threads:[~2020-06-02  9:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  9:29 Rohan Sable [this message]
2020-06-03 14:57 ` [PATCH] mountstats: Adding Day:Hour:Min:Sec format along with age to "mountstats --raw" for ease of understanding Scott Mayhew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200602092919.GA42177@fedora.rsable.com \
    --to=rsable@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox