本文整理汇总了Python中shinken.basemodule.BaseModule类的典型用法代码示例。如果您正苦于以下问题:Python BaseModule类的具体用法?Python BaseModule怎么用?Python BaseModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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]
示例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()
示例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) + ")!")
示例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()
示例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
示例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
示例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', ''))
示例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)
示例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)
示例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)
示例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)
示例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