Module: check_mk
Branch: master
Commit: 3816ba3c25918af652bd39619aff565ba328de5a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3816ba3c25918a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 22 09:22:16 2016 +0100
#3227 FIX Automatic service adding: Fixed exception when using time range to skip
automatic configuration
This fixes the exception:
Traceback (most recent call last):
File "/omd/sites/stable/share/check_mk/modules/check_mk.py", line 5065, in
<module>
discover_marked_hosts()
File "/omd/sites/stable/share/check_mk/modules/discovery.py", line 441, in
discover_marked_hosts
why_not = may_rediscover(params)
File "/omd/sites/stable/share/check_mk/modules/discovery.py", line 389, in
may_rediscover
now = datetime.datetime.utcfromtimestamp(now_ts)
NameError: global name 'datetime' is not defined
---
.werks/3227 | 20 ++++++++++++++++++++
ChangeLog | 1 +
modules/discovery.py | 12 +++++++++---
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/.werks/3227 b/.werks/3227
new file mode 100644
index 0000000..b79e833
--- /dev/null
+++ b/.werks/3227
@@ -0,0 +1,20 @@
+Title: Automatic service adding: Fixed exception when using time range to skip automatic
configuration
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1456129237
+
+This fixes the exception:
+
+Traceback (most recent call last):
+ File "/omd/sites/stable/share/check_mk/modules/check_mk.py", line 5065, in
<module>
+ discover_marked_hosts()
+ File "/omd/sites/stable/share/check_mk/modules/discovery.py", line 441, in
discover_marked_hosts
+ why_not = may_rediscover(params)
+ File "/omd/sites/stable/share/check_mk/modules/discovery.py", line 389, in
may_rediscover
+ now = datetime.datetime.utcfromtimestamp(now_ts)
+NameError: global name 'datetime' is not defined
+
diff --git a/ChangeLog b/ChangeLog
index 7b969e3..68061ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,7 @@
* 3226 FIX: isc_dhcpd: Fixed exception during discovery when pools can not be
gathered by agent
* 3189 FIX: mem.vmalloc: newer kernel versions (64bit) report wrong data, i.d. both
VmallocUsed and Chunk equal zero, thus this check is obsolete
* 3079 FIX: win_printers: fixed typo that kept default parameters from being used...
+ * 3227 FIX: Automatic service adding: Fixed exception when using time range to skip
automatic configuration...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/modules/discovery.py b/modules/discovery.py
index 4fc1c57..95300f3 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -386,10 +386,16 @@ def discover_marked_hosts():
if "inventory_rediscovery" not in params:
return "automatic discovery disabled for this host"
- now = datetime.datetime.utcfromtimestamp(now_ts)
+ now = time.gmtime(now_ts)
for start_hours_mins, end_hours_mins in
params["inventory_rediscovery"]["excluded_time"]:
- start_time = datetime.datetime(now.year, now.month, now.day,
start_hours_mins[0], start_hours_mins[1])
- end_time = datetime.datetime(now.year, now.month, now.day, end_hours_mins[0],
end_hours_mins[1])
+ start_time = time.struct_time((now.tm_year, now.tm_mon, now.tm_mday,
+ start_hours_mins[0], start_hours_mins[1], 0,
+ now.tm_wday, now.tm_yday, now.tm_isdst))
+
+ end_time = time.struct_time((now.tm_year, now.tm_mon, now.tm_mday,
+ end_hours_mins[0], end_hours_mins[1], 0,
+ now.tm_wday, now.tm_yday, now.tm_isdst))
+
if start_time <= now <= end_time:
return "we are currently in a disallowed time of day"