summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0cf56d4)
raw | patch | inline | side by side (parent: 0cf56d4)
author | Sven Velt <sven@velt.de> | |
Mon, 21 Feb 2011 19:12:47 +0000 (20:12 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Mon, 21 Feb 2011 19:12:47 +0000 (20:12 +0100) |
Windows ActivePython has some problems with "strftime()" from "datetime". All
we need is also in "time" - and is much more simple...
Signed-off-by: Sven Velt <sven@velt.de>
we need is also in "time" - and is much more simple...
Signed-off-by: Sven Velt <sven@velt.de>
nagixsc/__init__.py | patch | blob | history | |
nagixsc_read_xml.py | patch | blob | history | |
nagixsc_xml2cfg.py | patch | blob | history | |
nagixsc_xml2nagios.py | patch | blob | history |
diff --git a/nagixsc/__init__.py b/nagixsc/__init__.py
index 827a104b26c849d855a4e919d3afcad22e342484..036fe7e16d33ce474909d327ef6782fece7b8510 100644 (file)
--- a/nagixsc/__init__.py
+++ b/nagixsc/__init__.py
import ConfigParser
import SocketServer
import base64
-import datetime
import libxml2
import mimetools
import os
import string
import subprocess
import sys
+import time
import urllib2
def debug(level, verb, string):
@@ -116,7 +116,7 @@ def exec_check(host_name, service_descr, cmdline, cmdprefix='', timeout=None, ti
except OSError:
pass
- check['timestamp'] = datetime.datetime.now().strftime('%s')
+ check['timestamp'] = str(long(time.time()))
return check
FORMAT_HOST = '[%s] PROCESS_HOST_CHECK_RESULT;%s;%s;%s'
FORMAT_SERVICE = '[%s] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%s;%s'
count_services = 0
- now = datetime.datetime.now().strftime('%s')
+ now = str(long(time.time()))
# Prepare
if opt_verb <= 2:
count_failed = 0
list_failed = []
chars = string.letters + string.digits
- ctimestamp = datetime.datetime.now().ctime()
+ ctimestamp = time.ctime()
random.seed()
for check in checks:
def xml_to_dict(xmldoc, verb=0, hostfilter=None, servicefilter=None):
checks = []
- now = int(datetime.datetime.now().strftime('%s'))
+ now = long(time.time())
filetimestamp = reset_future_timestamp(xml_get_timestamp(xmldoc), now)
if hostfilter:
xmldoc = libxml2.newDoc('1.0')
xmlroot = xmldoc.newChild(None, 'nagixsc', None)
xmlroot.setProp('version', '1.0')
- xmltimestamp = xmlroot.newChild(None, 'timestamp', datetime.datetime.now().strftime('%s'))
+ xmltimestamp = xmlroot.newChild(None, 'timestamp', str(long(time.time())))
for entry in db:
check = entry[1]
diff --git a/nagixsc_read_xml.py b/nagixsc_read_xml.py
index 53bbf9b85ab4bcea416fd240e7d9bc9bff9ea28e..81470ef10d64bc69869d11051231ff080f7cee6d 100755 (executable)
--- a/nagixsc_read_xml.py
+++ b/nagixsc_read_xml.py
#!/usr/bin/python
#import base64
-import datetime
import libxml2
import optparse
import sys
+import time
parser = optparse.OptionParser()
##############################################################################
-now = int(datetime.datetime.now().strftime('%s'))
+now = int(time.time())
# Get URL or file
doc = read_xml(options)
diff --git a/nagixsc_xml2cfg.py b/nagixsc_xml2cfg.py
index 9cbd179cd93a4507512b58abf31362221fc73efb..fd79639aa222d7d92a4be6bdba5074dfb62834ef 100755 (executable)
--- a/nagixsc_xml2cfg.py
+++ b/nagixsc_xml2cfg.py
#!/usr/bin/python
#import base64
-import datetime
import libxml2
import optparse
import socket
diff --git a/nagixsc_xml2nagios.py b/nagixsc_xml2nagios.py
index 3aee034cfbac0ade5d5ea0a499a4791d9afb2886..e05f6134fa8312ef3cbe08ee8e17124aec49686e 100755 (executable)
--- a/nagixsc_xml2nagios.py
+++ b/nagixsc_xml2nagios.py
#!/usr/bin/python
#import base64
-import datetime
import libxml2
import optparse
import os
import sys
+import time
NAGIOSCMDs = [ '/usr/local/nagios/var/rw/nagios.cmd', '/var/lib/nagios3/rw/nagios.cmd', ]
CHECKRESULTDIRs = [ '/usr/local/nagios/var/spool/checkresults', '/var/lib/nagios3/spool/checkresults', ]
doc = read_xml(options)
# Now timestamp AFTER getting the XML file
-now = int(datetime.datetime.now().strftime('%s'))
+now = long(time.time())
# Check XML against DTD