diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-12-08 01:07:47 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-12-08 01:07:47 +0000 |
commit | d69a8a6b0bb0a51d6239bda10f4b693f4dadcb22 (patch) | |
tree | ceb5a475ad1b325be50e114a8a4733d9aee1d97d /src/nse | |
parent | 7c2e00ab0f1b2f266c9bcf96c784a289daaec4c7 (diff) | |
download | gnunet-d69a8a6b0bb0a51d6239bda10f4b693f4dadcb22.tar.gz gnunet-d69a8a6b0bb0a51d6239bda10f4b693f4dadcb22.zip |
- Added periodic transport & nse stats data logging
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 37e5ecfbd..078628faa 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -42,6 +42,8 @@ struct NSEPeer | |||
42 | struct GNUNET_NSE_Handle *nse_handle; | 42 | struct GNUNET_NSE_Handle *nse_handle; |
43 | 43 | ||
44 | struct GNUNET_STATISTICS_Handle *stats; | 44 | struct GNUNET_STATISTICS_Handle *stats; |
45 | |||
46 | GNUNET_SCHEDULER_TaskIdentifier stats_task; | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | 49 | ||
@@ -123,6 +125,11 @@ static struct GNUNET_DISK_FileHandle *data_file; | |||
123 | static struct GNUNET_TIME_Relative wait_time; | 125 | static struct GNUNET_TIME_Relative wait_time; |
124 | 126 | ||
125 | /** | 127 | /** |
128 | * NSE interval. | ||
129 | */ | ||
130 | static struct GNUNET_TIME_Relative interval; | ||
131 | |||
132 | /** | ||
126 | * Task called to disconnect peers. | 133 | * Task called to disconnect peers. |
127 | */ | 134 | */ |
128 | static GNUNET_SCHEDULER_TaskIdentifier disconnect_task; | 135 | static GNUNET_SCHEDULER_TaskIdentifier disconnect_task; |
@@ -249,7 +256,7 @@ core_stats_iterator (void *cls, const char *subsystem, const char *name, | |||
249 | if (output_file != NULL) | 256 | if (output_file != NULL) |
250 | { | 257 | { |
251 | size = | 258 | size = |
252 | GNUNET_asprintf (&output_buffer, "%s -> %s [%s]: %llu\n", | 259 | GNUNET_asprintf (&output_buffer, "%s [%s] %s %llu\n", |
253 | GNUNET_i2s (&peer->daemon->id), | 260 | GNUNET_i2s (&peer->daemon->id), |
254 | subsystem, name, value); | 261 | subsystem, name, value); |
255 | if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) | 262 | if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) |
@@ -278,15 +285,24 @@ static void | |||
278 | core_get_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 285 | core_get_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
279 | { | 286 | { |
280 | struct NSEPeer *peer = cls; | 287 | struct NSEPeer *peer = cls; |
288 | |||
289 | peer->stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
281 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 290 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
282 | { | 291 | { |
283 | GNUNET_STATISTICS_destroy(peer->stats, GNUNET_YES); | 292 | GNUNET_STATISTICS_destroy(peer->stats, GNUNET_NO); |
293 | peer->stats = NULL; | ||
284 | } | 294 | } |
285 | else | 295 | else |
286 | { | 296 | { |
287 | GNUNET_STATISTICS_get(peer->stats, "core", NULL, | 297 | GNUNET_STATISTICS_get(peer->stats, "core", NULL, |
288 | GNUNET_TIME_UNIT_FOREVER_REL, | 298 | GNUNET_TIME_UNIT_FOREVER_REL, |
289 | &core_stats_cont, &core_stats_iterator, peer); | 299 | &core_stats_cont, &core_stats_iterator, peer); |
300 | GNUNET_STATISTICS_get(peer->stats, "transport", NULL, | ||
301 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
302 | NULL, &core_stats_iterator, peer); | ||
303 | GNUNET_STATISTICS_get(peer->stats, "nse", NULL, | ||
304 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
305 | NULL, &core_stats_iterator, peer); | ||
290 | } | 306 | } |
291 | } | 307 | } |
292 | 308 | ||
@@ -301,8 +317,8 @@ static void | |||
301 | core_stats_cont (void *cls, int success) | 317 | core_stats_cont (void *cls, int success) |
302 | { | 318 | { |
303 | struct NSEPeer *peer = cls; | 319 | struct NSEPeer *peer = cls; |
304 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 320 | peer->stats_task = GNUNET_SCHEDULER_add_delayed (interval, &core_get_stats, |
305 | &core_get_stats, peer); | 321 | peer); |
306 | } | 322 | } |
307 | 323 | ||
308 | 324 | ||
@@ -337,11 +353,14 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
337 | GNUNET_assert (current_peer->nse_handle != NULL); | 353 | GNUNET_assert (current_peer->nse_handle != NULL); |
338 | } | 354 | } |
339 | current_peer->stats = GNUNET_STATISTICS_create("profiler", current_peer->daemon->cfg); | 355 | current_peer->stats = GNUNET_STATISTICS_create("profiler", current_peer->daemon->cfg); |
340 | GNUNET_STATISTICS_get(current_peer->stats, "core", NULL, GNUNET_TIME_UNIT_FOREVER_REL, | 356 | GNUNET_STATISTICS_get(current_peer->stats, "core", NULL, |
357 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
341 | &core_stats_cont, &core_stats_iterator, current_peer); | 358 | &core_stats_cont, &core_stats_iterator, current_peer); |
342 | GNUNET_STATISTICS_get(current_peer->stats, "transport", NULL, GNUNET_TIME_UNIT_FOREVER_REL, | 359 | GNUNET_STATISTICS_get(current_peer->stats, "transport", NULL, |
360 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
343 | NULL, &core_stats_iterator, current_peer); | 361 | NULL, &core_stats_iterator, current_peer); |
344 | GNUNET_STATISTICS_get(current_peer->stats, "nse", NULL, GNUNET_TIME_UNIT_FOREVER_REL, | 362 | GNUNET_STATISTICS_get(current_peer->stats, "nse", NULL, |
363 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
345 | NULL, &core_stats_iterator, current_peer); | 364 | NULL, &core_stats_iterator, current_peer); |
346 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); | 365 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); |
347 | } | 366 | } |
@@ -429,6 +448,10 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
429 | pos->nse_handle = NULL; | 448 | pos->nse_handle = NULL; |
430 | } | 449 | } |
431 | GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); | 450 | GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); |
451 | if (NULL != pos->stats) | ||
452 | GNUNET_STATISTICS_destroy(pos->stats, GNUNET_NO); | ||
453 | if (GNUNET_SCHEDULER_NO_TASK != pos->stats_task) | ||
454 | GNUNET_SCHEDULER_cancel (pos->stats_task); | ||
432 | GNUNET_free (pos); | 455 | GNUNET_free (pos); |
433 | } | 456 | } |
434 | 457 | ||
@@ -653,6 +676,15 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
653 | } | 676 | } |
654 | 677 | ||
655 | if (GNUNET_OK != | 678 | if (GNUNET_OK != |
679 | GNUNET_CONFIGURATION_get_value_time (testing_cfg, "nse", | ||
680 | "INTERVAL", &interval)) | ||
681 | { | ||
682 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
683 | "Option nse:interval is required!\n"); | ||
684 | return; | ||
685 | } | ||
686 | |||
687 | if (GNUNET_OK != | ||
656 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", | 688 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", |
657 | "connection_limit", | 689 | "connection_limit", |
658 | &connection_limit)) | 690 | &connection_limit)) |