From 56f06d4ff630d3d61b1dbeb6e7d1ae293d4c607a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 13 Mar 2010 11:17:04 +0000 Subject: [PATCH] more stats --- TODO | 1 - src/Makefile.am | 2 +- src/peerinfo/Makefile.am | 1 + src/peerinfo/gnunet-service-peerinfo.c | 16 ++++++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index e0022741a..d5ffde68e 100644 --- a/TODO +++ b/TODO @@ -33,7 +33,6 @@ away), in order in which they will likely be done: - synchronous/asynchronous API (& implementation) is not nice; => provide notification-based API - does not seem to work with timeouts (especially if service is not running) - - add stats to peerinfo (# peers tracked) - add stats to fs service (# queries, # replies, # routed, # found, # pending) - add stats to dvstore (# bytes available, # bytes used, # PUTs, # GETs, # GETs satisfied) * ARM: diff --git a/src/Makefile.am b/src/Makefile.am index 11912b2e2..4d63bc756 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,10 +14,10 @@ endif SUBDIRS = \ include $(INTLEMU_SUBDIRS) \ util \ + statistics \ arm \ hello \ peerinfo \ - statistics \ datacache \ datastore \ template \ diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am index 7512552d0..ea7ef1316 100644 --- a/src/peerinfo/Makefile.am +++ b/src/peerinfo/Makefile.am @@ -36,6 +36,7 @@ gnunet_service_peerinfo_SOURCES = \ gnunet-service-peerinfo.c gnunet_service_peerinfo_LDADD = \ $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 703ebee4c..b23d3318e 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -37,6 +37,7 @@ #include "gnunet_hello_lib.h" #include "gnunet_protocols.h" #include "gnunet_service_lib.h" +#include "gnunet_statistics_service.h" #include "peerinfo.h" /** @@ -108,6 +109,11 @@ static char *networkIdDirectory; */ static char *trustDirectory; +/** + * Handle for reporting statistics. + */ +static struct GNUNET_STATISTICS_Handle *stats; + /** * Notify all clients in the notify list about the @@ -251,6 +257,10 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) entry = lookup_host_entry (identity); if (entry != NULL) return; + GNUNET_STATISTICS_update (stats, + gettext_noop ("# peers known"), + 1, + GNUNET_NO); entry = GNUNET_malloc (sizeof (struct HostEntry)); entry->identity = *identity; fn = get_trust_filename (identity); @@ -763,6 +773,11 @@ shutdown_task (void *cls, { GNUNET_SERVER_notification_context_destroy (notify_list); notify_list = NULL; + if (stats != NULL) + { + GNUNET_STATISTICS_destroy (stats, GNUNET_YES); + stats = NULL; + } } @@ -780,6 +795,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { + stats = GNUNET_STATISTICS_create (sched, "statistics", cfg); notify_list = GNUNET_SERVER_notification_context_create (server, 0); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, -- 2.25.1