本文整理汇总了Python中shinken.external_command.ExternalCommandManager.load_receiver方法的典型用法代码示例。如果您正苦于以下问题:Python ExternalCommandManager.load_receiver方法的具体用法?Python ExternalCommandManager.load_receiver怎么用?Python ExternalCommandManager.load_receiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shinken.external_command.ExternalCommandManager
的用法示例。
在下文中一共展示了ExternalCommandManager.load_receiver方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from shinken.external_command import ExternalCommandManager [as 别名]
# 或者: from shinken.external_command.ExternalCommandManager import load_receiver [as 别名]
def __init__(self, config_file, is_daemon, do_replace, debug, debug_file):
super(Receiver, self).__init__(
'receiver', config_file, is_daemon, do_replace, debug, debug_file)
# Our arbiters
self.arbiters = {}
# Our pollers and reactionners
self.pollers = {}
self.reactionners = {}
# Modules are load one time
self.have_modules = False
# Can have a queue of external_commands give by modules
# will be taken by arbiter to process
self.external_commands = []
# and the unprocessed one, a buffer
self.unprocessed_external_commands = []
self.host_assoc = {}
self.direct_routing = False
self.accept_passive_unknown_check_results = False
self.istats = IStats(self)
self.ibroks = IBroks(self)
# Now create the external commander. It's just here to dispatch
# the commands to schedulers
e = ExternalCommandManager(None, 'receiver')
e.load_receiver(self)
self.external_command = e
示例2: test_unknown_check_result_command_receiver
# 需要导入模块: from shinken.external_command import ExternalCommandManager [as 别名]
# 或者: from shinken.external_command.ExternalCommandManager import load_receiver [as 别名]
def test_unknown_check_result_command_receiver(self):
receiverdaemon = Receiver(None, False, False, False, None)
receiverdaemon.direct_routing = True
receiverdaemon.accept_passive_unknown_check_results = True
# Now create the external commander. It's just here to dispatch
# the commands to schedulers. Pasted from setup_new_conf()
e = ExternalCommandManager(None, 'receiver')
e.load_receiver(receiverdaemon)
receiverdaemon.external_command = e
# Receiver receives unknown host external command
excmd = ExternalCommand('[%d] PROCESS_SERVICE_CHECK_RESULT;test_host_0;unknownservice;1;Bobby is not happy|rtt=9999;5;10;0;10000' % time.time())
receiverdaemon.unprocessed_external_commands.append(excmd)
receiverdaemon.push_external_commands_to_schedulers()
broks = [b for b in receiverdaemon.broks.values() if b.type == 'unknown_service_check_result']
self.assertEqual(len(broks), 1)
# now turn it off...
receiverdaemon.accept_passive_unknown_check_results = False
excmd = ExternalCommand('[%d] PROCESS_SERVICE_CHECK_RESULT;test_host_0;unknownservice;1;Bobby is not happy|rtt=9999;5;10;0;10000' % time.time())
receiverdaemon.unprocessed_external_commands.append(excmd)
receiverdaemon.push_external_commands_to_schedulers()
receiverdaemon.broks.clear()
broks = [b for b in receiverdaemon.broks.values() if b.type == 'unknown_service_check_result']
self.assertEqual(len(broks), 0)
示例3: setup_new_conf
# 需要导入模块: from shinken.external_command import ExternalCommandManager [as 别名]
# 或者: from shinken.external_command.ExternalCommandManager import load_receiver [as 别名]
def setup_new_conf(self):
conf = self.new_conf
self.new_conf = None
self.cur_conf = conf
# Got our name from the globals
if 'receiver_name' in conf['global']:
name = conf['global']['receiver_name']
else:
name = 'Unnamed receiver'
self.name = name
self.log.load_obj(self, name)
self.direct_routing = conf['global']['direct_routing']
g_conf = conf['global']
# If we've got something in the schedulers, we do not want it anymore
for sched_id in conf['schedulers']:
already_got = False
# We can already got this conf id, but with another address
if sched_id in self.schedulers:
new_addr = conf['schedulers'][sched_id]['address']
old_addr = self.schedulers[sched_id]['address']
new_port = conf['schedulers'][sched_id]['port']
old_port = self.schedulers[sched_id]['port']
# Should got all the same to be ok :)
if new_addr == old_addr and new_port == old_port:
already_got = True
if already_got:
logger.info("[%s] We already got the conf %d (%s)" % (self.name, sched_id, conf['schedulers'][sched_id]['name']))
wait_homerun = self.schedulers[sched_id]['wait_homerun']
actions = self.schedulers[sched_id]['actions']
external_commands = self.schedulers[sched_id]['external_commands']
con = self.schedulers[sched_id]['con']
s = conf['schedulers'][sched_id]
self.schedulers[sched_id] = s
if s['name'] in g_conf['satellitemap']:
s.update(g_conf['satellitemap'][s['name']])
uri = pyro.create_uri(s['address'], s['port'], 'ForArbiter', self.use_ssl)
self.schedulers[sched_id]['uri'] = uri
if already_got:
self.schedulers[sched_id]['wait_homerun'] = wait_homerun
self.schedulers[sched_id]['actions'] = actions
self.schedulers[sched_id]['external_commands'] = external_commands
self.schedulers[sched_id]['con'] = con
else:
self.schedulers[sched_id]['wait_homerun'] = {}
self.schedulers[sched_id]['actions'] = {}
self.schedulers[sched_id]['external_commands'] = []
self.schedulers[sched_id]['con'] = None
self.schedulers[sched_id]['running_id'] = 0
self.schedulers[sched_id]['active'] = s['active']
# Do not connect if we are a passive satellite
if self.direct_routing and not already_got:
# And then we connect to it :)
self.pynag_con_init(sched_id)
logger.debug("[%s] Sending us configuration %s" % (self.name, conf))
if not self.have_modules:
self.modules = mods = conf['global']['modules']
self.have_modules = True
logger.info("We received modules %s " % mods)
# Set our giving timezone from arbiter
use_timezone = conf['global']['use_timezone']
if use_timezone != 'NOTSET':
logger.info("Setting our timezone to %s" % use_timezone)
os.environ['TZ'] = use_timezone
time.tzset()
# Now create the external commander. It's just here to dispatch
# the commands to schedulers
e = ExternalCommandManager(None, 'receiver')
e.load_receiver(self)
self.external_command = e
示例4: setup_new_conf
# 需要导入模块: from shinken.external_command import ExternalCommandManager [as 别名]
# 或者: from shinken.external_command.ExternalCommandManager import load_receiver [as 别名]
def setup_new_conf(self):
conf = self.new_conf
self.new_conf = None
self.cur_conf = conf
# Got our name from the globals
if "receiver_name" in conf["global"]:
name = conf["global"]["receiver_name"]
else:
name = "Unnamed receiver"
self.name = name
logger.load_obj(self, name)
self.direct_routing = conf["global"]["direct_routing"]
g_conf = conf["global"]
# If we've got something in the schedulers, we do not want it anymore
for sched_id in conf["schedulers"]:
already_got = False
# We can already got this conf id, but with another address
if sched_id in self.schedulers:
new_addr = conf["schedulers"][sched_id]["address"]
old_addr = self.schedulers[sched_id]["address"]
new_port = conf["schedulers"][sched_id]["port"]
old_port = self.schedulers[sched_id]["port"]
# Should got all the same to be ok :)
if new_addr == old_addr and new_port == old_port:
already_got = True
if already_got:
logger.info(
"[%s] We already got the conf %d (%s)" % (self.name, sched_id, conf["schedulers"][sched_id]["name"])
)
wait_homerun = self.schedulers[sched_id]["wait_homerun"]
actions = self.schedulers[sched_id]["actions"]
external_commands = self.schedulers[sched_id]["external_commands"]
con = self.schedulers[sched_id]["con"]
s = conf["schedulers"][sched_id]
self.schedulers[sched_id] = s
if s["name"] in g_conf["satellitemap"]:
s.update(g_conf["satellitemap"][s["name"]])
uri = "http://%s:%s/" % (s["address"], s["port"])
self.schedulers[sched_id]["uri"] = uri
if already_got:
self.schedulers[sched_id]["wait_homerun"] = wait_homerun
self.schedulers[sched_id]["actions"] = actions
self.schedulers[sched_id]["external_commands"] = external_commands
self.schedulers[sched_id]["con"] = con
else:
self.schedulers[sched_id]["wait_homerun"] = {}
self.schedulers[sched_id]["actions"] = {}
self.schedulers[sched_id]["external_commands"] = []
self.schedulers[sched_id]["con"] = None
self.schedulers[sched_id]["running_id"] = 0
self.schedulers[sched_id]["active"] = s["active"]
# Do not connect if we are a passive satellite
if self.direct_routing and not already_got:
# And then we connect to it :)
self.pynag_con_init(sched_id)
logger.debug("[%s] Sending us configuration %s" % (self.name, conf))
if not self.have_modules:
self.modules = mods = conf["global"]["modules"]
self.have_modules = True
logger.info("We received modules %s " % mods)
# Set our giving timezone from arbiter
use_timezone = conf["global"]["use_timezone"]
if use_timezone != "NOTSET":
logger.info("Setting our timezone to %s" % use_timezone)
os.environ["TZ"] = use_timezone
time.tzset()
# Now create the external commander. It's just here to dispatch
# the commands to schedulers
e = ExternalCommandManager(None, "receiver")
e.load_receiver(self)
self.external_command = e