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@xxxxxxxxxx> --- 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