Open rafaelcapucho opened 8 years ago
I have solved with it:
from datetime import datetime, timezone, timedelta
import gevent
def heartbeat(redis_conn, ip, hostname):
while True:
future = datetime.now(timezone.utc) + timedelta(seconds=6)
redis_conn.zadd(
'servers',
'{ip}-{hostname}'.format(ip=ip, hostname=hostname),
int(future.timestamp())
)
now = datetime.now(timezone.utc)
servers = redis_conn.zrangebyscore('servers', now.timestamp(), max='+inf')
print('servers: ', servers)
gevent.sleep(3)
Good enough, thank you
Hello,
I need to monitor which python server is online, I can send packages from those servers to redis like a heartbeat (pinging) but I can't filter in a BaseDay interval, when a server stop working it should me removed from the monitoring system asap.
It is a realtime distributed scrapy monitor, made with React:
redis-moment can help me? Thank you