Message ID | CAD9POpJSfbBYVgupAFxie_N6g2BQAUZ-qWV=tZFMHMJMmdqoYw@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/1] mountstats: division by zero error on new mount when 0==rpcsends | expand |
On 9/22/21 11:44 AM, Stig wrote: > For https://bugzilla.linux-nfs.org/show_bug.cgi?id=367 > > When rpcsends is 0 this is the error seen when mounstats is run on a > NFSv4.2 mount: > >> sudo umount /fsx ; sudo mount /fsx ; mountstats /fsx Committed... (tag: nfs-utils-2-5-5-rc3) On future patches please use the proper 'Signed-off-by:' tag. steved. > ... > RPC statistics: > 0 RPC requests sent, 0 RPC replies received (0 XIDs not found) > > SERVER_CAPS: > Traceback (most recent call last): > File "mountstats.py.orig", line 1134, in <module> > res = main() > File "mountstats.py.orig", line 1123, in main > return args.func(args) > File "mountstats.py.orig", line 863, in mountstats_command > print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw, > args.xprt_only) > File "mountstats.py.orig", line 825, in print_mountstats > stats.display_rpc_op_stats() > File "mountstats.py.orig", line 486, in display_rpc_op_stats > (count, ((count * 100) / sends)), end=' ') > ZeroDivisionError: division by zero > > Fixed with: > > diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py > index 23876fc..8e129c8 100755 > --- a/tools/mountstats/mountstats.py > +++ b/tools/mountstats/mountstats.py > @@ -482,8 +482,11 @@ class DeviceData: > count = stats[1] > if count != 0: > print('%s:' % stats[0]) > + ops_pcnt = 0 > + if sends != 0: > + ops_pcnt = (count * 100) / sends > print('\t%d ops (%d%%)' % \ > - (count, ((count * 100) / sends)), end=' ') > + (count, ops_pcnt), end=' ') > retrans = stats[2] - count > if retrans != 0: > print('\t%d retrans (%d%%)' % (retrans, ((retrans > * 100) / count)), end=' ') >
diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index 23876fc..8e129c8 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -482,8 +482,11 @@ class DeviceData: count = stats[1] if count != 0: print('%s:' % stats[0]) + ops_pcnt = 0 + if sends != 0: + ops_pcnt = (count * 100) / sends print('\t%d ops (%d%%)' % \ - (count, ((count * 100) / sends)), end=' ') + (count, ops_pcnt), end=' ') retrans = stats[2] - count if retrans != 0: print('\t%d retrans (%d%%)' % (retrans, ((retrans
For https://bugzilla.linux-nfs.org/show_bug.cgi?id=367 When rpcsends is 0 this is the error seen when mounstats is run on a NFSv4.2 mount: > sudo umount /fsx ; sudo mount /fsx ; mountstats /fsx ... RPC statistics: 0 RPC requests sent, 0 RPC replies received (0 XIDs not found) SERVER_CAPS: Traceback (most recent call last): File "mountstats.py.orig", line 1134, in <module> res = main() File "mountstats.py.orig", line 1123, in main return args.func(args) File "mountstats.py.orig", line 863, in mountstats_command print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw, args.xprt_only) File "mountstats.py.orig", line 825, in print_mountstats stats.display_rpc_op_stats() File "mountstats.py.orig", line 486, in display_rpc_op_stats (count, ((count * 100) / sends)), end=' ') ZeroDivisionError: division by zero Fixed with: * 100) / count)), end=' ')