From: Rohan Sable <rsable@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: rsable@redhat.com, steved@redhat.com, smayhew@redhat.com
Subject: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding.
Date: Thu, 4 Jun 2020 23:22:21 +0530 [thread overview]
Message-ID: <20200604175221.GA157967@fedora.rsable.com> (raw)
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 <rsable@redhat.com>
---
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)")
+
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
next reply other threads:[~2020-06-04 17:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 17:52 Rohan Sable [this message]
2020-06-04 18:12 ` [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding Chuck Lever
2020-06-04 18:53 ` Kenneth Dsouza
2020-06-04 19:23 ` Kenneth Dsouza
2020-06-04 19:34 ` Chuck Lever
[not found] ` <CAC0K3ih2GF6sxio70WMVxiO24e7xfRjVFfgScFSvYRSyjZ4+XQ@mail.gmail.com>
[not found] ` <CAC0K3iiJ3vdvAidLugYeCJGU669=tdd2a4Dj_iez2MVrWsdNfA@mail.gmail.com>
2020-06-04 23:27 ` Chuck Lever
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=20200604175221.GA157967@fedora.rsable.com \
--to=rsable@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=smayhew@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.