[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Gerhard Lausser
gerhard.lausser at consol.de
Tue Feb 28 22:15:18 UTC 2012
The following commit has been merged in the debian/master branch:
commit f02af0d5448ec17faf9e2a4301f4960e1ba41aff
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date: Sat Jan 21 17:19:56 2012 +0100
Fix some minor bugs in livestatus
Make test_livestatus_mongodb exit gracefully if no pymongo is installed
Some cleanup of unnecessary code
diff --git a/shinken/modules/livestatus_broker/livestatus_broker.py b/shinken/modules/livestatus_broker/livestatus_broker.py
index ced05d0..ec7a514 100644
--- a/shinken/modules/livestatus_broker/livestatus_broker.py
+++ b/shinken/modules/livestatus_broker/livestatus_broker.py
@@ -42,6 +42,7 @@ from shinken.basemodule import BaseModule
from shinken.message import Message
from shinken.log import logger
from shinken.modulesmanager import ModulesManager
+from shinken.objects.module import Module
from shinken.daemon import Daemon
from shinken.misc.datamanager import datamgr
#Local import
@@ -77,16 +78,22 @@ class LiveStatus_broker(BaseModule, Daemon):
'module_name': 'LogStore',
'module_type': 'logstore_sqlite',
'use_aggressive_sql': "0",
- 'database_file': getattr(modconf, 'database_file', os.path.join(os.path.abspath('.'), 'var', 'livestatus.db')),
- 'archive_path': getattr(modconf, 'archive_path', os.path.join(os.path.dirname(self.database_file), 'archives')),
- 'max_logs_age': getattr(modconf, 'max_logs_age', '365'),
+ 'database_file': getattr(modconf, 'database_file', None),
+ 'archive_path': getattr(modconf, 'archive_path', None),
+ 'max_logs_age': getattr(modconf, 'max_logs_age', None),
}
- def add_compatibility_sqlite_module(self)
+ def add_compatibility_sqlite_module(self):
if len([m for m in self.modules_manager.instances if m.module_type.startswith('logstore_')]) == 0:
# this shinken-specific.cfg does not use the new submodules
- dbmodconf = Module(self.compat_sqlite)
- self.modules.append(dbmodconf)
+ for k in self.compat_sqlite.keys():
+ if self.compat_sqlite[k] == None:
+ del self.compat_sqlite[k]
+ dbmod = Module(self.compat_sqlite)
+ self.modules_manager.set_modules([dbmod])
+ self.modules_manager.load_and_init()
+
+
diff --git a/shinken/modules/livestatus_broker/mapping.py b/shinken/modules/livestatus_broker/mapping.py
index c05ab6b..6fb5646 100644
--- a/shinken/modules/livestatus_broker/mapping.py
+++ b/shinken/modules/livestatus_broker/mapping.py
@@ -46,231 +46,6 @@ from shinken.pollerlink import PollerLink
from log_line import LOGCLASS_INFO, LOGCLASS_ALERT, LOGCLASS_PROGRAM, LOGCLASS_NOTIFICATION, LOGCLASS_PASSIVECHECK, LOGCLASS_COMMAND, LOGCLASS_STATE, LOGCLASS_INVALID, LOGCLASS_ALL, LOGOBJECT_INFO, LOGOBJECT_HOST, LOGOBJECT_SERVICE, LOGOBJECT_CONTACT, Logline, LoglineWrongFormat
-xLOGCLASS_INFO = 0 # all messages not in any other class
-xLOGCLASS_ALERT = 1 # alerts: the change service/host state
-xLOGCLASS_PROGRAM = 2 # important programm events (restart, ...)
-xLOGCLASS_NOTIFICATION = 3 # host/service notifications
-xLOGCLASS_PASSIVECHECK = 4 # passive checks
-xLOGCLASS_COMMAND = 5 # external commands
-xLOGCLASS_STATE = 6 # initial or current states
-xLOGCLASS_INVALID = -1 # never stored
-xLOGCLASS_ALL = 0xffff
-xLOGOBJECT_INFO = 0
-xLOGOBJECT_HOST = 1
-xLOGOBJECT_SERVICE = 2
-xLOGOBJECT_CONTACT = 3
-
-class xLoglineWrongFormat(Exception):
- pass
-
-
-class xLogline(dict):
- """A class which represents a line from the logfile
- Public functions:
- fill -- Attach host and/or service objects to a Logline object
-
- """
-
- id = 0
- columns = ['logobject', 'attempt', 'logclass', 'command_name', 'comment', 'contact_name', 'host_name', 'lineno', 'message', 'options', 'plugin_output', 'service_description', 'state', 'state_type', 'time', 'type']
-
- def __init__(self, sqlite_cursor=None, sqlite_row=None, line=None, srcdict=None):
- if srcdict != None:
- for col in Logline.columns:
- print "set ", col, srcdict[col]
- setattr(self, col, srcdict[col])
- elif sqlite_cursor != None and sqlite_row != None:
- for idx, col in enumerate(sqlite_cursor):
- if col[0] == 'class':
- setattr(self, 'logclass', sqlite_row[idx])
- else:
- setattr(self, col[0], sqlite_row[idx])
- elif line != None:
- line = line.encode('UTF-8').rstrip()
- # [1278280765] SERVICE ALERT: test_host_0
- if line[0] != '[' and line[11] != ']':
- print "INVALID line", line
- raise LoglineWrongFormat
- else:
- service_states = {
- 'OK': 0,
- 'WARNING': 1,
- 'CRITICAL': 2,
- 'UNKNOWN': 3,
- 'RECOVERY': 0
- }
- host_states = {
- 'UP' :0,
- 'DOWN': 1,
- 'UNREACHABLE': 2,
- 'UNKNOWN': 3,
- 'RECOVERY': 0
- }
-
- # type is 0:info, 1:state, 2:program, 3:notification, 4:passive, 5:command
- logobject = LOGOBJECT_INFO
- logclass = LOGCLASS_INVALID
- attempt, state = [0] * 2
- command_name, comment, contact_name, host_name, message, options, plugin_output, service_description, state_type = [''] * 9
- time= line[1:11]
- first_type_pos = line.find(' ') + 1
- last_type_pos = line.find(':')
- first_detail_pos = last_type_pos + 2
- type = line[first_type_pos:last_type_pos]
- options = line[first_detail_pos:]
- message = line
- if type == 'CURRENT SERVICE STATE':
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_STATE
- host_name, service_description, state, state_type, attempt, plugin_output = options.split(';', 5)
- elif type == 'INITIAL SERVICE STATE':
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_STATE
- host_name, service_description, state, state_type, attempt, plugin_output = options.split(';', 5)
- elif type == 'SERVICE ALERT':
- # SERVICE ALERT: srv-40;Service-9;CRITICAL;HARD;1;[Errno 2] No such file or directory
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_ALERT
- host_name, service_description, state, state_type, attempt, plugin_output = options.split(';', 5)
- state = service_states[state]
- elif type == 'SERVICE DOWNTIME ALERT':
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_ALERT
- host_name, service_description, state_type, comment = options.split(';', 3)
- elif type == 'SERVICE FLAPPING ALERT':
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_ALERT
- host_name, service_description, state_type, comment = options.split(';', 3)
-
- elif type == 'CURRENT HOST STATE':
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_STATE
- host_name, state, state_type, attempt, plugin_output = options.split(';', 4)
- elif type == 'INITIAL HOST STATE':
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_STATE
- host_name, state, state_type, attempt, plugin_output = options.split(';', 4)
- elif type == 'HOST ALERT':
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_ALERT
- host_name, state, state_type, attempt, plugin_output = options.split(';', 4)
- state = host_states[state]
- elif type == 'HOST DOWNTIME ALERT':
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_ALERT
- host_name, state_type, comment = options.split(';', 2)
- elif type == 'HOST FLAPPING ALERT':
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_ALERT
- host_name, state_type, comment = options.split(';', 2)
-
- elif type == 'SERVICE NOTIFICATION':
- # tust_cuntuct;test_host_0;test_ok_0;CRITICAL;notify-service;i am CRITICAL <-- normal
- # SERVICE NOTIFICATION: test_contact;test_host_0;test_ok_0;DOWNTIMESTART (OK);notify-service;OK
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_NOTIFICATION
- contact_name, host_name, service_description, state_type, command_name, check_plugin_output = options.split(';', 5)
- if '(' in state_type: # downtime/flapping/etc-notifications take the type UNKNOWN
- state_type = 'UNKNOWN'
- state = service_states[state_type]
- elif type == 'HOST NOTIFICATION':
- # tust_cuntuct;test_host_0;DOWN;notify-host;i am DOWN
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_NOTIFICATION
- contact_name, host_name, state_type, command_name, check_plugin_output = options.split(';', 4)
- if '(' in state_type:
- state_type = 'UNKNOWN'
- state = host_states[state_type]
-
- elif type == 'PASSIVE SERVICE CHECK':
- logobject = LOGOBJECT_SERVICE
- logclass = LOGCLASS_PASSIVECHECK
- host_name, service_description, state, check_plugin_output = options.split(';', 3)
- elif type == 'PASSIVE HOST CHECK':
- logobject = LOGOBJECT_HOST
- logclass = LOGCLASS_PASSIVECHECK
- host_name, state, check_plugin_output = options.split(';', 2)
- elif type == 'SERVICE EVENT HANDLER':
- # SERVICE EVENT HANDLER: test_host_0;test_ok_0;CRITICAL;SOFT;1;eventhandler
- logobject = LOGOBJECT_SERVICE
- host_name, service_description, state, state_type, attempt, command_name = options.split(';', 5)
- state = service_states[state]
-
- elif type == 'HOST EVENT HANDLER':
- logobject = LOGOBJECT_HOST
- host_name, state, state_type, attempt, command_name = options.split(';', 4)
- state = host_states[state]
-
- elif type == 'EXTERNAL COMMAND':
- logobject = LOGOBJECT_INFO
- logclass = LOGCLASS_COMMAND
- elif type.startswith('starting...') or \
- type.startswith('shutting down...') or \
- type.startswith('Bailing out') or \
- type.startswith('active mode...') or \
- type.startswith('standby mode...'):
- logobject = LOGOBJECT_INFO
- logclass = LOGCLASS_PROGRAM
- else:
- pass
- #print "does not match"
-
- Logline.id += 1
- self.lineno = Logline.id
- setattr(self, 'logobject', int(logobject))
- setattr(self, 'attempt', int(attempt))
- setattr(self, 'logclass', int(logclass))
- setattr(self, 'command_name', command_name)
- setattr(self, 'comment', comment)
- setattr(self, 'contact_name', contact_name)
- setattr(self, 'host_name', host_name)
- setattr(self, 'message', message)
- setattr(self, 'options', options)
- setattr(self, 'plugin_output', plugin_output)
- setattr(self, 'service_description', service_description)
- setattr(self, 'state', state)
- setattr(self, 'state_type', state_type)
- setattr(self, 'time', int(time))
- setattr(self, 'type', type)
-
-
- def as_tuple(self):
- return tuple([str(getattr(self, col)) for col in Logline.columns])
-
- def as_dict(self):
- return dict(zip(Logline.columns, [getattr(self, col) for col in Logline.columns]))
-
- def __str__(self):
- return "line: %s" % self.message
-
- def fill(self, datamgr):
- """Attach host and/or service objects to a Logline object
-
- Lines describing host or service events only contain host_name
- and/or service_description. This method finds the corresponding
- objects and adds them to the line as attributes log_host
- and/or log_service
-
- """
- if self.logobject == LOGOBJECT_HOST:
- try:
- setattr(self, 'log_host', datamgr.get_host(self.host_name))
- except Exception, e:
- print "du scheiss host", e
- pass
- elif self.logobject == LOGOBJECT_SERVICE:
- try:
- setattr(self, 'log_host', datamgr.get_host(self.host_name))
- setattr(self, 'log_service', datamgr.get_service(self.host_name, self.service_description))
- except Exception, e:
- print "du scheiss svc", e
- pass
- else:
- setattr(self, 'log_host', None)
- setattr(self, 'log_service', None)
- return self
-
-
class Problem:
def __init__(self, source, impacts):
self.source = source
diff --git a/shinken/util.py b/shinken/util.py
index 471772f..106d01a 100644
--- a/shinken/util.py
+++ b/shinken/util.py
@@ -224,6 +224,13 @@ def get_obj_name_two_args_and_void(obj, value):
except AttributeError:
return ''
+# Get the full name if there is one
+def get_obj_full_name(obj):
+ try:
+ return obj.get_full_name()
+ except Exception:
+ return obj.get_name()
+
# return the list of keys of the custom dict
# but without the _ before
def get_customs_keys(d):
diff --git a/test/shinken_test.py b/test/shinken_test.py
index d58e5f3..58b8a78 100755
--- a/test/shinken_test.py
+++ b/test/shinken_test.py
@@ -52,8 +52,7 @@ from shinken.modules import livestatus_broker
from shinken.modules.livestatus_broker import LiveStatus_broker
from shinken.modules.livestatus_broker.livestatus import LiveStatus
from shinken.modules.livestatus_broker.livestatus_regenerator import LiveStatusRegenerator
-from shinken.modules.livestatus_broker.datamanager import datamgr
-from shinken.modules.livestatus_broker.helper import helper
+from shinken.misc.datamanager import datamgr
livestatus_modconf = Module()
livestatus_modconf.module_name = "livestatus"
@@ -405,7 +404,6 @@ class ShinkenTest(unittest.TestCase):
self.livestatus_broker.rg = LiveStatusRegenerator()
self.livestatus_broker.datamgr = datamgr
datamgr.load(self.livestatus_broker.rg)
- self.livestatus_broker.helper = helper
#--- livestatus_broker.main
self.livestatus_broker.init()
diff --git a/test/test_livestatus_db.py b/test/test_livestatus_db.py
index 91e550e..6a10e59 100755
--- a/test/test_livestatus_db.py
+++ b/test/test_livestatus_db.py
@@ -480,8 +480,8 @@ Columns: time type options state host_name"""
print "archive is", archives_path
-
class TestConfigBig(TestConfig):
+
def setUp(self):
start_setUp = time.time()
self.setup_with_file('etc/nagios_5r_100h_2000s.cfg')
@@ -497,62 +497,6 @@ class TestConfigBig(TestConfig):
host = self.sched.hosts.find_by_name("test_host_000")
host.__class__.use_aggressive_host_checking = 1
-
- def init_livestatus(self):
- self.livelogs = 'tmp/livelogs.db' + "wrumm"
- modconf = Module({'module_name' : 'LiveStatus',
- 'module_type' : 'livestatus',
- 'port' : str(50000 + os.getpid()),
- 'pnp_path' : 'tmp/livestatus_broker.pnp_path_test' + self.testid,
- 'host' : '127.0.0.1',
- 'socket' : 'live',
- 'name' : 'test', #?
- })
-
- dbmodconf = Module({'module_name' : 'LogStore',
- 'module_type' : 'logstore_sqlite',
- 'use_aggressive_sql' : "0",
- 'database_file' : self.livelogs,
- 'archive_path' : os.path.join(os.path.dirname(self.livelogs), 'archives'),
- })
- modconf.modules = [dbmodconf]
- self.livestatus_broker = LiveStatus_broker(modconf)
- self.livestatus_broker.create_queues()
-
- #--- livestatus_broker.main
- self.livestatus_broker.log = logger
- # this seems to damage the logger so that the scheduler can't use it
- #self.livestatus_broker.log.load_obj(self.livestatus_broker)
- self.livestatus_broker.debug_output = []
- self.livestatus_broker.modules_manager = ModulesManager('livestatus', self.livestatus_broker.find_modules_path(), [])
- self.livestatus_broker.modules_manager.set_modules(self.livestatus_broker.modules)
- # We can now output some previouly silented debug ouput
- self.livestatus_broker.do_load_modules()
- for inst in self.livestatus_broker.modules_manager.instances:
- if inst.properties["type"].startswith('logstore'):
- f = getattr(inst, 'load', None)
- if f and callable(f):
- f(self.livestatus_broker) #!!! NOT self here !!!!
- break
- for s in self.livestatus_broker.debug_output:
- print "errors during load", s
- del self.livestatus_broker.debug_output
- self.livestatus_broker.rg = LiveStatusRegenerator()
- self.livestatus_broker.datamgr = datamgr
- datamgr.load(self.livestatus_broker.rg)
- self.livestatus_broker.helper = helper
- #--- livestatus_broker.main
-
- self.livestatus_broker.init()
- self.livestatus_broker.db = self.livestatus_broker.modules_manager.instances[0]
- self.livestatus_broker.livestatus = LiveStatus(self.livestatus_broker.datamgr, self.livestatus_broker.db, self.livestatus_broker.pnp_path, self.livestatus_broker.from_q)
-
- #--- livestatus_broker.do_main
- self.livestatus_broker.db.open()
- #--- livestatus_broker.do_main
-
-
-
def test_a_long_history(self):
#return
test_host_005 = self.sched.hosts.find_by_name("test_host_005")
@@ -718,6 +662,98 @@ OutputFormat: json"""
self.livestatus_broker = None
+class TestConfigNoLogstore(TestConfig):
+
+ def setUp(self):
+ start_setUp = time.time()
+ self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
+ Comment.id = 1
+ self.testid = str(os.getpid() + random.randint(1, 1000))
+ self.init_livestatus()
+ print "Cleaning old broks?"
+ self.sched.fill_initial_broks()
+ self.update_broker()
+ print "************* Overall Setup:", time.time() - start_setUp
+ # add use_aggressive_host_checking so we can mix exit codes 1 and 2
+ # but still get DOWN state
+ host = self.sched.hosts.find_by_name("test_host_0")
+ host.__class__.use_aggressive_host_checking = 1
+
+ def tearDown(self):
+ self.livestatus_broker.db.commit()
+ self.livestatus_broker.db.close()
+ if os.path.exists(self.livelogs):
+ os.remove(self.livelogs)
+ if os.path.exists(self.livelogs+"-journal"):
+ os.remove(self.livelogs+"-journal")
+ if os.path.exists(self.livestatus_broker.pnp_path):
+ shutil.rmtree(self.livestatus_broker.pnp_path)
+ if os.path.exists('var/nagios.log'):
+ os.remove('var/nagios.log')
+ if os.path.exists('var/retention.dat'):
+ os.remove('var/retention.dat')
+ if os.path.exists('var/status.dat'):
+ os.remove('var/status.dat')
+ self.livestatus_broker = None
+
+ def init_livestatus(self):
+ self.livelogs = 'tmp/livelogs.db' + self.testid
+ modconf = Module({'module_name' : 'LiveStatus',
+ 'module_type' : 'livestatus',
+ 'port' : str(50000 + os.getpid()),
+ 'pnp_path' : 'tmp/pnp4nagios_test' + self.testid,
+ 'host' : '127.0.0.1',
+ 'socket' : 'live',
+ 'name' : 'test', #?
+ })
+
+ dbmodconf = Module({'module_name' : 'LogStore',
+ 'module_type' : 'logstore_sqlite',
+ 'use_aggressive_sql' : "0",
+ 'database_file' : self.livelogs,
+ 'archive_path' : os.path.join(os.path.dirname(self.livelogs), 'archives'),
+ })
+ ####################################
+ # !NOT! modconf.modules = [dbmodconf]
+ ####################################
+ self.livestatus_broker = LiveStatus_broker(modconf)
+ self.livestatus_broker.create_queues()
+
+ #--- livestatus_broker.main
+ self.livestatus_broker.log = logger
+ # this seems to damage the logger so that the scheduler can't use it
+ #self.livestatus_broker.log.load_obj(self.livestatus_broker)
+ self.livestatus_broker.debug_output = []
+ self.livestatus_broker.modules_manager = ModulesManager('livestatus', self.livestatus_broker.find_modules_path(), [])
+ self.livestatus_broker.modules_manager.set_modules(self.livestatus_broker.modules)
+ # We can now output some previouly silented debug ouput
+ self.livestatus_broker.do_load_modules()
+ for inst in self.livestatus_broker.modules_manager.instances:
+ if inst.properties["type"].startswith('logstore'):
+ f = getattr(inst, 'load', None)
+ if f and callable(f):
+ f(self.livestatus_broker) #!!! NOT self here !!!!
+ break
+ for s in self.livestatus_broker.debug_output:
+ print "errors during load", s
+ del self.livestatus_broker.debug_output
+ self.livestatus_broker.add_compatibility_sqlite_module()
+ self.livestatus_broker.rg = LiveStatusRegenerator()
+ self.livestatus_broker.datamgr = datamgr
+ datamgr.load(self.livestatus_broker.rg)
+ #--- livestatus_broker.main
+
+ self.livestatus_broker.init()
+ self.livestatus_broker.db = self.livestatus_broker.modules_manager.instances[0]
+ self.livestatus_broker.livestatus = LiveStatus(self.livestatus_broker.datamgr, self.livestatus_broker.db, self.livestatus_broker.pnp_path, self.livestatus_broker.from_q)
+
+ #--- livestatus_broker.do_main
+ self.livestatus_broker.db.open()
+ #--- livestatus_broker.do_main
+
+ def test_has_implicit_module(self):
+ self.assert_(self.livestatus_broker.modules_manager.instances[0].__class__.__name__ == 'LiveStatusLogStoreSqlite')
+
if __name__ == '__main__':
#import cProfile
diff --git a/test/test_livestatus_mongodb.py b/test/test_livestatus_mongodb.py
index b158736..0ec2400 100755
--- a/test/test_livestatus_mongodb.py
+++ b/test/test_livestatus_mongodb.py
@@ -34,6 +34,7 @@ import shutil
import time
import random
import copy
+import unittest
from shinken.brok import Brok
from shinken.objects.timeperiod import Timeperiod
@@ -43,12 +44,21 @@ from shinken.modules.livestatus_broker.mapping import Logline
from shinken.modules.logstore_sqlite import LiveStatusLogStoreSqlite
from shinken.comment import Comment
+try:
+ import pymongo
+ has_pymongo = True
+except Exception:
+ has_pymongo = False
+
+
sys.setcheckinterval(10000)
class TestConfig(ShinkenTest):
def tearDown(self):
+ if not has_pymongo:
+ return
self.shutdown_livestatus()
if os.path.exists(self.livelogs):
os.remove(self.livelogs)
@@ -80,8 +90,7 @@ class TestConfig(ShinkenTest):
dbmodconf = Module({'module_name' : 'LogStore',
'module_type': 'logstore_mongodb',
- #'mongodb_uri': "mongodb://127.0.0.1:27017",
- 'mongodb_uri': "mongodb://10.0.12.51:27017",
+ 'mongodb_uri': "mongodb://127.0.0.1:27017",
'database': 'testtest'+self.testid,
})
modconf.modules = [dbmodconf]
@@ -109,10 +118,11 @@ class TestConfig(ShinkenTest):
self.livestatus_broker.rg = LiveStatusRegenerator()
self.livestatus_broker.datamgr = datamgr
datamgr.load(self.livestatus_broker.rg)
- self.livestatus_broker.helper = helper
#--- livestatus_broker.main
self.livestatus_broker.init()
+ for i in self.livestatus_broker.modules_manager.instances:
+ print "instance", i
self.livestatus_broker.db = self.livestatus_broker.modules_manager.instances[0]
self.livestatus_broker.livestatus = LiveStatus(self.livestatus_broker.datamgr, self.livestatus_broker.db, self.livestatus_broker.pnp_path, self.livestatus_broker.from_q)
@@ -152,6 +162,8 @@ class TestConfig(ShinkenTest):
class TestConfigSmall(TestConfig):
def setUp(self):
+ if not has_pymongo:
+ return
self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
Comment.id = 1
self.testid = str(os.getpid() + random.randint(1, 1000))
@@ -184,6 +196,8 @@ class TestConfigSmall(TestConfig):
def test_hostsbygroup(self):
+ if not has_pymongo:
+ return
self.print_header()
now = time.time()
objlist = []
@@ -210,6 +224,8 @@ ResponseHeader: fixed16
print response
def test_one_log(self):
+ if not has_pymongo:
+ return
self.print_header()
host = self.sched.hosts.find_by_name("test_host_0")
now = time.time()
@@ -246,6 +262,8 @@ Columns: time type options state host_name"""
class TestConfigBig(TestConfig):
def setUp(self):
+ if not has_pymongo:
+ return
start_setUp = time.time()
self.setup_with_file('etc/nagios_5r_100h_2000s.cfg')
Comment.id = 1
@@ -261,7 +279,7 @@ class TestConfigBig(TestConfig):
host.__class__.use_aggressive_host_checking = 1
- def init_livestatus(self):
+ def xinit_livestatus(self):
self.livelogs = 'tmp/livelogs.db' + "wrumm"
modconf = Module({'module_name' : 'LiveStatus',
'module_type' : 'livestatus',
@@ -274,8 +292,7 @@ class TestConfigBig(TestConfig):
dbmodconf = Module({'module_name' : 'LogStore',
'module_type' : 'logstore_mongodb',
- 'mongodb_uri' : "mongodb://10.0.12.51:27017",
- #'mongodb_uri' : "mongodb://127.0.0.1:27017",
+ 'mongodb_uri' : "mongodb://127.0.0.1:27017",
})
modconf.modules = [dbmodconf]
self.livestatus_broker = LiveStatus_broker(modconf)
@@ -302,7 +319,6 @@ class TestConfigBig(TestConfig):
self.livestatus_broker.rg = LiveStatusRegenerator()
self.livestatus_broker.datamgr = datamgr
datamgr.load(self.livestatus_broker.rg)
- self.livestatus_broker.helper = helper
#--- livestatus_broker.main
self.livestatus_broker.init()
@@ -318,7 +334,8 @@ class TestConfigBig(TestConfig):
def test_a_long_history(self):
- #return
+ if not has_pymongo:
+ return
test_host_005 = self.sched.hosts.find_by_name("test_host_005")
test_host_099 = self.sched.hosts.find_by_name("test_host_099")
test_ok_00 = self.sched.services.find_srv_by_name_and_hostname("test_host_005", "test_ok_00")
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list