本文整理汇总了Python中shinken.objects.module.Module类的典型用法代码示例。如果您正苦于以下问题:Python Module类的具体用法?Python Module怎么用?Python Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Module类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: init_livestatus
def init_livestatus(self, modconf=None, dbmodconf=None, needcache=False):
self.livelogs = 'tmp/livelogs.db' + self.testid
if modconf is None:
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', #?
})
if dbmodconf is None:
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', modules_dir, [])
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.query_cache = LiveStatusQueryCache()
if not needcache:
self.livestatus_broker.query_cache.disable()
self.livestatus_broker.rg.register_cache(self.livestatus_broker.query_cache)
#--- 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.query_cache, self.livestatus_broker.db, self.livestatus_broker.pnp_path, self.livestatus_broker.from_q)
#--- livestatus_broker.do_main
self.livestatus_broker.db.open()
if hasattr(self.livestatus_broker.db, 'prepare_log_db_table'):
self.livestatus_broker.db.prepare_log_db_table()
开发者ID:HubLot,项目名称:shinken,代码行数:60,代码来源:shinken_modules.py
示例2: init_livestatus
def init_livestatus(self):
self.livelogs = "bigbigbig"
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_mongodb',
'database': 'bigbigbig',
'mongodb_uri': "mongodb://127.0.0.1:27017",
#'mongodb_uri': "mongodb://10.0.12.50:27017,10.0.12.51:27017",
# 'replica_set': 'livestatus',
'max_logs_age': '7',
})
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.query_cache = LiveStatusQueryCache()
self.livestatus_broker.query_cache.disable()
self.livestatus_broker.rg.register_cache(self.livestatus_broker.query_cache)
#--- 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.query_cache, self.livestatus_broker.db, self.livestatus_broker.pnp_path, self.livestatus_broker.from_q)
#--- livestatus_broker.do_main
self.livestatus_broker.db.open()
开发者ID:6jo6jo,项目名称:shinken,代码行数:55,代码来源:test_livestatus_mongodb.py
示例3: Module
#
# This file is used to test reading and processing of config files
#
import os
import time
from shinken_test import unittest, ShinkenTest
from shinken.log import logger
from shinken.objects.module import Module
from shinken.modules import pickle_retention_file_scheduler
from shinken.modules.pickle_retention_file_scheduler import get_instance
modconf = Module()
modconf.module_name = "PickleRetention"
modconf.module_type = pickle_retention_file_scheduler.properties['type']
modconf.modules = []
modconf.properties = pickle_retention_file_scheduler.properties.copy()
class TestConfig(ShinkenTest):
#setUp is in shinken_test
#Change ME :)
def test_pickle_retention(self):
print self.conf.modules
now = time.time()
#get our modules
mod = pickle_retention_file_scheduler.Pickle_retention_scheduler(modconf, 'tmp/retention-test.dat')
开发者ID:Morkxy,项目名称:shinken,代码行数:31,代码来源:test_module_pickle_retention.py
示例4: Module
modulesctx.set_modulesdir(modules_dir)
# Special Livestatus module opening since the module rename
#from shinken.modules.livestatus import module as livestatus_broker
livestatus_broker = modulesctx.get_module('livestatus')
LiveStatus_broker = livestatus_broker.LiveStatus_broker
LiveStatus = livestatus_broker.LiveStatus
LiveStatusRegenerator = livestatus_broker.LiveStatusRegenerator
LiveStatusQueryCache = livestatus_broker.LiveStatusQueryCache
Logline = livestatus_broker.Logline
LiveStatusLogStoreMongoDB = modulesctx.get_module('logstore-mongodb').LiveStatusLogStoreMongoDB
LiveStatusLogStoreSqlite = modulesctx.get_module('logstore-sqlite').LiveStatusLogStoreSqlite
livestatus_modconf = Module()
livestatus_modconf.module_name = "livestatus"
livestatus_modconf.module_type = livestatus_broker.properties['type']
livestatus_modconf.properties = livestatus_broker.properties.copy()
class ShinkenModulesTest(ShinkenTest):
def do_load_modules(self):
self.modules_manager.load_and_init()
self.log.log("I correctly loaded the modules: [%s]" % (','.join([inst.get_name() for inst in self.modules_manager.instances])))
def update_broker(self, dodeepcopy=False):
开发者ID:HubLot,项目名称:shinken,代码行数:31,代码来源:shinken_modules.py
示例5: Module
Test pickle retention arbiter.
"""
import os
import copy
from shinken_test import unittest, ShinkenTest
from shinken.daemons.arbiterdaemon import Arbiter
from shinken.objects.module import Module
from shinken.modulesctx import modulesctx
pickle_retention_file_generic = modulesctx.get_module('pickle_retention_file_generic')
get_instance = pickle_retention_file_generic.get_instance
modconf = Module()
modconf.module_name = "PickleRetentionGeneric"
modconf.module_type = pickle_retention_file_generic.properties['type']
modconf.properties = pickle_retention_file_generic.properties.copy()
class TestPickleRetentionArbiter(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_pickle_retention(self):
# get our modules
mod = pickle_retention_file_generic.Pickle_retention_generic(
modconf, 'tmp/retention-test.dat')
try:
os.unlink(mod.path)
except:
开发者ID:David-,项目名称:shinken,代码行数:31,代码来源:test_module_pickle_retention_arbiter.py
示例6: Module
Test the named pipe arbiter module.
"""
import os, time, platform
from shinken_test import unittest, ShinkenTest
from shinken.objects.module import Module
from shinken.modulesctx import modulesctx
named_pipe = modulesctx.get_module('named_pipe')
Named_Pipe_arbiter = named_pipe.Named_Pipe_arbiter
get_instance = named_pipe.get_instance
modconf = Module()
modconf.module_name = "NamedPipe"
modconf.module_type = named_pipe.properties['type']
modconf.properties = named_pipe.properties.copy()
class TestModuleNamedPipe(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_read_named_pipe(self):
# Ok, windows do not have named pipe, we know...
# cygwin cannot write from two sides at the same time
if os.name == 'nt' or platform.system().startswith('CYGWIN'):
return
开发者ID:David-,项目名称:shinken,代码行数:30,代码来源:test_module_named_pipe_arbiter.py
示例7: Module
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
"""
Test Mongodb retention.
"""
from shinken_test import unittest, ShinkenTest
from shinken.objects.module import Module
from shinken.modules.retention_mongodb import module as mongodb_retention
from shinken.modules.retention_mongodb.module import get_instance
modconf = Module()
modconf.module_name = "MongodbRetention"
modconf.uri = "mongodb://127.0.0.1:27017"
modconf.database = "test"
modconf.module_type = mongodb_retention.properties["type"]
modconf.properties = mongodb_retention.properties.copy()
class TestMongodbRetention(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_mongodb_retention(self):
# get our modules
sl = mongodb_retention.Mongodb_retention_scheduler(modconf, "localhost", "test", "")
# sl = get_instance(mod)
开发者ID:Thibautg16,项目名称:shinken,代码行数:31,代码来源:test_module_mongodb_retention.py
示例8: Module
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
"""
Test Nagios retention
"""
from shinken_test import unittest, ShinkenTest
from shinken.objects.module import Module
from shinken.modulesctx import modulesctx
nagios_retention_file_scheduler = modulesctx.get_module('retention_nagios')
get_instance = nagios_retention_file_scheduler.get_instance
modconf = Module()
modconf.module_name = "NagiosRetention"
modconf.module_type = nagios_retention_file_scheduler.properties['type']
modconf.properties = nagios_retention_file_scheduler.properties.copy()
class TestNagiosRetention(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_pickle_retention(self):
# get our modules
mod = nagios_retention_file_scheduler.Nagios_retention_scheduler(
modconf, 'etc/module_nagios_retention/retention.dat')
sl = get_instance(mod)
# Hack here :(
开发者ID:David-,项目名称:shinken,代码行数:31,代码来源:test_module_nagios_retention.py
示例9: Module
#
# This file is used to test reading and processing of config files
#
import os
from shinken_test import unittest, ShinkenTest
from shinken.log import logger
from shinken.objects.module import Module
from shinken.modules import redis_retention_scheduler
from shinken.modules.redis_retention_scheduler import get_instance
modconf = Module()
modconf.module_name = "RedisRetention"
modconf.module_type = redis_retention_scheduler.properties['type']
modconf.properties = redis_retention_scheduler.properties.copy()
class TestConfig(ShinkenTest):
#setUp is in shinken_test
#Change ME :)
def test_redis_retention(self):
print self.conf.modules
#get our modules
mod = redis_retention_scheduler.Redis_retention_scheduler(modconf, 'localhost')
sl = get_instance(mod)
开发者ID:Dabg,项目名称:shinken,代码行数:30,代码来源:test_module_redis_retention.py
示例10: Module
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
"""
Test Mongodb retention.
"""
from shinken_test import unittest, ShinkenTest
from shinken.objects.module import Module
from shinken.modulesctx import modulesctx
mongodb_retention = modulesctx.get_module('retention_mongodb')
get_instance = mongodb_retention.get_instance
modconf = Module()
modconf.module_name = "MongodbRetention"
modconf.uri = 'mongodb://127.0.0.1:27017'
modconf.database = 'test'
modconf.module_type = mongodb_retention.properties['type']
modconf.properties = mongodb_retention.properties.copy()
class TestMongodbRetention(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_mongodb_retention(self):
# get our modules
sl = mongodb_retention.Mongodb_retention_scheduler(modconf, 'localhost', 'test', '')
# sl = get_instance(mod)
开发者ID:David-,项目名称:shinken,代码行数:31,代码来源:test_module_mongodb_retention.py
示例11: Module
from shinken_test import unittest, ShinkenTest, original_time_time, original_time_sleep
# Need to use the real time-functions as we are reading timestamps
# from the filesystem.
time.time = original_time_time
time.sleep = original_time_sleep
from shinken.objects.module import Module
from shinken.modulesctx import modulesctx
hot_dependencies_arbiter = modulesctx.get_module('hot_dependencies')
Hot_dependencies_arbiter = hot_dependencies_arbiter.Hot_dependencies_arbiter
get_instance = hot_dependencies_arbiter.get_instance
modconf = Module()
modconf.module_name = "PickleRetention"
modconf.module_type = hot_dependencies_arbiter.properties['type']
modconf.modules = []
modconf.properties = hot_dependencies_arbiter.properties.copy()
try:
import json
except ImportError:
# For old Python version, load
# simple json (it can be hard json?! It's 2 functions guy!)
try:
import simplejson as json
except ImportError:
print "Error: you need the json or simplejson module for this script"
开发者ID:David-,项目名称:shinken,代码行数:30,代码来源:test_module_hot_dependencies_arbiter.py
示例12: SkipTest
SkipTest = None
if not sys.version_info > (2, 5):
if SkipTest:
raise SkipTest("bah, i am 2.4.x")
else:
raise SystemExit(0)
from shinken.objects.module import Module
from shinken.modules import passwd_ui
from shinken.modules.passwd_ui import get_instance
from shinken.log import logger
if sys.version_info > (2, 5):
modconf = Module()
modconf.module_name = "PasswdUI"
modconf.module_type = passwd_ui.properties['type']
modconf.properties = passwd_ui.properties.copy()
class TestPasswdUI(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_check_auth(self):
# get our modules
modconf.passwd = 'libexec/htpasswd.users'
mod = passwd_ui.get_instance(modconf)
sl = get_instance(mod)
# Hack here :(
开发者ID:Denetariko,项目名称:shinken,代码行数:31,代码来源:test_module_passwd_ui.py
示例13: Module
#
# This file is used to test reading and processing of config files
#
import os
from shinken_test import unittest, ShinkenTest
from shinken.log import logger
from shinken.objects.module import Module
from shinken.modules import memcache_retention_scheduler
from shinken.modules.memcache_retention_scheduler import get_instance
modconf = Module()
modconf.module_name = "MemcacheRetention"
modconf.module_type = memcache_retention_scheduler.properties['type']
modconf.properties = memcache_retention_scheduler.properties.copy()
class TestConfig(ShinkenTest):
# setUp is inherited from ShinkenTest
def test_memcache_retention(self):
print self.conf.modules
# get our modules
modconf.server = 'localhost'
modconf.port = '11211'
mod = memcache_retention_scheduler.Memcache_retention_scheduler(modconf)
开发者ID:BaniaHP,项目名称:shinken,代码行数:28,代码来源:test_module_memcache_retention.py
示例14: Module
#
# This file is used to test reading and processing of config files
#
import os
from Queue import Empty
from multiprocessing import Queue, Manager, active_children
from shinken_test import *
from shinken.log import logger
from shinken.objects.module import Module
from shinken.modules.booster_nrpe import module as nrpe_poller
from shinken.modules.booster_nrpe.module import get_instance
from shinken.message import Message
modconf = Module()
modconf.module_name = "NrpePoller"
modconf.module_type = nrpe_poller.properties['type']
modconf.properties = nrpe_poller.properties.copy()
class TestNrpePoller(ShinkenTest):
# Uncomment this is you want to use a specific configuration
# for your test
#def setUp(self):
# self.setup_with_file('etc/nagios_module_hack_cmd_poller_tag.cfg')
def test_nrpe_poller(self):
if os.name == 'nt':
return
开发者ID:Thibautg16,项目名称:shinken,代码行数:30,代码来源:test_modules_nrpe_poller.py
示例15: Module
#
import os, sys, string, time
from multiprocessing import Queue
from shinken_test import unittest, ShinkenTest
from shinken.objects.module import Module
from shinken.modulesctx import modulesctx
npcdmod_broker = modulesctx.get_module('npcdmod')
Npcd_broker = npcdmod_broker.Npcd_broker
sys.setcheckinterval(10000)
modconf = Module()
modconf.module_name = "ncpd"
modconf.module_type = npcdmod_broker.properties['type']
modconf.modules = []
modconf.properties = npcdmod_broker.properties.copy()
class TestNpcd(ShinkenTest):
def add(self, b):
self.broks[b.id] = b
def fake_check(self, ref, exit_status, output="OK"):
print "fake", ref
now = time.time()
ref.schedule()
开发者ID:David-,项目名称:shinken,代码行数:31,代码来源:test_npcdmod.py
示例16: Module
from shinken.check import Check
try:
import unittest2 as unittest
except ImportError:
import unittest
from shinken.objects.module import Module
from shinken.message import Message
import booster_nrpe
modconf = Module()
modconf.module_name = "NrpePoller"
modconf.module_type = booster_nrpe.properties['type']
modconf.properties = booster_nrpe.properties.copy()
class NrpePollerTestMixin(object):
def setUp(self):
super(NrpePollerTestMixin, self).setUp()
logger.setLevel(logging.DEBUG)
def _setup_nrpe(self, modconf):
mod = booster_nrpe.Nrpe_poller(modconf)
inst = booster_nrpe.get_instance(mod)
inst.init()
开发者ID:jfpik,项目名称:mod-booster-nrpe,代码行数:31,代码来源:test_simple.py
注:本文中的shinken.objects.module.Module类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论