summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d8759b3)
raw | patch | inline | side by side (parent: d8759b3)
author | Sven Velt <sven@velt.de> | |
Tue, 5 Jan 2010 14:03:54 +0000 (15:03 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Tue, 5 Jan 2010 14:03:54 +0000 (15:03 +0100) |
nagixsc.py | patch | blob | history |
diff --git a/nagixsc.py b/nagixsc.py
index 4f834869f236ff6ba35bc2299ffe413cecf9fd0f..21fc9a85009f732559eabb7b54cbcab505e1db97 100644 (file)
--- a/nagixsc.py
+++ b/nagixsc.py
def xml_to_dict(xmldoc, verb=0, hostfilter=None, servicefilter=None):
checks = []
- filetimestamp = xml_get_timestamp(xmldoc)
+ now = int(datetime.datetime.now().strftime('%s'))
+ filetimestamp = reset_future_timestamp(xml_get_timestamp(xmldoc), now)
if hostfilter:
hosts = xmldoc.xpathNewContext().xpathEval('/nagixsc/host[name="%s"] | /nagixsc/host[name="%s"]' % (hostfilter, encode(hostfilter)))
output = None
if host.xpathEval('timestamp'):
- timestamp = int(host.xpathEval('timestamp')[0].get_content())
+ timestamp = reset_future_timestamp(int(host.xpathEval('timestamp')[0].get_content()), now)
else:
timestamp = filetimestamp
output = decode(xmloutput.get_content(), xmloutput.prop('encoding')).rstrip()
try:
- timestamp = int(service.xpathEval('timestamp')[0].get_content())
+ timestamp = reset_future_timestamp(int(service.xpathEval('timestamp')[0].get_content()), now)
except:
timestamp = filetimestamp
check['returncode'] = 3
return check
+
+def reset_future_timestamp(timestamp, now):
+ if timestamp <= now:
+ return timestamp
+ else:
+ return now
+