Browse Source

add libtorrent's session status data to getinfo output

miguelfreitas
Denis Ryabov 10 years ago
parent
commit
7271692310
  1. 4
      src/rpcwallet.cpp
  2. 34
      src/twister.cpp
  3. 3
      src/twister.h

4
src/rpcwallet.cpp

@ -99,6 +99,10 @@ Value getinfo(const Array& params, bool fHelp) @@ -99,6 +99,10 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("public_server_mode", GetBoolArg("-public_server_mode",false)));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
}
Object torrent_stats = getLibtorrentSessionStatus();
obj.insert( obj.end(), torrent_stats.begin(), torrent_stats.end() );
return obj;
}

34
src/twister.cpp

@ -2333,3 +2333,37 @@ Value torrentstatus(const Array& params, bool fHelp) @@ -2333,3 +2333,37 @@ Value torrentstatus(const Array& params, bool fHelp)
return result;
}
Object getLibtorrentSessionStatus()
{
Object obj;
boost::shared_ptr<session> ses(m_ses);
if( ses ) {
session_status stats = ses->status();
obj.push_back( Pair("dht_torrents", stats.dht_torrents) );
obj.push_back( Pair("num_peers", stats.num_peers) );
obj.push_back( Pair("peerlist_size", stats.peerlist_size) );
obj.push_back( Pair("num_active_requests", stats.active_requests.size()) );
obj.push_back( Pair("download_rate", stats.download_rate) );
obj.push_back( Pair("upload_rate", stats.upload_rate) );
obj.push_back( Pair("dht_download_rate", stats.dht_download_rate) );
obj.push_back( Pair("dht_upload_rate", stats.dht_upload_rate) );
obj.push_back( Pair("ip_overhead_download_rate", stats.ip_overhead_download_rate) );
obj.push_back( Pair("ip_overhead_upload_rate", stats.ip_overhead_upload_rate) );
obj.push_back( Pair("payload_download_rate", stats.payload_download_rate) );
obj.push_back( Pair("payload_upload_rate", stats.payload_upload_rate) );
obj.push_back( Pair("total_download", stats.total_download) );
obj.push_back( Pair("total_upload", stats.total_upload) );
obj.push_back( Pair("total_dht_download", stats.total_dht_download) );
obj.push_back( Pair("total_dht_upload", stats.total_dht_upload) );
obj.push_back( Pair("total_ip_overhead_download", stats.total_ip_overhead_download) );
obj.push_back( Pair("total_ip_overhead_upload", stats.total_ip_overhead_upload) );
obj.push_back( Pair("total_payload_download", stats.total_payload_download) );
obj.push_back( Pair("total_payload_upload", stats.total_payload_upload) );
}
// @TODO: Is there a way to get some statistics for dhtProxy?
return obj;
}

3
src/twister.h

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "util.h"
#include "key.h"
#include <boost/thread.hpp>
#include "json/json_spirit.h"
#define LIBTORRENT_PORT_OFFSET 1000
@ -52,4 +53,6 @@ void dhtPutData(std::string const &username, std::string const &resource, bool m @@ -52,4 +53,6 @@ void dhtPutData(std::string const &username, std::string const &resource, bool m
void dhtPutDataSigned(std::string const &username, std::string const &resource, bool multi,
libtorrent::entry const &p, std::string const &sig_p, std::string const &sig_user, bool local);
json_spirit::Object getLibtorrentSessionStatus();
#endif // TWISTER_H

Loading…
Cancel
Save