-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprober.py
29 lines (26 loc) · 879 Bytes
/
prober.py
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
28
29
import json
import asyncio
import logging
async def run(conf):
yarrp_command = [
'/yarrp/yarrp',
'-o', conf['prober']['tmp_output_file'],
'-i', conf['prober']['targets_file'],
'-r', str(conf['prober']['probe_rate']),
'-t', conf['prober']['probe_type'],
'-v',
'-m', str(conf['prober']['max_ttl']),
]
command = ' '.join(yarrp_command)
logging.info(f"Executing command: {command}")
process = await asyncio.create_subprocess_shell(
command,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
logging.info("Execution completed")
if process.returncode == 0:
logging.info(f'Command succeeded: {stdout.decode()}')
else:
logging.info(f'Command returned unexpected code: {stderr.decode()}')