diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index 5977129a1f94920333d29480f2e22a9121b89f81..5dcc4193cdf37f6b6aed54b567866cfab03f80bb 100644 --- a/include/opendht/dht_proxy_server.h +++ b/include/opendht/dht_proxy_server.h @@ -98,8 +98,10 @@ public: struct ServerStats { /** Current number of listen operations */ size_t listenCount {0}; - /** Current number of permanent put operations */ + /** Current number of permanent put operations (hash used) */ size_t putCount {0}; + /** Current number of permanent put values */ + size_t totalPermanentPuts {0}; /** Current number of push tokens with at least one listen operation */ size_t pushListenersCount {0}; /** Average requests per second */ @@ -129,6 +131,7 @@ public: Json::Value result; result["listenCount"] = static_cast<Json::UInt64>(listenCount); result["putCount"] = static_cast<Json::UInt64>(putCount); + result["totalPermanentPuts"] = static_cast<Json::UInt64>(totalPermanentPuts); result["pushListenersCount"] = static_cast<Json::UInt64>(pushListenersCount); result["requestRate"] = requestRate; if (nodeInfo) diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index 4ef34260448da6b546675cb55d3bb732757609a3..71c4831028d7ac15dbec640acb58b4cb12b6a154 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -555,6 +555,10 @@ DhtProxyServer::updateStats(std::shared_ptr<NodeInfo> info) const #ifdef OPENDHT_PUSH_NOTIFICATIONS stats.pushListenersCount = pushListeners_.size(); #endif + stats.totalPermanentPuts = 0; + std::for_each(puts_.begin(), puts_.end(), [&stats](const auto& put) { + stats.totalPermanentPuts += put.second.puts.size(); + }); stats.putCount = puts_.size(); stats.listenCount = listeners_.size(); stats.nodeInfo = std::move(info); @@ -1142,8 +1146,8 @@ DhtProxyServer::put(restinio::request_handle_t request, auto& sPuts = puts_[infoHash]; if (value->id == Value::INVALID_ID) { for (auto& pp : sPuts.puts) { - if (pp.second.pushToken == pushToken - and pp.second.clientId == clientId + if (pp.second.pushToken == pushToken + and pp.second.clientId == clientId and pp.second.value->contentEquals(*value)) { pp.second.expireTimer->expires_at(timeout); diff --git a/tools/dhtproxy_stats.py b/tools/dhtproxy_stats.py index 45625b0e9bf97b4147883bd12e3e91c07aa031e1..42b57ffe374d803e200bd2ed6600c590c9c0322c 100644 --- a/tools/dhtproxy_stats.py +++ b/tools/dhtproxy_stats.py @@ -7,7 +7,7 @@ stats_total = {"users":0, "pushListenersCount":0, "listenCount":0, "totalListene for i in range(80,101): print("Collecting stats for proxy " + str(i)) - response = requests.request('STATS', 'http://dhtproxy.jami.net:' + str(i)) + response = requests.request('STATS', 'http://127.0.0.1:' + str(i)) if response.status_code == 200: result = response.json() @@ -38,14 +38,11 @@ for i in range(80,101): except: pass try: - total = 0 - for h,v in result["puts"].items(): - total += int(v) - stats['totalPermanentPuts'] = total - stats_total['totalPermanentPuts'] += total + stats['totalPermanentPuts'] = int(result["totalPermanentPuts"]) + stats_total['totalPermanentPuts'] += int(result["totalPermanentPuts"]) except: pass - + stats['timestamp'] = str(ts) #with open("stats_proxy_" + str(i), "a") as stat_file: