本文整理汇总了Python中shinken.scheduler.Scheduler类的典型用法代码示例。如果您正苦于以下问题:Python Scheduler类的具体用法?Python Scheduler怎么用?Python Scheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scheduler类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_with_file
def setup_with_file(self, path):
# i am arbiter-like
self.broks = {}
self.me = None
self.log = logger
self.log.load_obj(self)
self.config_files = [path]
self.conf = Config()
buf = self.conf.read_config(self.config_files)
raw_objects = self.conf.read_config_buf(buf)
self.conf.create_objects_for_type(raw_objects, 'arbiter')
self.conf.create_objects_for_type(raw_objects, 'module')
self.conf.early_arbiter_linking()
self.conf.create_objects(raw_objects)
self.conf.old_properties_names_to_new()
self.conf.instance_id = 0
self.conf.instance_name = 'test'
# Hack push_flavor, that is set by the dispatcher
self.conf.push_flavor = 0
self.conf.linkify_templates()
self.conf.apply_inheritance()
self.conf.explode()
print "Aconf.services has %d elements" % len(self.conf.services)
self.conf.create_reversed_list()
self.conf.remove_twins()
self.conf.apply_implicit_inheritance()
self.conf.fill_default()
self.conf.remove_templates()
print "conf.services has %d elements" % len(self.conf.services)
self.conf.create_reversed_list()
self.conf.pythonize()
self.conf.linkify()
self.conf.apply_dependencies()
self.conf.explode_global_conf()
self.conf.propagate_timezone_option()
self.conf.create_business_rules()
self.conf.create_business_rules_dependencies()
self.conf.is_correct()
self.confs = self.conf.cut_into_parts()
self.conf.show_errors()
self.dispatcher = Dispatcher(self.conf, self.me)
scheddaemon = Shinken(None, False, False, False, None)
self.sched = Scheduler(scheddaemon)
scheddaemon.sched = self.sched
m = MacroResolver()
m.init(self.conf)
self.sched.load_conf(self.conf)
e = ExternalCommandManager(self.conf, 'applyer')
self.sched.external_command = e
e.load_scheduler(self.sched)
e2 = ExternalCommandManager(self.conf, 'dispatcher')
e2.load_arbiter(self)
self.external_command_dispatcher = e2
self.sched.schedule()
开发者ID:jfbutkiewicz,项目名称:Windows-Setup-for-Shinken,代码行数:57,代码来源:shinken_test.py
示例2: __init__
def __init__(self, config_file, is_daemon, do_replace, debug, debug_file):
BaseSatellite.__init__(self, 'scheduler', config_file, is_daemon, do_replace, debug, debug_file)
self.interface = IForArbiter(self)
self.sched = Scheduler(self)
self.ichecks = None
self.ibroks = None
self.must_run = True
# Now the interface
self.uri = None
self.uri2 = None
# And possible links for satellites
# from now only pollers
self.pollers = {}
self.reactionners = {}
开发者ID:BaniaHP,项目名称:shinken,代码行数:19,代码来源:schedulerdaemon.py
示例3: setup_with_file
def setup_with_file(self, path):
time_hacker.set_my_time()
self.print_header()
# i am arbiter-like
self.broks = {}
self.me = None
self.log = logger
self.log.load_obj(self)
self.config_files = [path]
self.conf = Config()
buf = self.conf.read_config(self.config_files)
raw_objects = self.conf.read_config_buf(buf)
self.conf.create_objects_for_type(raw_objects, 'arbiter')
self.conf.create_objects_for_type(raw_objects, 'module')
self.conf.early_arbiter_linking()
self.conf.create_objects(raw_objects)
self.conf.instance_id = 0
self.conf.instance_name = 'test'
# Hack push_flavor, that is set by the dispatcher
self.conf.push_flavor = 0
self.conf.load_triggers()
#import pdb;pdb.set_trace()
self.conf.linkify_templates()
#import pdb;pdb.set_trace()
self.conf.apply_inheritance()
#import pdb;pdb.set_trace()
self.conf.explode()
#print "Aconf.services has %d elements" % len(self.conf.services)
self.conf.apply_implicit_inheritance()
self.conf.fill_default()
self.conf.remove_templates()
self.conf.compute_hash()
#print "conf.services has %d elements" % len(self.conf.services)
self.conf.override_properties()
self.conf.linkify()
self.conf.apply_dependencies()
self.conf.explode_global_conf()
self.conf.propagate_timezone_option()
self.conf.create_business_rules()
self.conf.create_business_rules_dependencies()
self.conf.is_correct()
if not self.conf.conf_is_correct:
print "The conf is not correct, I stop here"
self.conf.dump()
return
self.conf.clean()
self.confs = self.conf.cut_into_parts()
self.conf.prepare_for_sending()
self.conf.show_errors()
self.dispatcher = Dispatcher(self.conf, self.me)
scheddaemon = Shinken(None, False, False, False, None, None)
self.sched = Scheduler(scheddaemon)
scheddaemon.sched = self.sched
scheddaemon.modules_dir = modules_dir
scheddaemon.load_modules_manager()
# Remember to clean the logs we just created before launching tests
self.clear_logs()
m = MacroResolver()
m.init(self.conf)
self.sched.load_conf(self.conf, in_test=True)
e = ExternalCommandManager(self.conf, 'applyer')
self.sched.external_command = e
e.load_scheduler(self.sched)
e2 = ExternalCommandManager(self.conf, 'dispatcher')
e2.load_arbiter(self)
self.external_command_dispatcher = e2
self.sched.conf.accept_passive_unknown_check_results = False
self.sched.schedule()
开发者ID:MPOWER4RU,项目名称:shinken,代码行数:72,代码来源:shinken_test.py
示例4: ShinkenTest
class ShinkenTest(unittest.TestCase, _Unittest2CompatMixIn):
def setUp(self):
self.setup_with_file('etc/shinken_1r_1h_1s.cfg')
def setup_with_file(self, path):
time_hacker.set_my_time()
self.print_header()
# i am arbiter-like
self.broks = {}
self.me = None
self.log = logger
self.log.load_obj(self)
self.config_files = [path]
self.conf = Config()
buf = self.conf.read_config(self.config_files)
raw_objects = self.conf.read_config_buf(buf)
self.conf.create_objects_for_type(raw_objects, 'arbiter')
self.conf.create_objects_for_type(raw_objects, 'module')
self.conf.early_arbiter_linking()
self.conf.create_objects(raw_objects)
self.conf.instance_id = 0
self.conf.instance_name = 'test'
# Hack push_flavor, that is set by the dispatcher
self.conf.push_flavor = 0
self.conf.load_triggers()
#import pdb;pdb.set_trace()
self.conf.linkify_templates()
#import pdb;pdb.set_trace()
self.conf.apply_inheritance()
#import pdb;pdb.set_trace()
self.conf.explode()
#print "Aconf.services has %d elements" % len(self.conf.services)
self.conf.apply_implicit_inheritance()
self.conf.fill_default()
self.conf.remove_templates()
self.conf.compute_hash()
#print "conf.services has %d elements" % len(self.conf.services)
self.conf.override_properties()
self.conf.linkify()
self.conf.apply_dependencies()
self.conf.explode_global_conf()
self.conf.propagate_timezone_option()
self.conf.create_business_rules()
self.conf.create_business_rules_dependencies()
self.conf.is_correct()
if not self.conf.conf_is_correct:
print "The conf is not correct, I stop here"
self.conf.dump()
return
self.conf.clean()
self.confs = self.conf.cut_into_parts()
self.conf.prepare_for_sending()
self.conf.show_errors()
self.dispatcher = Dispatcher(self.conf, self.me)
scheddaemon = Shinken(None, False, False, False, None, None)
self.sched = Scheduler(scheddaemon)
scheddaemon.sched = self.sched
scheddaemon.modules_dir = modules_dir
scheddaemon.load_modules_manager()
# Remember to clean the logs we just created before launching tests
self.clear_logs()
m = MacroResolver()
m.init(self.conf)
self.sched.load_conf(self.conf, in_test=True)
e = ExternalCommandManager(self.conf, 'applyer')
self.sched.external_command = e
e.load_scheduler(self.sched)
e2 = ExternalCommandManager(self.conf, 'dispatcher')
e2.load_arbiter(self)
self.external_command_dispatcher = e2
self.sched.conf.accept_passive_unknown_check_results = False
self.sched.schedule()
def add(self, b):
if isinstance(b, Brok):
self.broks[b.id] = b
return
if isinstance(b, ExternalCommand):
self.sched.run_external_command(b.cmd_line)
def fake_check(self, ref, exit_status, output="OK"):
#print "fake", ref
now = time.time()
ref.schedule(force=True)
# now checks are schedule and we get them in
# the action queue
#check = ref.actions.pop()
check = ref.checks_in_progress[0]
self.sched.add(check) # check is now in sched.checks[]
# Allows to force check scheduling without setting its status nor
# output. Useful for manual business rules rescheduling, for instance.
if exit_status is None:
return
# fake execution
#.........这里部分代码省略.........
开发者ID:MPOWER4RU,项目名称:shinken,代码行数:101,代码来源:shinken_test.py
示例5: ShinkenTest
class ShinkenTest(unittest.TestCase):
def setUp(self):
self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
def setup_with_file(self, path):
# i am arbiter-like
self.broks = {}
self.me = None
self.log = logger
self.log.load_obj(self)
self.config_files = [path]
self.conf = Config()
buf = self.conf.read_config(self.config_files)
raw_objects = self.conf.read_config_buf(buf)
self.conf.create_objects_for_type(raw_objects, 'arbiter')
self.conf.create_objects_for_type(raw_objects, 'module')
self.conf.early_arbiter_linking()
self.conf.create_objects(raw_objects)
self.conf.old_properties_names_to_new()
self.conf.instance_id = 0
self.conf.instance_name = 'test'
# Hack push_flavor, that is set by the dispatcher
self.conf.push_flavor = 0
self.conf.load_triggers()
self.conf.linkify_templates()
self.conf.apply_inheritance()
self.conf.explode()
#print "Aconf.services has %d elements" % len(self.conf.services)
self.conf.create_reversed_list()
self.conf.remove_twins()
self.conf.apply_implicit_inheritance()
self.conf.fill_default()
self.conf.remove_templates()
self.conf.compute_hash()
#print "conf.services has %d elements" % len(self.conf.services)
self.conf.create_reversed_list()
self.conf.pythonize()
self.conf.linkify()
self.conf.apply_dependencies()
self.conf.explode_global_conf()
self.conf.propagate_timezone_option()
self.conf.create_business_rules()
self.conf.create_business_rules_dependencies()
self.conf.is_correct()
if not self.conf.conf_is_correct:
print "The conf is not correct, I stop here"
return
self.confs = self.conf.cut_into_parts()
self.conf.prepare_for_sending()
self.conf.show_errors()
self.dispatcher = Dispatcher(self.conf, self.me)
scheddaemon = Shinken(None, False, False, False, None)
self.sched = Scheduler(scheddaemon)
scheddaemon.sched = self.sched
m = MacroResolver()
m.init(self.conf)
self.sched.load_conf(self.conf, in_test=True)
e = ExternalCommandManager(self.conf, 'applyer')
self.sched.external_command = e
e.load_scheduler(self.sched)
e2 = ExternalCommandManager(self.conf, 'dispatcher')
e2.load_arbiter(self)
self.external_command_dispatcher = e2
self.sched.schedule()
def add(self, b):
if isinstance(b, Brok):
self.broks[b.id] = b
return
if isinstance(b, ExternalCommand):
self.sched.run_external_command(b.cmd_line)
def fake_check(self, ref, exit_status, output="OK"):
#print "fake", ref
now = time.time()
ref.schedule(force=True)
# now checks are schedule and we get them in
# the action queue
check = ref.actions.pop()
self.sched.add(check) # check is now in sched.checks[]
# fake execution
check.check_time = now
# and lie about when we will launch it because
# if not, the schedule call for ref
# will not really reschedule it because there
# is a valid value in the future
ref.next_chk = now - 0.5
check.get_outputs(output, 9000)
check.exit_status = exit_status
check.execution_time = 0.001
check.status = 'waitconsume'
self.sched.waiting_results.append(check)
#.........这里部分代码省略.........
开发者ID:BaniaHP,项目名称:shinken,代码行数:101,代码来源:shinken_test.py
示例6: ShinkenTest
class ShinkenTest(unittest.TestCase):
def setUp(self):
self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
def setup_with_file(self, path):
# i am arbiter-like
self.broks = {}
self.me = None
self.log = logger
self.log.load_obj(self)
self.config_files = [path]
self.conf = Config()
self.conf.read_config(self.config_files)
buf = self.conf.read_config(self.config_files)
raw_objects = self.conf.read_config_buf(buf)
self.conf.create_objects_for_type(raw_objects, 'arbiter')
self.conf.create_objects_for_type(raw_objects, 'module')
self.conf.early_arbiter_linking()
self.conf.create_objects(raw_objects)
self.conf.old_properties_names_to_new()
self.conf.instance_id = 0
self.conf.instance_name = 'test'
self.conf.linkify_templates()
self.conf.apply_inheritance()
self.conf.explode()
self.conf.create_reversed_list()
self.conf.remove_twins()
self.conf.apply_implicit_inheritance()
self.conf.fill_default()
self.conf.remove_templates()
self.conf.create_reversed_list()
self.conf.pythonize()
self.conf.linkify()
self.conf.apply_dependencies()
self.conf.explode_global_conf()
self.conf.propagate_timezone_option()
self.conf.create_business_rules()
self.conf.create_business_rules_dependencies()
self.conf.is_correct()
self.confs = self.conf.cut_into_parts()
self.conf.show_errors()
self.dispatcher = Dispatcher(self.conf, self.me)
scheddaemon = Shinken(None, False, False, False, None)
self.sched = Scheduler(scheddaemon)
scheddaemon.sched = self.sched
m = MacroResolver()
m.init(self.conf)
self.sched.load_conf(self.conf)
e = ExternalCommandManager(self.conf, 'applyer')
self.sched.external_command = e
e.load_scheduler(self.sched)
e2 = ExternalCommandManager(self.conf, 'dispatcher')
e2.load_arbiter(self)
self.external_command_dispatcher = e2
self.sched.schedule()
def add(self, b):
if isinstance(b, Brok):
self.broks[b.id] = b
return
if isinstance(b, ExternalCommand):
self.sched.run_external_command(b.cmd_line)
def fake_check(self, ref, exit_status, output="OK"):
#print "fake", ref
now = time.time()
ref.schedule(force=True)
#now checks are schedule and we get them in
#the action queue
check = ref.actions.pop()
self.sched.add(check) # check is now in sched.checks[]
# fake execution
check.check_time = now
# and lie about when we will launch it because
# if not, the schedule call for ref
# will not really reschedule it because there
# is a valid value in the future
ref.next_chk = now - 0.5
check.get_outputs(output, 9000)
check.exit_status = exit_status
check.execution_time = 0.001
check.status = 'waitconsume'
self.sched.waiting_results.append(check)
def scheduler_loop(self, count, reflist, do_sleep=False, sleep_time=61):
for ref in reflist:
(obj, exit_status, output) = ref
obj.checks_in_progress = []
for loop in range(1, count + 1):
print "processing check", loop
for ref in reflist:
(obj, exit_status, output) = ref
#.........这里部分代码省略.........
开发者ID:mleinart,项目名称:shinken,代码行数:101,代码来源:shinken_test.py
示例7: Shinken
class Shinken(BaseSatellite):
properties = BaseSatellite.properties.copy()
properties.update({
'pidfile': PathProp(default='schedulerd.pid'),
'port': IntegerProp(default='7768'),
'local_log': PathProp(default='schedulerd.log'),
})
# Create the shinken class:
# Create a Pyro server (port = arvg 1)
# then create the interface for arbiter
# Then, it wait for a first configuration
def __init__(self, config_file, is_daemon, do_replace, debug, debug_file, profile=''):
BaseSatellite.__init__(self, 'scheduler', config_file, is_daemon, do_replace, debug, debug_file)
self.interface = IForArbiter(self)
self.istats = IStats(self)
self.sched = Scheduler(self)
self.ichecks = None
self.ibroks = None
self.must_run = True
# Now the interface
self.uri = None
self.uri2 = None
# And possible links for satellites
# from now only pollers
self.pollers = {}
self.reactionners = {}
self.brokers = {}
def do_stop(self):
if self.http_daemon:
if self.ibroks:
self.http_daemon.unregister(self.ibroks)
if self.ichecks:
self.http_daemon.unregister(self.ichecks)
super(Shinken, self).do_stop()
def compensate_system_time_change(self, difference):
""" Compensate a system time change of difference for all hosts/services/checks/notifs """
logger.warning("A system time change of %d has been detected. Compensating..." % difference)
# We only need to change some value
self.program_start = max(0, self.program_start + difference)
if not hasattr(self.sched, "conf"):
# Race condition where time change before getting conf
return
# Then we compensate all host/services
for h in self.sched.hosts:
h.compensate_system_time_change(difference)
for s in self.sched.services:
s.compensate_system_time_change(difference)
# Now all checks and actions
for c in self.sched.checks.values():
# Already launch checks should not be touch
if c.status == 'scheduled' and c.t_to_go is not None:
t_to_go = c.t_to_go
ref = c.ref
new_t = max(0, t_to_go + difference)
if ref.check_period is not None:
# But it's no so simple, we must match the timeperiod
new_t = ref.check_period.get_next_valid_time_from_t(new_t)
# But maybe no there is no more new value! Not good :(
# Say as error, with error output
if new_t is None:
c.state = 'waitconsume'
c.exit_status = 2
c.output = '(Error: there is no available check time after time change!)'
c.check_time = time.time()
c.execution_time = 0
else:
c.t_to_go = new_t
ref.next_chk = new_t
# Now all checks and actions
for c in self.sched.actions.values():
# Already launch checks should not be touch
if c.status == 'scheduled':
t_to_go = c.t_to_go
# Event handler do not have ref
ref = getattr(c, 'ref', None)
new_t = max(0, t_to_go + difference)
# Notification should be check with notification_period
if c.is_a == 'notification':
if ref.notification_period:
# But it's no so simple, we must match the timeperiod
new_t = ref.notification_period.get_next_valid_time_from_t(new_t)
# And got a creation_time variable too
c.creation_time = c.creation_time + difference
#.........这里部分代码省略.........
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:101,代码来源:schedulerdaemon.py
示例8: ShinkenTest
class ShinkenTest(unittest.TestCase):
def setUp(self):
self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
def setup_with_file(self, path):
# i am arbiter-like
self.broks = {}
self.me = None
self.log = logger
self.log.load_obj(self)
self.config_files = [path]
self.conf = Config()
self.conf.read_config(self.config_files)
buf = self.conf.read_config(self.config_files)
raw_objects = self.conf.read_config_buf(buf)
self.conf.create_objects_for_type(raw_objects, 'arbiter')
self.conf.create_objects_for_type(raw_objects, 'module')
self.conf.early_arbiter_linking()
self.conf.create_objects(raw_objects)
self.conf.instance_id = 0
self.conf.instance_name = 'test'
self.conf.linkify_templates()
self.conf.apply_inheritance()
self.conf.explode()
self.conf.create_reversed_list()
self.conf.remove_twins()
self.conf.apply_implicit_inheritance()
self.conf.fill_default()
self.conf.clean_useless()
self.conf.pythonize()
self.conf.linkify()
self.conf.apply_dependancies()
self.conf.explode_global_conf()
self.conf.propagate_timezone_option()
self.conf.create_business_rules()
self.conf.create_business_rules_dependencies()
self.conf.is_correct()
self.confs = self.conf.cut_into_parts()
self.dispatcher = Dispatcher(self.conf, self.me)
scheddaemon = Shinken(None, False, False, False, None)
self.sched = Scheduler(scheddaemon)
scheddaemon.sched = self.sched
m = MacroResolver()
m.init(self.conf)
self.sched.load_conf(self.conf)
e = ExternalCommandManager(self.conf, 'applyer')
self.sched.external_command = e
e.load_scheduler(self.sched)
e2 = ExternalCommandManager(self.conf, 'dispatcher')
e2.load_arbiter(self)
self.external_command_dispatcher = e2
self.sched.schedule()
def add(self, b):
if isinstance(b, Brok):
self.broks[b.id] = b
return
if isinstance(b, ExternalCommand):
self.sched.run_external_command(b.cmd_line)
def fake_check(self, ref, exit_status, output="OK"):
#print "fake", ref
now = time.time()
ref.schedule(force=True)
#now checks are schedule and we get them in
#the action queue
check = ref.actions.pop()
self.sched.add(check) # check is now in sched.checks[]
# fake execution
check.check_time = now
elts_line1 = output.split('|')
#First line before | is output
check.output = elts_line1[0]
#After | is perfdata
if len(elts_line1) > 1:
check.perf_data = elts_line1[1]
else:
check.perf_data = ''
check.exit_status = exit_status
check.execution_time = 0.001
check.status = 'waitconsume'
self.sched.waiting_results.append(check)
def scheduler_loop(self, count, reflist, do_sleep=False, sleep_time=61):
for ref in reflist:
(obj, exit_status, output) = ref
obj.checks_in_progress = []
for loop in range(1, count + 1):
print "processing check", loop
for ref in reflist:
(obj, exit_status, output) = ref
obj.update_in_checking()
self.fake_check(obj, exit_status, output)
#.........这里部分代码省略.........
开发者ID:zoranzaric,项目名称:shinken,代码行数:101,代码来源:shinken_test.py
示例9: Shinken
class Shinken(BaseSatellite):
properties = BaseSatellite.properties.copy()
properties.update({
'pidfile': PathProp(default='/usr/local/shinken/var/schedulerd.pid'),
'port': IntegerProp(default='7768'),
'local_log': PathProp(default='/usr/local/shinken/var/schedulerd.log'),
})
#Create the shinken class:
#Create a Pyro server (port = arvg 1)
#then create the interface for arbiter
#Then, it wait for a first configuration
def __init__(self, config_file, is_daemon, do_replace, debug, debug_file):
BaseSatellite.__init__(self, 'scheduler', config_file, is_daemon, do_replace, debug, debug_file)
self.interface = IForArbiter(self)
self.sched = Scheduler(self)
self.ichecks = None
self.ibroks = None
self.must_run = True
# Now the interface
self.uri = None
self.uri2 = None
# And possible links for satellites
# from now only pollers
self.pollers = {}
self.reactionners = {}
def do_stop(self):
self.pyro_daemon.unregister(self.ibroks)
self.pyro_daemon.unregister(self.ichecks)
super(Shinken, self).do_stop()
def compensate_system_time_change(self, difference):
""" Compensate a system time change of difference for all hosts/services/checks/notifs """
logger.log('Warning: A system time change of %d has been detected. Compensating...' % difference)
# We only need to change some value
self.program_start = max(0, self.program_start + difference)
# Then we compasate all host/services
for h in self.sched.hosts:
h.compensate_system_time_change(difference)
for s in self.sched.services:
s.compensate_system_time_change(difference)
# Now all checks and actions
for c in self.sched.checks.values():
# Already launch checks should not be touch
if c.status == 'scheduled':
t_to_go = c.t_to_go
ref = c.ref
new_t = max(0, t_to_go + difference)
# But it's no so simple, we must match the timeperiod
new_t = ref.check_period.get_next_valid_time_from_t(new_t)
# But maybe no there is no more new value! Not good :(
# Say as error, with error output
if new_t is None:
c.state = 'waitconsume'
c.exit_status = 2
c.output = '(Error: there is no available check time after time change!)'
c.check_time = time.time()
c.execution_time = 0
else:
c.t_to_go = new_t
ref.next_chk = new_t
# Now all checks and actions
for c in self.sched.actions.values():
# Already launch checks should not be touch
if c.status == 'scheduled':
t_to_go = c.t_to_go
# Event handler do not have ref
ref = getattr(c, 'ref', None)
new_t = max(0, t_to_go + difference)
# Notification should be check with notification_period
if c.is_a == 'notification':
# But it's no so simple, we must match the timeperiod
new_t = ref.notification_period.get_next_valid_time_from_t(new_t)
# And got a creation_time variable too
c.creation_time = c.creation_time + difference
# But maybe no there is no more new value! Not good :(
# Say as error, with error output
if new_t is None:
c.state = 'waitconsume'
c.exit_status = 2
c.output = '(Error: there is no available check time after time change!)'
c.check_time = time.time()
c.execution_time = 0
else:
#.........这里部分代码省略.........
开发者ID:zoranzaric,项目名称:shinken,代码行数:101,代码来源:schedulerdaemon.py
示例10: Shinken
class Shinken(BaseSatellite):
properties = BaseSatellite.properties.copy()
properties.update(
{
"pidfile": PathProp(default="schedulerd.pid"),
"port": IntegerProp(default="7768"),
"local_log": PathProp(default="schedulerd.log"),
}
)
# Create the shinken class:
# Create a Pyro server (port = arvg 1)
# then create the interface for arbiter
# Then, it wait for a first configuration
def __init__(self, config_file, is_daemon, do_replace, debug, debug_file):
BaseSatellite.__init__(self, "scheduler", config_file, is_daemon, do_replace, debug, debug_file)
self.interface = IForArbiter(self)
self.sched = Scheduler(self)
self.ichecks = None
self.ibroks = None
self.must_run = True
# Now the interface
self.uri = None
self.uri2 = None
# And possible links for satellites
# from now only pollers
self.pollers = {}
self.reactionners = {}
def do_stop(self):
if self.pyro_daemon:
if self.ibroks:
self.pyro_daemon.unregister(self.ibroks)
if self.ichecks:
self.pyro_daemon.unregister(self.ichecks)
super(Shinken, self).do_stop()
def compensate_system_time_change(self, difference):
""" Compensate a system time change of difference for all hosts/services/checks/notifs """
logger.log("Warning: A system time change of %d has been detected. Compensating..." % difference)
# We only need to change some value
self.program_start = max(0, self.program_start + difference)
# Then we compasate all host/services
for h in self.sched.hosts:
h.compensate_system_time_change(difference)
for s in self.sched.services:
s.compensate_system_time_change(difference)
# Now all checks and actions
for c in self.sched.checks.values():
# Already launch checks should not be touch
if c.status == "scheduled":
t_to_go = c.t_to_go
ref = c.ref
new_t = max(0, t_to_go + difference)
if ref.check_period is not None:
# But it's no so simple, we must match the timeperiod
new_t = ref.check_period.get_next_valid_time_from_t(new_t)
# But maybe no there is no more new value! Not good :(
# Say as error, with error output
if new_t is None:
c.state = "waitconsume"
c.exit_status = 2
c.output = "(Error: there is no available check time after time change!)"
c.check_time = time.time()
c.execution_time = 0
else:
c.t_to_go = new_t
ref.next_chk = new_t
# Now all checks and actions
for c in self.sched.actions.values():
# Already launch checks should not be touch
if c.status == "scheduled":
t_to_go = c.t_to_go
# Event handler do not have ref
ref = getattr(c, "ref", None)
new_t = max(0, t_to_go + difference)
# Notification should be check with notification_period
if c.is_a == "notification":
if ref.notification_period:
# But it's no so simple, we must match the timeperiod
new_t = ref.notification_period.get_next_valid_time_from_t(new_t)
# And got a creation_time variable too
c.creation_time = c.creation_time + difference
# But maybe no there is no more new value! Not good :(
# Say as error, with error output
if new_t is None:
c.state = "waitconsume"
c.exit_status = 2
#.........这里部分代码省略.........
开发者ID:jfbutkiewicz,项目名称:Windows-Setup-for-Shinken,代码行数:101,代码来源:schedulerdaemon.py
注:本文中的shinken.scheduler.Scheduler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论