Open fivetime opened 3 years ago
Sure, why not! Can you give examples of software you know that do similar things, so that I don’t reinvent the wheel?
I don't find any similar software, my requirement is to query all the upstream and downstream traffic of rinetd through API.
For example: rinetd.conf configure a line of manager addr and port, and then rinetd starts udp monitoring to receive the query command. After receiving the query command, the upstream and downlink traffic data is sent to the requestor by udp.
rinetd.conf
manager 127.0.0.1:8000
command protocol:
Send udp request: stat
Respond to Json: stat: {"up": 11370, "down": 12345}
import socket
cli = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
cli.sendto('stat', '127.0.0.1:8000')
print(cli.recv(8000)) # You'll receive 'stat: {"up": 11370, "down": 12345}'
echo "stat" | socat - udp4-datagram:127.0.0.1:8000
The console will output stat: {"up": 11370, "down": 12345}
It is recommended to use udp protocol to provide traffic query. If you use http api, then you need to import the http framework, the program is too large, it will affect performance.
Can you add a Http or Socket query interface for total upstream and downstream traffic?