Module: check_mk
Branch: master
Commit: 5e51e729720658d1e031dff41c9927862c379366
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5e51e729720658…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 25 15:00:09 2016 +0200
3770 FIX win_dhcp_pools: Fixed crash in case of empty DHCP pools
---
.werks/3770 | 10 ++++++++++
ChangeLog | 1 +
checks/dhcp_pools.include | 7 ++++++-
checks/win_dhcp_pools | 1 +
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/.werks/3770 b/.werks/3770
new file mode 100644
index 0000000..1583e74
--- /dev/null
+++ b/.werks/3770
@@ -0,0 +1,10 @@
+Title: win_dhcp_pools: Fixed crash in case of empty DHCP pools
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1472129993
+
+
diff --git a/ChangeLog b/ChangeLog
index 4a5cb53..f807724 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -355,6 +355,7 @@
* 3765 FIX: oracle_asm_diskgroup: Made check more robust against invalid data
received from agent...
* 3766 FIX: palo_alto_sessions: Fixed possible division by zero error
* 3769 FIX: cisco_temperature: Fixed exception in case of empty SNMP data received
from device
+ * 3770 FIX: win_dhcp_pools: Fixed crash in case of empty DHCP pools
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/dhcp_pools.include b/checks/dhcp_pools.include
index d09a1f2..e348b2c 100644
--- a/checks/dhcp_pools.include
+++ b/checks/dhcp_pools.include
@@ -41,7 +41,12 @@ def check_dhcp_pools_levels(free, used, pending, size, params):
for what, value in [("free", free), ("used", used)]:
state = 0
value_abs = value
- value_perc = float(value) / size * 100.0
+
+ if size == 0:
+ value_perc = 0
+ else:
+ value_perc = float(value) / size * 100.0
+
infotext = "%s: %d leases (%.1f%%)" % (what, value, value_perc)
if params.get("%s_leases" % what, ""):
warn, crit = params["%s_leases" % what]
diff --git a/checks/win_dhcp_pools b/checks/win_dhcp_pools
index 939ebb1..6b565b7 100644
--- a/checks/win_dhcp_pools
+++ b/checks/win_dhcp_pools
@@ -135,6 +135,7 @@ def check_win_dhcp_pools(item, params, info):
# Catch unused pools
if size == 0:
yield 3, "DHCP Pool contains no IP addresses / is deactivated"
+ return
for check_result in check_dhcp_pools_levels(free, used, pending, size, params):
yield check_result