diff mbox series

[nfs-utils,2/8] mountstats: when printing iostats, verify that old and new types are the same

Message ID 20250130142008.3600334-3-sorenson@redhat.com (mailing list archive)
State Handled Elsewhere
Headers show
Series mountstats/nfsiostat: bugfixes for iostat | expand

Commit Message

Frank Sorenson Jan. 30, 2025, 2:20 p.m. UTC
It's not sufficient to verify that old and new are not autofs; both
should be the same fstype, in order to cover other potential
mismatches.  This prevents crashes when a path is a mountpoint, but
not nfs or autofs.

Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
 tools/mountstats/mountstats.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index 00d1ac7e..59139ccc 100755
--- a/tools/mountstats/mountstats.py
+++ b/tools/mountstats/mountstats.py
@@ -961,14 +961,15 @@  def print_iostat_summary(old, new, devices, time):
     for device in devices:
         stats = DeviceData()
         stats.parse_stats(new[device])
-        if not old or device not in old:
+        if old and device in old:
+            old_stats = DeviceData()
+            old_stats.parse_stats(old[device])
+            if stats.fstype() == old_stats.fstype():
+                stats.compare_iostats(old_stats).display_iostats(time)
+            else: # device is in old, but fstypes are different
+                stats.display_iostats(time)
+        else: # device is only in new
             stats.display_iostats(time)
-        else:
-            if ("fstype autofs" not in str(old[device])) and ("fstype autofs" not in str(new[device])):
-                old_stats = DeviceData()
-                old_stats.parse_stats(old[device])
-                diff_stats = stats.compare_iostats(old_stats)
-                diff_stats.display_iostats(time)
 
 def iostat_command(args):
     """iostat-like command for NFS mount points