Module: check_mk
Branch: master
Commit: ac40c72b220d8b1c9b01c086f2e99af397ec1125
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ac40c72b220d8b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri May 3 09:15:51 2013 +0200
handle exception in check_timeperiod
---
modules/check_mk_base.py | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index a24a650..09a3043 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1493,13 +1493,21 @@ def check_timeperiod(timeperiod):
global g_inactive_timerperiods
# Let exceptions happen, they will be handled upstream.
if g_inactive_timerperiods == None:
- import socket
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.connect(livestatus_unix_socket)
- # We just get the currently inactive timeperiods. All others
- # (also non-existing) are considered to be active
- s.send("GET timeperiods\nColumns:name\nFilter: in = 0\n")
- s.shutdown(socket.SHUT_WR)
- g_inactive_timerperiods = s.recv(10000000).splitlines()
+ try:
+ import socket
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.connect(livestatus_unix_socket)
+ # We just get the currently inactive timeperiods. All others
+ # (also non-existing) are considered to be active
+ s.send("GET timeperiods\nColumns:name\nFilter: in = 0\n")
+ s.shutdown(socket.SHUT_WR)
+ g_inactive_timerperiods = s.recv(10000000).splitlines()
+ except Exception, e:
+ if opt_debug:
+ raise
+ else:
+ # If the query is not successful better skip this check then fail
+ return False
+
return timeperiod not in g_inactive_timerperiods