bundles/transmission: add telegraf statistics
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit

This commit is contained in:
Franzi 2021-05-19 20:12:52 +02:00
parent 3b3bdeecab
commit df192e543b
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 65 additions and 2 deletions

View file

@ -0,0 +1,34 @@
#!/usr/bin/env python3
from transmission_rpc import Client
c = Client(host='127.0.0.1', port=${rpc_port})
torrents = c.get_torrents()
total_progress = 0
total_available = 0
total_upload = 0
total_download = 0
for torrent in torrents:
name = torrent.name.replace(' ', '\\ ')
print(f'transmission,type=detail,name={name} percent_done={torrent.progress}')
print(f'transmission,type=detail,name={name} percent_avail={torrent.available}')
print(f'transmission,type=detail,name={name} ratio={torrent.ratio}')
print(f'transmission,type=detail,name={name} size={torrent.total_size}')
print(f'transmission,type=detail,name={name} upload={torrent.rateUpload}')
print(f'transmission,type=detail,name={name} download={torrent.rateDownload}')
total_progress += torrent.progress
total_available += torrent.available
total_upload += torrent.rateUpload
total_download += torrent.rateDownload
total_progress_pct = round((total_progress/(len(torrents)*100))*100, 3)
total_available_pct = round((total_available/(len(torrents)*100))*100, 3)
print(f'transmission,type=global num_torrents={len(torrents)}')
print(f'transmission,type=global percent_done={total_progress_pct}')
print(f'transmission,type=global percent_avail={total_available_pct}')
print(f'transmission,type=global upload={total_upload}')
print(f'transmission,type=global download={total_download}')