From 02533e1dcfc097ea31ba0155b9495ba841d666f5 Mon Sep 17 00:00:00 2001 From: Ewald van Geffen Date: Sat, 13 Oct 2018 18:52:07 +0200 Subject: Update show_dhcp.py I don't really do python, please check/test. --- src/op_mode/show_dhcp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/op_mode/show_dhcp.py b/src/op_mode/show_dhcp.py index e76fc3a14..0005d62a3 100755 --- a/src/op_mode/show_dhcp.py +++ b/src/op_mode/show_dhcp.py @@ -142,7 +142,12 @@ if __name__ == '__main__': for p in pools: size = get_pool_size(config, p) leases = len(get_leases(lease_file, state='active', pool=args.pool)) - use_percentage = round(leases / size) * 100 + + if size != 0: + use_percentage = round(leases / size) * 100 + else: + use_percentage = 0 + if args.json: pool_stats = {"pool": p, "size": size, "leases": leases, "available": (size - leases), "percentage": use_percentage} -- cgit v1.2.3