25 lines
581 B
Python
25 lines
581 B
Python
import asyncio
|
|
import random
|
|
|
|
random.seed(1)
|
|
|
|
SERVERS = [
|
|
"api.database.local",
|
|
"auth.backend.local",
|
|
"web.frontend.local",
|
|
"cache.redis.local",
|
|
"analytics.bigdata.local"
|
|
]
|
|
|
|
STATUSES = ["Online", "Offline", "Maintenance", "Error"]
|
|
|
|
async def monitor_servers(servers):
|
|
for server in servers:
|
|
await asyncio.sleep(.1)
|
|
yield (server, random.choice(STATUSES))
|
|
|
|
async def main():
|
|
async for server_name, server_status in monitor_servers(SERVERS):
|
|
print(f'{server_name}: состояние {server_status}')
|
|
|
|
asyncio.run(main())
|