I have modified it a little bit, but this version now works on Debian 9:
Code: Select all
#!/usr/bin/perl
# transmission-remote http://127.0.0.1:9091/asm/transmission/rpc -st
# Unfortunately uploaded and downloaded is displayed in GB, TB, not bytes
# apt install libjson-rpc-perl
# apt-get remove --purge libjson-rpc-perl
# wget http://ftp.de.debian.org/debian/pool/main/libj/libjson-rpc-perl/libjson-rpc-perl_0.96-3_all.deb
# dpkg --install libjson-rpc-perl_0.96-3_all.deb
use strict;
use JSON::RPC::Client;
use JSON;
my $username = $ENV{'username'} || '';
my $password = $ENV{'password'} || '';
my $host = $ENV{'host'} || '127.0.0.1';
my $port = $ENV{'port'} || 9091;
my $uri = "http://$host:$port/asm/transmission/rpc";
my $client = new JSON::RPC::Client;
my @content;
$client->ua->credentials("$host:$port",'Transmission',$username,$password);
$content[0] = $client->ua->get($uri)->content;
@content = split('<code>X-Transmission-Session-Id: ',$content[0]);
@content = split('</code>',$content[1]);
$client->ua->default_header('X-Transmission-Session-Id'=>"$content[0]");
my $obj = {
method => 'session-stats',
arguments => {}
};
my $res = $client->call( $uri, $obj ) || die $! . " $uri\n";
printf("Uploaded bytes: %d\n", $res->content->{'arguments'}->{'cumulative-stats'}->{'uploadedBytes'});
printf("Downloaded bytes: %d\n", $res->content->{'arguments'}->{'cumulative-stats'}->{'downloadedBytes'});
exit 0;
The problem is, that when running the script quite often, I get the same numbers printed at Uploaded bytes: and Downloaded bytes:.
It seems that there is no change also in the file /var/lib/transmission-daemon/info/stats.json
But checking the state of the daemon via the web interface, I see, that the daemon is uploading with a speed of 70 - 80 kbytes / sec.
How frequently is updated the session-stats of the rpc?
How frequently is updated /var/lib/transmission-daemon/info/stats.json?
thanks in advance!