summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKenneth D'souza <kdsouza@redhat.com>2020-08-31 10:45:36 -0400
committerSteve Dickson <steved@redhat.com>2020-08-31 10:54:31 -0400
commit4d5da01f926341bca97617e223656e3a90bcce5d (patch)
tree6e95b2d282935155e3f1c4b98b036ce937164678 /tools
parent574dd0ab54f0c97aba69661bd4410bd0773780a3 (diff)
downloadnfs-utils-4d5da01f926341bca97617e223656e3a90bcce5d.tar.gz
nfs-iostat: divide by zero with fresh mount
When an export is freshly mounted, /proc/self/mountstats displays age = 0. This causes nfs-iostat to divide by zero throwing an error. When we have age = 0, other stats are greater than 0, so we'll set age = 1 and print the relevant stats. This will prevent a backtrace like this from occurring if nfsiostat is run. nfsiostat -s 1 Traceback (most recent call last): File "/usr/sbin/nfsiostat", line 662, in <module> iostat_command(prog) File "/usr/sbin/nfsiostat", line 644, in iostat_command print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) File "/usr/sbin/nfsiostat", line 490, in print_iostat_summary devicelist.sort(key=lambda x: stats[x].ops(time), reverse=True) File "/usr/sbin/nfsiostat", line 490, in <lambda> devicelist.sort(key=lambda x: stats[x].ops(time), reverse=True) File "/usr/sbin/nfsiostat", line 383, in ops return (sends / sample_time) ZeroDivisionError: float division by zero Signed-off-by: Kenneth D'souza <kdsouza@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/nfs-iostat/nfs-iostat.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
index 5556f69..50fd6a9 100755
--- a/tools/nfs-iostat/nfs-iostat.py
+++ b/tools/nfs-iostat/nfs-iostat.py
@@ -383,6 +383,8 @@ class DeviceData:
sends = float(self.__rpc_data['rpcsends'])
if sample_time == 0:
sample_time = float(self.__nfs_data['age'])
+ if sample_time == 0:
+ sample_time = 1;
return (sends / sample_time)
def display_iostats(self, sample_time, which):