The test for empty device list and 'No NFS mount points found' message terminate the program immediately if no nfs mounts are present during a particular iteration. However, if multiple iterations are specified, it makes more sense to simply output the message and sleep for the next iteration, since there may be nfs mounts next time through. If we move the test and message into the print function, we still get the message when appropriate, don't terminate on an empty list, and also eliminate two extra copies of the same test and message. Signed-off-by: Frank Sorenson <sorenson@xxxxxxxxxx> --- tools/mountstats/mountstats.py | 13 ++++--------- tools/nfs-iostat/nfs-iostat.py | 14 ++++---------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index e640642a..fbd57f51 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -958,6 +958,10 @@ def nfsstat_command(args): return 0 def print_iostat_summary(old, new, devices, time): + if len(devices) == 0: + print('No NFS mount points were found') + return + for device in devices: stats = DeviceData() stats.parse_stats(new[device]) @@ -1005,9 +1009,6 @@ def iostat_command(args): # make certain devices contains only NFS mount points devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return 1 sample_time = 0 @@ -1026,9 +1027,6 @@ def iostat_command(args): # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return count -= 1 else: while True: @@ -1040,9 +1038,6 @@ def iostat_command(args): # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return args.infile.close() if args.since: diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index 1502b431..f69ffb0e 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -478,6 +478,10 @@ def parse_stats_file(filename): def print_iostat_summary(old, new, devices, time, options): display_stats = {} + if len(devices) == 0: + print('No NFS mount points were found') + return + for device in devices: stats = DeviceData() stats.parse_stats(new[device]) @@ -612,10 +616,6 @@ client are listed. # make certain devices contains only NFS mount points devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return - old_mountstats = None sample_time = 0.0 @@ -634,9 +634,6 @@ client are listed. # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices,mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return count -= 1 else: while True: @@ -648,9 +645,6 @@ client are listed. # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices,mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return # # Main -- 2.48.1