当前位置: 首页>>代码示例>>Python>>正文


Python Monitor.check方法代码示例

本文整理汇总了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)
开发者ID:lxhuang,项目名称:fetch_url,代码行数:9,代码来源:monitor_test.py

示例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)
开发者ID:waiverson,项目名称:HTTPMonitor,代码行数:20,代码来源:runner.py

示例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)
开发者ID:wellnesstelecom,项目名称:pony_monitor,代码行数:22,代码来源:runner.py

示例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")
开发者ID:lxhuang,项目名称:fetch_url,代码行数:53,代码来源:monitor_server.py

示例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
开发者ID:lxhuang,项目名称:fetch_url,代码行数:8,代码来源:monitor_test.py


注:本文中的monitor.Monitor.check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。