-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtasks.py
More file actions
27 lines (23 loc) · 745 Bytes
/
tasks.py
File metadata and controls
27 lines (23 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import subprocess
from logger import logger
async def ping(message, name, ip, port):
logger.info(f'name {name} / ip {ip}')
result = subprocess.run(
f"ping -c 1 -W 10 {ip}".split(),
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
if result.returncode != 0:
logger.info(f'name {name} / ip {ip}')
await message.reply(text=f"{name} with ip:{ip} goes down.")
return
async def wget(message, name, ip, port):
result = subprocess.run(
f"wget -nv -O - {ip}:{port}".split(),
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
if result.returncode != 0:
await message.reply(text=f"{name} with ip:{ip} goes down.")
return