rakshasa / rtorrent

rTorrent BitTorrent client
https://github.com/rakshasa/rtorrent/wiki
GNU General Public License v2.0
4.15k stars 414 forks source link

Script/command to get rtorrent status #1227

Closed zmechu closed 1 year ago

zmechu commented 1 year ago

Hello!

Is there a kind of command/script, to get status of rtorrent? I'm interesting in monitoring such status data as "download speed", "upload speed", "active torrents" and "complete torrents" count - and so on. Hope it is possible via RPC2 querying, but can't handle it till now...

buggsi commented 1 year ago

Here's a little snippet in python. It doesn't show the download/upload speed though, I haven't figured out how to get those, the rtorrent documentation is very old and badly maintained. There are these methods in the RPC1 api for the server stats, get_down_rate() get_up_rate() get_down_total() and get_up_total(), however they are removed in RPC2, possibly replaced by download_rate() and upload_rate() but I can't get those to work.

import xmlrpc.client
server= xmlrpc.client.Server('http://user:password@hostname:port/RPC2', verbose=False)

for opt in ['main', 'name', 'started', 'stopped', 'complete', 'incomplete', 'hashing', 'seeding', 'leeching', 'active']:
    print(opt, len(server.download_list("", opt)))

Outputs something like this:

main 720
name 720
started 666
stopped 54
complete 693
incomplete 27
hashing 0
seeding 664
leeching 2
active 666
kannibalox commented 1 year ago

I support a python project with support for calling rtorrent directly: https://kannibalox.github.io/pyrosimple/, and the docs have an example of both a bash and python script to do this: https://kannibalox.github.io/pyrosimple/tips/#instance-statistics

Here's a little snippet in python. It doesn't show the download/upload speed though, I haven't figured out how to get those, the rtorrent documentation is very old and badly maintained. There are these methods in the RPC1 api for the server stats, get_down_rate() get_up_rate() get_down_total() and get_up_total(), however they are removed in RPC2, possibly replaced by download_rate() and upload_rate() but I can't get those to work.

There is no RPC1 vs RPC2 distinction in rtorrent (/RPC2 is simply a standard HTTP path for XMLRPC endpoints), those commands were deprecated in version 0.7.0 and finally removed in 0.9.7: https://github.com/rakshasa/rtorrent/commit/51c5190eb1b630c1066fbb555d894a26ae0dd95f. https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html is currently the most comprehensive list of commands.