aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authorrbrunner7 <rbrunner@dreamshare.ch>2019-03-21 11:03:24 +0100
committerrbrunner7 <rbrunner@dreamshare.ch>2019-03-24 16:58:57 +0100
commitc23ea7962debe4e66fd3c0e7719117dcb7966d1f (patch)
tree4627040783eac198cbcdde56e47a8e16c3a16b77 /src/rpc/core_rpc_server.cpp
parentMerge pull request #5201 (diff)
downloadmonero-c23ea7962debe4e66fd3c0e7719117dcb7966d1f.tar.xz
New interactive daemon command 'print_net_stats': Global traffic stats
Diffstat (limited to '')
-rw-r--r--src/rpc/core_rpc_server.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index ff55167fe..d976a052e 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -260,6 +260,23 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_get_net_stats(const COMMAND_RPC_GET_NET_STATS::request& req, COMMAND_RPC_GET_NET_STATS::response& res, const connection_context *ctx)
+ {
+ PERF_TIMER(on_get_net_stats);
+ // No bootstrap daemon check: Only ever get stats about local server
+ res.start_time = (uint64_t)m_core.get_start_time();
+ {
+ CRITICAL_REGION_LOCAL(epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_in);
+ epee::net_utils::network_throttle_manager::get_global_throttle_in().get_stats(res.total_packets_in, res.total_bytes_in);
+ }
+ {
+ CRITICAL_REGION_LOCAL(epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_out);
+ epee::net_utils::network_throttle_manager::get_global_throttle_out().get_stats(res.total_packets_out, res.total_bytes_out);
+ }
+ res.status = CORE_RPC_STATUS_OK;
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
class pruned_transaction {
transaction& tx;
public: