diff options
author | Rohan Sable <rsable@redhat.com> | 2020-10-31 12:11:29 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2020-10-31 12:11:29 -0400 |
commit | f5f3a9d93dceedddf6c4037d8534f152621e2c52 (patch) | |
tree | 3532ec1c95e3a1bec3b317bef06ea4792eb49681 /tools | |
parent | 4c2da1619815faad761df98c001feabda33085d6 (diff) | |
download | nfs-utils-f5f3a9d93dceedddf6c4037d8534f152621e2c52.tar.gz |
mountstats: handle KeyError in display_raw_stats
While printing Nfsv4ops from older /proc/self/mountstats
e.g. in 2.6.32-754.el6.x86_64 from RHEL 6.10,
it will not have all the Keys present leading to a KeyError
like below :
Traceback (most recent call last):
File "nfs-utils/tools/mountstats/mountstats.py", line 1131, in <module>
res = main()
File "nfs-utils/tools/mountstats/mountstats.py", line 1120, in main
return args.func(args)
File "nfs-utils/tools/mountstats/mountstats.py", line 860, in mountstats_command
print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw, args.xprt_only)
File "nfs-utils/tools/mountstats/mountstats.py", line 813, in print_mountstats
stats.display_raw_stats()
File "nfs-utils/tools/mountstats/mountstats.py", line 381, in display_raw_stats
print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op])))
KeyError: 'FSID_PRESENT'
Signed-off-by: Rohan Sable <rsable@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/mountstats/mountstats.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index 25e92a1..23876fc 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -378,7 +378,10 @@ class DeviceData: print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) elif vers == '4': for op in Nfsv4ops: - print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) + try: + print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) + except KeyError: + continue else: print('\tnot implemented for version %d' % vers) print() |