本文整理汇总了Python中shinken.basemodule.BaseModule类的典型用法代码示例。如果您正苦于以下问题:Python BaseModule类的具体用法?Python BaseModule怎么用?Python BaseModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseModule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, mod_conf):
BaseModule.__init__(self, mod_conf)
self.uri = getattr(mod_conf, 'uri', 'mongodb://localhost')
logger.info('[Mongodb-Scheduler-Retention] mongo uri: %s', self.uri)
self.replica_set = getattr(mod_conf, 'replica_set', None)
if self.replica_set and int(pymongo.version[0]) < 3:
logger.error('[Mongodb-Scheduler-Retention] Can not initialize module with '
'replica_set because your pymongo lib is too old. '
'Please install it with a 3.x+ version from '
'https://pypi.python.org/pypi/pymongo')
return None
self.path = getattr(mod_conf, 'path', None)
logger.info('[Mongodb-Scheduler-Retention] old file path: %s', self.path)
self.database = getattr(mod_conf, 'database', 'shinken')
logger.info('[Mongodb-Scheduler-Retention] database: %s', self.database)
self.hosts_collection_name = getattr(mod_conf, 'hosts_collection_name', 'retention_hosts')
logger.info('[Mongodb-Scheduler-Retention] hosts retention collection: %s', self.hosts_collection_name)
self.services_collection_name = getattr(mod_conf, 'services_collection_name', 'retention_services')
logger.info('[Mongodb-Scheduler-Retention] services retention collection: %s', self.services_collection_name)
self.comments_collection_name = getattr(mod_conf, 'comments_collection_name', 'retention_comments')
logger.info('[Mongodb-Scheduler-Retention] comments retention collection: %s', self.comments_collection_name)
self.downtimes_collection_name = getattr(mod_conf, 'downtimes_collection_name', 'retention_downtimes')
logger.info('[Mongodb-Scheduler-Retention] downtimes retention collection: %s', self.downtimes_collection_name)
self.connection = None
self.task = None
开发者ID:congdonglinux,项目名称:mod-retention-mongodb,代码行数:34,代码来源:module.py
示例2: __init__
def __init__(self, modconf, server, sentinel_servers, redis_instance, wait_for_failover):
BaseModule.__init__(self, modconf)
self.server = server
self.sentinel_servers = sentinel_servers
self.redis_instance = redis_instance
self.wait_for_failover = wait_for_failover
if self.wait_for_failover:
self.wait_for_failover = int(self.wait_for_failover)
else:
self.wait_for_failover = 0
if self.sentinel_servers:
if not Sentinel:
logger.error('[RedisRetention]: Can not initialize module with '
'sentinel because your redis-py lib is too old. '
'Please install it with a 2.9+ version from '
'https://pypi.python.org/pypi/redis')
return None
else:
server_list = []
for sentinel_server in self.sentinel_servers.split(','):
server_list.append(tuple(sentinel_server.split(':')))
self.sentinel_servers = server_list
self.mc = None
开发者ID:mpedeupe,项目名称:mod-retention-redis,代码行数:26,代码来源:module.py
示例3: __init__
def __init__(self, modconf, server, port, password, db, expire_time):
BaseModule.__init__(self, modconf)
self.server = server
self.port = port
self.password = password
self.db = db
self.expire_time = expire_time
开发者ID:shinken-monitoring,项目名称:mod-retention-redis,代码行数:7,代码来源:module.py
示例4: __init__
def __init__(self, modconf):
BaseModule.__init__(self, modconf)
self.ldap_uri = getattr(modconf, "ldap_uri", None)
self.username = getattr(modconf, "username", "")
self.password = getattr(modconf, "password", "")
self.basedn = getattr(modconf, "basedn", "")
# If we got no uri, we bailout...
if not self.ldap_uri:
self.active = False
else:
self.active = True
self.con = None
# Switch between active directory and OpenLdap mode
self.mode = getattr(modconf, "mode", "ad")
if self.mode not in ["ad", "openldap"]:
raise Exception("WebUI Auth ldap module error, mode is not in ad or openldap")
self.retrieveAttributes = {
"ad": ["userPrincipalName", "thumbnailPhoto", "samaccountname", "email"],
"openldap": ["cn", "jpegphoto", "uid", "mail"],
}[self.mode]
self.photo_attr = {"ad": "thumbnailPhoto", "openldap": "jpegPhoto"}[self.mode]
self.name_id = {"ad": "userPrincipalName", "openldap": "uid"}[self.mode]
self.auth_key = {"ad": "userPrincipalName", "openldap": "dn"}[self.mode]
self.search_format = {"ad": "(| (samaccountname=%s)(mail=%s))", "openldap": "(| (uid=%s)(mail=%s))"}[self.mode]
开发者ID:sckevmit,项目名称:shinken,代码行数:25,代码来源:active_directory_ui.py
示例5: __init__
def __init__(self, mod_conf, host, port, socket, allowed_hosts, database_file, max_logs_age, pnp_path, debug=None, debug_queries=False):
BaseModule.__init__(self, mod_conf)
self.host = host
self.port = port
self.socket = socket
self.allowed_hosts = allowed_hosts
self.database_file = database_file
self.max_logs_age = max_logs_age
self.pnp_path = pnp_path
self.debug = debug
self.debug_queries = debug_queries
#Our datas
self.configs = {}
self.hosts = SortedDict()
self.services = SortedDict()
self.contacts = SortedDict()
self.hostgroups = SortedDict()
self.servicegroups = SortedDict()
self.contactgroups = SortedDict()
self.timeperiods = SortedDict()
self.commands = SortedDict()
#Now satellites
self.schedulers = SortedDict()
self.pollers = SortedDict()
self.reactionners = SortedDict()
self.brokers = SortedDict()
self.service_id_cache = {}
self.instance_ids = []
self.number_of_objects = 0
self.last_need_data_send = time.time()
开发者ID:Dabg,项目名称:shinken,代码行数:33,代码来源:livestatus_broker.py
示例6: __init__
def __init__(self, mod_conf, pub_endpoint, serialize_to):
from zmq import Context, PUB
BaseModule.__init__(self, mod_conf)
self.pub_endpoint = pub_endpoint
self.serialize_to = serialize_to
logger.info("[Zmq Broker] Binding to endpoint " + self.pub_endpoint)
# This doesn't work properly in init()
# sometimes it ends up beings called several
# times and the address becomes already in use.
self.context = Context()
self.s_pub = self.context.socket(PUB)
self.s_pub.bind(self.pub_endpoint)
# Load the correct serialization function
# depending on the serialization method
# chosen in the configuration.
if self.serialize_to == "msgpack":
from msgpack import Packer
packer = Packer(default=encode_monitoring_data)
self.serialize = lambda msg: packer.pack(msg)
elif self.serialize_to == "json":
self.serialize = lambda msg: json.dumps(msg, cls=SetEncoder)
else:
raise Exception("[Zmq Broker] No valid serialization method defined (Got " + str(self.serialize_to) + ")!")
开发者ID:shinken-debian-modules,项目名称:shinken-mod-zmq,代码行数:27,代码来源:module.py
示例7: __init__
def __init__(self, mod_conf, host, port, socket, allowed_hosts, database_file, max_logs_age, pnp_path):
BaseModule.__init__(self, mod_conf)
self.host = host
self.port = port
self.socket = socket
self.allowed_hosts = allowed_hosts
self.database_file = database_file
self.max_logs_age = max_logs_age
self.pnp_path = pnp_path
#Our datas
self.configs = {}
self.hosts = {}
self.services = {}
self.contacts = {}
self.hostgroups = {}
self.servicegroups = {}
self.contactgroups = {}
self.timeperiods = {}
self.commands = {}
#Now satellites
self.schedulers = {}
self.pollers = {}
self.reactionners = {}
self.brokers = {}
self.instance_ids = []
self.hostname_lookup_table = {}
self.servicename_lookup_table = {}
self.number_of_objects = 0
self.last_need_data_send = time.time()
开发者ID:wAmpIre,项目名称:shinken,代码行数:33,代码来源:livestatus_broker.py
示例8: __init__
def __init__(self, mod_conf, uri, database):
BaseModule.__init__(self, mod_conf)
self.uri = uri
self.database = database
# Some used varaible init
self.con = None
self.db = None
开发者ID:amosshapira,项目名称:shinken,代码行数:7,代码来源:mongodb_generic.py
示例9: __init__
def __init__(self, mod_conf, host, login, password, database, reqlist):
BaseModule.__init__(self, mod_conf)
self.host = host
self.login = login
self.password = password
self.database = database
self.reqlist = reqlist
开发者ID:sni,项目名称:shinken,代码行数:7,代码来源:mysql_import_arbiter.py
示例10: __init__
def __init__(self, modconf):
BaseModule.__init__(self, modconf)
self.host = getattr(modconf, 'host', 'localhost')
self.use_pickle = getattr(modconf, 'use_pickle', '0') == '1'
if self.use_pickle:
self.port = int(getattr(modconf, 'port', '2004'))
else:
self.port = int(getattr(modconf, 'port', '2003'))
self.tick_limit = int(getattr(modconf, 'tick_limit', '300'))
# Used to reset check time into the scheduled time.
# Carbon/graphite does not like latency data and creates blanks in graphs
# Every data with "small" latency will be considered create at scheduled time
self.ignore_latency_limit = \
int(getattr(modconf, 'ignore_latency_limit', '0'))
if self.ignore_latency_limit < 0:
self.ignore_latency_limit = 0
self.buffer = []
self.ticks = 0
self.host_dict = {}
self.svc_dict = {}
self.multival = re.compile(r'_(\d+)$')
self.chunk_size = 200
self.max_chunk_size = 100000
# optional "sub-folder" in graphite to hold the data of a specific host
self.graphite_data_source = \
self.illegal_char.sub('_', getattr(modconf, 'graphite_data_source', ''))
开发者ID:Azef1,项目名称:mod-graphite,代码行数:27,代码来源:module.py
示例11: __init__
def __init__(self, modconf):
BaseModule.__init__(self, modconf)
self.hosts_cache = {}
self.services_cache = {}
# Database configuration
self.host = getattr(modconf, 'host', '127.0.0.1')
self.user = getattr(modconf, 'user', 'shinken')
self.password = getattr(modconf, 'password', 'shinken')
self.database = getattr(modconf, 'database', 'glpidb')
self.character_set = getattr(modconf, 'character_set', 'utf8')
logger.info("[glpidb] using '%s' database on %s (user = %s)", self.database, self.host, self.user)
# Database tables update configuration
self.update_availability = bool(getattr(modconf, 'update_availability', '0')=='1')
self.update_shinken_state = bool(getattr(modconf, 'update_shinken_state', '0')=='1')
self.update_services_events = bool(getattr(modconf, 'update_services_events', '0')=='1')
self.update_hosts = bool(getattr(modconf, 'update_hosts', '0')=='1')
self.update_services = bool(getattr(modconf, 'update_services', '0')=='1')
self.update_acknowledges = bool(getattr(modconf, 'update_acknowledges', '0')=='1')
logger.info("[glpidb] updating availability: %s", self.update_availability)
logger.info("[glpidb] updating Shinken state: %s", self.update_shinken_state)
logger.info("[glpidb] updating services events: %s", self.update_services_events)
logger.info("[glpidb] updating hosts states: %s", self.update_hosts)
logger.info("[glpidb] updating services states: %s", self.update_services)
logger.info("[glpidb] updating acknowledges states: %s", self.update_acknowledges)
开发者ID:shinken-debian-modules,项目名称:shinken-mod-glpidb,代码行数:27,代码来源:module.py
示例12: __init__
def __init__(self, modconf, host, port, encryption_method, password):
BaseModule.__init__(self, modconf)
self.host = host
self.port = port
self.encryption_method = encryption_method
self.password = password
self.rng = random.Random(password)
开发者ID:wAmpIre,项目名称:shinken,代码行数:7,代码来源:nsca.py
示例13: __init__
def __init__(self, mod_conf):
BaseModule.__init__(self, mod_conf)
# create shared queues
#manager = Manager()
#self.create_queues(manager=manager)
# store only host and service check results
self.host_valid_broks = ['host_check_result']
self.service_valid_broks = ['service_check_result']
# need only these keys out of complete check result
self.host_valid_attrs = ['address', 'state', 'last_chk',
'last_state_change', 'host_name', 'perf_data']
self.service_valid_attrs = self.host_valid_attrs + ['service_description']
# need to save plugin output for these services as well
self.need_plugin_out = ['wimax_topology', 'cambium_topology']
self.redis_conf = {
'host': getattr(mod_conf, 'host', 'localhost'),
'port': getattr(mod_conf, 'port', 6379),
'db': int(getattr(mod_conf, 'db', 0))
}
sentinels = []
sentinels_conf = getattr(mod_conf, 'sentinels', None)
if sentinels_conf:
sentinels_conf = sentinels_conf.split(',')
while sentinels_conf:
sentinels.append(tuple(sentinels_conf[:2]))
sentinels_conf = sentinels_conf[2:]
sentinels_service_name = getattr(mod_conf, 'service_name', 'mymaster')
self.redis_conf.update({'sentinels': sentinels,
'sentinels_service_name': sentinels_service_name})
min_other_sentinels = getattr(mod_conf, 'min_other_sentinels', 0)
# redis queue
self.queue = RedisQueue(**self.redis_conf)
开发者ID:peeyush-tm,项目名称:shinken,代码行数:33,代码来源:module.py
示例14: __init__
def __init__(self, conf):
BaseModule.__init__(self, conf)
# Mapping for name of data and transform function
self.mapping = {
"program_status": {
"program_start": {"name": "program_start_time", "transform": de_unixify},
"pid": {"name": "process_id", "transform": None},
"last_alive": {"name": "status_update_time", "transform": de_unixify},
"is_running": {"name": "is_currently_running", "transform": None},
"last_log_rotation": {"name": "last_log_rotation", "transform": de_unixify},
"last_command_check": {"name": "last_command_check", "transform": de_unixify},
}
}
self.host = conf.host
self.user = conf.user
self.password = conf.password
self.database = conf.database
self.character_set = conf.character_set
self.port = int(getattr(conf, "port", "3306"))
self.prefix = getattr(conf, "prefix", "nagios_")
# Centreon ndo add some fields like long_output
# that are not in the vanilla ndo
self.centreon_version = False
self.synchronize_database_id = int(conf.synchronize_database_id)
开发者ID:shaicoleman,项目名称:shinken,代码行数:26,代码来源:ndodb_mysql_broker.py
示例15: __init__
def __init__(self, mod_conf, key, secret, ca, default_template, https_proxy):
BaseModule.__init__(self, mod_conf)
self.key = key
self.secret = secret
self.ca = ca
self.default_template = default_template
self.https_proxy = https_proxy
开发者ID:David-,项目名称:shinken,代码行数:7,代码来源:module.py
示例16: __init__
def __init__(self, mod_conf):
BaseModule.__init__(self, mod_conf)
logger.info("[Checks forward] module init")
try:
logger.debug("[Checks forward] module init : get parameters entities")
# Module configuration
self.glpi_entities = getattr(mod_conf, 'glpi_entities', '')
self.glpi_entities = self.glpi_entities.split(',')
if len(self.glpi_entities) > 0 and self.glpi_entities[0] == '':
self.glpi_entities = None
logger.warning("[Checks forward] module init : get parameters nsca")
self.send_nsca_bin = str(getattr(mod_conf, 'send_nsca_bin', '/usr/sbin/send_nsca'))
self.send_nsca_config = str(getattr(mod_conf, 'send_nsca_config', '/etc/send_nsca.cfg'))
logger.warning("[Checks forward] module init : get parameters nsca server")
self.nsca_server_host = str(getattr(mod_conf, 'nsca_server_host', '127.0.0.1'))
self.nsca_server_port = int(getattr(mod_conf, 'nsca_server_port', 5667))
logger.warning("[Checks forward] module init : log info")
logger.info("[Checks forward] module configuration, forward to: %s:%s, using %s with configuration %s" % (self.nsca_server_host, self.nsca_server_port, self.send_nsca_bin, self.send_nsca_config))
if self.glpi_entities:
logger.info("[Checks forward] module configuration, forward checks for GLPI entities: %s" % str(self.glpi_entities))
else:
logger.info("[Checks forward] module configuration, forward checks for all hosts/services")
# Internal cache for host entities id
self.cache_host_entities_id = {}
except AttributeError:
logger.error("[Checks forward] The module is missing a property, check module configuration")
raise
开发者ID:jeromeLB,项目名称:mod-checks-forward,代码行数:33,代码来源:module.py
示例17: __init__
def __init__(self, modconf, config_file, perfdata_file, perfdata_spool_dir, perfdata_spool_filename, sleep_time):
BaseModule.__init__(self, modconf)
self.config_file = config_file
self.perfdata_file = perfdata_file
self.perfdata_spool_dir = perfdata_spool_dir
self.perfdata_spool_filename = perfdata_spool_filename
self.sleep_time = sleep_time
self.process_performance_data = True # this can be reset and set by program_status_broks
self.processed_lines = 0
self.host_commands = {}
self.service_commands = {}
if self.config_file and not self.process_config_file():
print "npcdmod: An error occurred process your config file. Check your perfdata_file or perfdata_spool_dir"
raise
if not self.perfdata_spool_dir and not self.perfdata_file:
print "npcdmod: An error occurred while attempting to process module arguments"
raise
try:
# We open the file with line buffering, so we can better watch it with tail -f
self.logfile = open(self.perfdata_file, 'a', 1)
except:
print "could not open file %s" % self.perfdata_file
raise
# use so we do nto ask a reinit ofan instance too quickly
self.last_need_data_send = time.time()
开发者ID:Dabg,项目名称:shinken,代码行数:26,代码来源:npcdmod_broker.py
示例18: __init__
def __init__(self, modconf):
BaseModule.__init__(self, modconf)
self.plugins = []
# Now sleep one second, so that won't get lineno collisions with the last second
time.sleep(1)
Logline.lineno = 0
开发者ID:raphaeltr,项目名称:shinken,代码行数:7,代码来源:logstore_null.py
示例19: __init__
def __init__(self, conf):
BaseModule.__init__(self, conf)
# Mapping for name of data and transform function
self.mapping = {
'program_status': {
'program_start': {'name': 'program_start_time', 'transform': de_unixify},
'pid': {'name': 'process_id', 'transform': None},
'last_alive': {'name': 'status_update_time', 'transform': de_unixify},
'is_running': {'name': 'is_currently_running', 'transform': None},
'last_log_rotation': {'name': 'last_log_rotation', 'transform': de_unixify},
'last_command_check': {'name': 'last_command_check', 'transform': de_unixify}
},
}
self.host = conf.host
self.user = conf.user
self.password = conf.password
self.database = conf.database
self.character_set = conf.character_set
self.port = int(getattr(conf, 'port', '3306'))
self.prefix = getattr(conf, 'prefix', 'nagios_')
# Centreon ndo add some fields like long_output
# that are not in the vanilla ndo
self.centreon_version = False
self.synchronize_database_id = int(conf.synchronize_database_id)
开发者ID:sckevmit,项目名称:shinken,代码行数:26,代码来源:ndodb_mysql_broker.py
示例20: __init__
def __init__(self, modconf):
BaseModule.__init__(self, modconf)
# mongodb://host1,host2,host3/?safe=true;w=2;wtimeoutMS=2000
self.mongodb_uri = getattr(modconf, 'mongodb_uri', None)
self.database = getattr(modconf, 'database', 'shinken')
self.version = version
self.pp = pprint.PrettyPrinter()
开发者ID:sni,项目名称:shinken,代码行数:7,代码来源:mongodb_broker.py
注:本文中的shinken.basemodule.BaseModule类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论