* [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. @ 2020-06-04 17:52 Rohan Sable 2020-06-04 18:12 ` Chuck Lever 0 siblings, 1 reply; 6+ messages in thread From: Rohan Sable @ 2020-06-04 17:52 UTC (permalink / raw) To: linux-nfs; +Cc: rsable, steved, smayhew 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. 2020-06-04 17:52 [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding Rohan Sable @ 2020-06-04 18:12 ` Chuck Lever 2020-06-04 18:53 ` Kenneth Dsouza 0 siblings, 1 reply; 6+ messages in thread From: Chuck Lever @ 2020-06-04 18:12 UTC (permalink / raw) To: Rohan Sable; +Cc: Linux NFS Mailing List, Steve Dickson, smayhew > On Jun 4, 2020, at 1:52 PM, Rohan Sable <rsable@redhat.com> 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 <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)") > + 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. 2020-06-04 18:12 ` Chuck Lever @ 2020-06-04 18:53 ` Kenneth Dsouza 2020-06-04 19:23 ` Kenneth Dsouza 0 siblings, 1 reply; 6+ messages in thread From: Kenneth Dsouza @ 2020-06-04 18:53 UTC (permalink / raw) To: Chuck Lever; +Cc: Rohan Sable, Linux NFS Mailing List, Steve Dickson, smayhew 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 <chuck.lever@oracle.com> wrote: > > > > > On Jun 4, 2020, at 1:52 PM, Rohan Sable <rsable@redhat.com> 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 <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)") > > + > > 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 > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. 2020-06-04 18:53 ` Kenneth Dsouza @ 2020-06-04 19:23 ` Kenneth Dsouza 2020-06-04 19:34 ` Chuck Lever 0 siblings, 1 reply; 6+ messages in thread From: Kenneth Dsouza @ 2020-06-04 19:23 UTC (permalink / raw) To: Chuck Lever; +Cc: Rohan Sable, Linux NFS Mailing List, Steve Dickson, smayhew I get the below results using the datetime module. # mountstats --nfs | grep -w age NFS mount age: 688865; 7 days, 23:21:05 On Fri, Jun 5, 2020 at 12:23 AM Kenneth Dsouza <kdsouza@redhat.com> wrote: > > 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 <chuck.lever@oracle.com> wrote: > > > > > > > > > On Jun 4, 2020, at 1:52 PM, Rohan Sable <rsable@redhat.com> 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 <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)") > > > + > > > > 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 > > > > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. 2020-06-04 19:23 ` Kenneth Dsouza @ 2020-06-04 19:34 ` Chuck Lever [not found] ` <CAC0K3ih2GF6sxio70WMVxiO24e7xfRjVFfgScFSvYRSyjZ4+XQ@mail.gmail.com> 0 siblings, 1 reply; 6+ messages in thread From: Chuck Lever @ 2020-06-04 19:34 UTC (permalink / raw) To: Kenneth Dsouza Cc: Rohan Sable, Linux NFS Mailing List, Steve Dickson, smayhew > On Jun 4, 2020, at 3:23 PM, Kenneth Dsouza <kdsouza@redhat.com> wrote: > > I get the below results using the datetime module. > > # mountstats --nfs | grep -w age > NFS mount age: 688865; 7 days, 23:21:05 For pretty-printing the mount point's age, you probably don't need to display the raw delta seconds value. > On Fri, Jun 5, 2020 at 12:23 AM Kenneth Dsouza <kdsouza@redhat.com> wrote: >> >> 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 <chuck.lever@oracle.com> wrote: >>> >>> >>> >>>> On Jun 4, 2020, at 1:52 PM, Rohan Sable <rsable@redhat.com> 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 <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)") >>>> + >>> >>> 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 >>> >>> >>> > -- Chuck Lever ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAC0K3ih2GF6sxio70WMVxiO24e7xfRjVFfgScFSvYRSyjZ4+XQ@mail.gmail.com>]
[parent not found: <CAC0K3iiJ3vdvAidLugYeCJGU669=tdd2a4Dj_iez2MVrWsdNfA@mail.gmail.com>]
* Re: [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding. [not found] ` <CAC0K3iiJ3vdvAidLugYeCJGU669=tdd2a4Dj_iez2MVrWsdNfA@mail.gmail.com> @ 2020-06-04 23:27 ` Chuck Lever 0 siblings, 0 replies; 6+ messages in thread From: Chuck Lever @ 2020-06-04 23:27 UTC (permalink / raw) To: Rohan Sable Cc: Kenneth Dsouza, Linux NFS Mailing List, Steve Dickson, smayhew > On Jun 4, 2020, at 4:12 PM, Rohan Sable <rsable@redhat.com> wrote: > > >> For pretty-printing the mount point's age, you probably don't need > >> to display the raw delta seconds value. > > Yes, I can drop that. > > >> Just wondering if there's a Python module that can do this for us? > > I was not exactly sure if I could be doing that, since this is kind of the 1st one for me. > If that's fine, using the timedate module makes it way smaller and easier. Importing "datetime" should be fine. -- Chuck Lever ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-06-04 23:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-04 17:52 [PATCH v2] mountstats: Adding 'Day:Hour:Min:Sec' format along with 'age' to "mountstats --nfs" for ease of understanding Rohan Sable
2020-06-04 18:12 ` 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
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.