本文整理汇总了Python中shinken.scheduler.Scheduler.run方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.run方法的具体用法?Python Scheduler.run怎么用?Python Scheduler.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shinken.scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Shinken
# 需要导入模块: from shinken.scheduler import Scheduler [as 别名]
# 或者: from shinken.scheduler.Scheduler import run [as 别名]
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:
#.........这里部分代码省略.........
示例2: Shinken
# 需要导入模块: from shinken.scheduler import Scheduler [as 别名]
# 或者: from shinken.scheduler.Scheduler import run [as 别名]
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
#.........这里部分代码省略.........
示例3: Shinken
# 需要导入模块: from shinken.scheduler import Scheduler [as 别名]
# 或者: from shinken.scheduler.Scheduler import run [as 别名]
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
#.........这里部分代码省略.........