summaryrefslogtreecommitdiff
path: root/src/op_mode/show_dhcp.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-10-14 01:52:07 +0700
committerGitHub <noreply@github.com>2018-10-14 01:52:07 +0700
commite98e44c724b21a5c5aeb312f22a2c29605415df5 (patch)
tree43699d7591f55ee217471a404dee385e5e3466aa /src/op_mode/show_dhcp.py
parent24d76821ede9966127883840a4bd199807926fac (diff)
parent02533e1dcfc097ea31ba0155b9495ba841d666f5 (diff)
downloadvyos-1x-e98e44c724b21a5c5aeb312f22a2c29605415df5.tar.gz
vyos-1x-e98e44c724b21a5c5aeb312f22a2c29605415df5.zip
Merge pull request #54 from EwaldvanGeffen/patch-1
Show usage percentage as zero when there are no leases
Diffstat (limited to 'src/op_mode/show_dhcp.py')
-rwxr-xr-xsrc/op_mode/show_dhcp.py7
1 files changed, 6 insertions, 1 deletions
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}