2016-10-26 00:34:47 +02:00
|
|
|
#!/bin/sh
|
2016-10-26 02:04:11 +02:00
|
|
|
# -*- sh -*-
|
2012-08-07 07:16:31 +02:00
|
|
|
|
2016-10-26 02:04:11 +02:00
|
|
|
: <<=cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
tr_ratios - monitor transfer ratios of the "transmission" bittorent program
|
|
|
|
|
|
|
|
=head1 APPLICABLE SYSTEMS
|
|
|
|
|
|
|
|
Any system with "transmission" installed and a transmission daemon running.
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
Maybe you need to configure access credentials and connection settings:
|
|
|
|
|
|
|
|
[tr_ratios]
|
|
|
|
env.host localhost
|
|
|
|
env.port 9091
|
|
|
|
env.username alice
|
|
|
|
env.password secret
|
|
|
|
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
unspecified
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
unspecified
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
2012-08-07 07:16:31 +02:00
|
|
|
|
2016-10-26 02:23:06 +02:00
|
|
|
CONNECTION_ARG="${host:-localhost}:${port:-9091}"
|
|
|
|
USERNAME="${username:-}"
|
|
|
|
PASSWORD="${password:-}"
|
|
|
|
|
|
|
|
|
|
|
|
# return a space separated list of transmissions with the following columns:
|
|
|
|
# * fieldname
|
|
|
|
# * ratio (in percent)
|
|
|
|
# * name of the transmissions
|
|
|
|
request_transmission_stats() {
|
|
|
|
if [ -n "$USERNAME$PASSWORD" ]; then
|
|
|
|
transmission-remote "$CONNECTION_ARG" --auth "$USERNAME:$PASSWORD" --list
|
|
|
|
else
|
|
|
|
transmission-remote "$CONNECTION_ARG" --list
|
|
|
|
fi | awk '
|
2016-10-26 00:38:07 +02:00
|
|
|
BEGIN { FIELDWIDTHS = "7 4 13 10 7 9 7 13 40" }
|
|
|
|
NR > 1 {
|
|
|
|
split($1,torrentid," ")
|
2016-10-26 02:23:06 +02:00
|
|
|
# remove "*" from the ID of stopped transmissions
|
|
|
|
sub(/\*/, "", torrentid[1])
|
2016-10-26 00:38:07 +02:00
|
|
|
if (torrentid[1] != "Sum:") {
|
2016-10-26 02:23:06 +02:00
|
|
|
split($7,ratio," ")
|
|
|
|
ratio[1] = ratio[1] * 100
|
|
|
|
print "ID" torrentid[1], ratio[1], $9
|
2016-10-26 00:38:07 +02:00
|
|
|
}
|
2016-10-26 02:23:06 +02:00
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
if [ -n "$(request_transmission_stats 2>/dev/null)" ]; then
|
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
if which transmission-remote >/dev/null; then
|
|
|
|
echo "no (failed to connect to daemon)"
|
|
|
|
else
|
|
|
|
echo "no (missing 'transmission-remote' program)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo "graph_title Transmission seed ratios"
|
|
|
|
echo "graph_vlabel Seed ratio %"
|
2017-02-24 19:50:15 +01:00
|
|
|
echo "graph_category filetransfer"
|
2016-10-26 02:23:06 +02:00
|
|
|
echo "graph_info This plugin shows your transmission ratios per torrent"
|
|
|
|
request_transmission_stats | awk '{print $1 ".label " $3 }' | iconv -f utf-8 -t ascii//translit
|
2012-08-07 07:16:31 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-10-26 02:23:06 +02:00
|
|
|
request_transmission_stats | awk '{print $1 ".value " $2 }'
|