本文整理汇总了Python中monitor.Monitor.check方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.check方法的具体用法?Python Monitor.check怎么用?Python Monitor.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.check方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: random_tester
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import check [as 别名]
def random_tester():
monitor = Monitor()
while True:
user = random.randint(1,30)
if not monitor.check(str(user)):
print "malicious user detected"
time.sleep(0.05)
示例2: main
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import check [as 别名]
def main():
logging.basicConfig(level=logging.INFO,
format="%(asctime)s %(levelname)s MODULE:%(module)s LineNO:%(lineno)d %(message)s",
stream=sys.stdout)
timeout = getattr(settings, "TIMEOUT", DEFAULT_TIMEOUT)
check_inv = getattr(settings, "CHECK_INTERVAL", DEFAULT_INTERVAL)
# callback_url = getattr(settings, "CALLBACK_URL", None)
monitor = Monitor(settings.NOTICATION, settings.HANDLER, timeout)
try:
while True:
monitor.check(settings.CHECK_URL, settings.RETRY_COUNT)
time.sleep(check_inv)
except KeyboardInterrupt:
pass
except Exception, e:
logging.error(e)
示例3: main
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import check [as 别名]
def main():
from conf import settings
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s',
stream=sys.stdout);
timeout = getattr(settings, 'TIMEOUT', DEFAULT_TIMEOUT)
check_time = getattr(settings, 'CHECK_INTERVAL', DEFAULT_INTERVAL)
monitor = Monitor(settings.ALERT_BACKENDS, timeout)
try:
while True:
monitor.check(settings.URLS_TO_CHECK)
time.sleep(check_time)
except KeyboardInterrupt:
pass
except Exception, e:
logging.error(e)
示例4: main
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import check [as 别名]
def main():
argc = len(sys.argv)
if argc < 2:
print "usage: python monitor_server port"
return
else:
server_port = int(sys.argv[1])
monitor = Monitor()
context = zmq.Context()
# monitor server
server = context.socket(zmq.ROUTER)
server.bind("tcp://*:" + str(server_port))
# heartbeat
heartbeat = context.socket(zmq.ROUTER)
heartbeat.bind("tcp://*:" + str(server_port+1))
poller = zmq.Poller()
poller.register(server, zmq.POLLIN)
poller.register(heartbeat, zmq.POLLIN)
while True:
socks = dict(poller.poll())
if socks.get(server) == zmq.POLLIN:
addr = server.recv()
tmp = server.recv()
data = server.recv()
print data
server.send(addr, zmq.SNDMORE)
server.send("", zmq.SNDMORE)
if monitor.check(data):
server.send("pass")
else:
server.send("fail")
elif socks.get(heartbeat) == zmq.POLLIN:
addr = heartbeat.recv()
tmp = heartbeat.recv()
data = heartbeat.recv()
print "heartbeat"
heartbeat.send(addr, zmq.SNDMORE)
heartbeat.send("", zmq.SNDMORE)
heartbeat.send("live")
示例5: load_tester
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import check [as 别名]
def load_tester():
count = 1
monitor = Monitor()
while True:
monitor.check(str(count))
count = count + 1