aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-02-28 08:21:45 +0000
committerChristian Grothoff <christian@grothoff.org>2008-02-28 08:21:45 +0000
commitbf1c767dafa51e951890c4ce4bb4b2c7d3865a41 (patch)
treeadfa36f83f72a1696e8205b131317d0c44b460e0
parent2bf7fd6e68e2b38e2987d8c2c2942a190b8ba5a3 (diff)
downloadgnunet-gtk-bf1c767dafa51e951890c4ce4bb4b2c7d3865a41.tar.gz
gnunet-gtk-bf1c767dafa51e951890c4ce4bb4b2c7d3865a41.zip
update to stats
-rw-r--r--src/plugins/stats/functions.c119
1 files changed, 67 insertions, 52 deletions
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index 06a9772c..71d46e08 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -76,7 +76,7 @@ getStatValue (unsigned long long *value,
76 } 76 }
77#if FUNCTIONS_DEBUG 77#if FUNCTIONS_DEBUG
78 GNUNET_GE_LOG (ectx, 78 GNUNET_GE_LOG (ectx,
79 GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER | GNUNET_GE_REQUEST, 79 GNUNET_GE_ERROR | GNUNET_GE_DEVELOPER | GNUNET_GE_ADMIN | GNUNET_GE_USER | GNUNET_GE_BULK,
80 "Statistic not found: `%s'\n", optName); 80 "Statistic not found: `%s'\n", optName);
81#endif 81#endif
82 return GNUNET_SYSERR; 82 return GNUNET_SYSERR;
@@ -358,70 +358,76 @@ getTrafficSendStats (const void *closure, gfloat ** data)
358 return GNUNET_OK; 358 return GNUNET_OK;
359} 359}
360 360
361static int
362getTrustStats (const void *closure, gfloat ** data)
363{
364 unsigned long long spent;
365 unsigned long long earned;
366 unsigned long long awarded;
367 unsigned long long lspent;
368 unsigned long long learned;
369 unsigned long long lawarded;
370 unsigned long long max;
371
372 if (GNUNET_OK != getStatValue (&spent,
373 &lspent, NULL, "# trust spent", GNUNET_YES))
374 return GNUNET_SYSERR;
375 if (GNUNET_OK != getStatValue (&earned,
376 &learned,
377 NULL, "# trust earned", GNUNET_YES))
378 return GNUNET_SYSERR;
379 if (GNUNET_OK != getStatValue (&awarded,
380 &lawarded,
381 NULL, "# gap total trust awarded", GNUNET_YES))
382 return GNUNET_SYSERR;
383 max = spent;
384 if (earned > max)
385 max = earned;
386 if (awarded > max)
387 max = awarded;
388 data[0][0] = 0.0;
389 if (max > 0)
390 {
391 data[0][0] = (1.0 * spent) / max;
392 data[0][1] = (1.0 * earned) / max;
393 data[0][2] = (1.0 * awarded) / max;
394 }
395 else
396 {
397 data[0][0] = 0.0;
398 data[0][1] = 0.0;
399 data[0][2] = 0.0;
400 }
401 return GNUNET_OK;
402}
361 403
362static int 404static int
363getEffectivenessStats (const void *closure, gfloat ** data) 405getEffectivenessStats (const void *closure, gfloat ** data)
364{ 406{
365 static GNUNET_CronTime last; 407 unsigned long long total; /* total number of queries passed on to remote */
366 static double lastdata; 408 unsigned long long success; /* responses forwarded (including local and remote) */
367 static double lastavg;
368 unsigned long long total;
369 unsigned long long success;
370 unsigned long long local;
371 unsigned long long ltotal; 409 unsigned long long ltotal;
372 unsigned long long lsuccess; 410 unsigned long long lsuccess;
373 unsigned long long llocal;
374 GNUNET_CronTime now;
375 411
376 now = GNUNET_get_time ();
377 if (now < last + 2 * GNUNET_CRON_MINUTES)
378 {
379 data[0][0] = lastdata;
380 data[0][1] = lastavg;
381 return GNUNET_OK;
382 }
383 last = now;
384 if (GNUNET_OK != getStatValue (&total, 412 if (GNUNET_OK != getStatValue (&total,
385 &ltotal, 413 &ltotal,
386 NULL, 414 NULL,
387 "# gap requests forwarded (counting each peer)", 415 "# gap requests total sent",
388 GNUNET_YES)) 416 GNUNET_YES))
389 return GNUNET_SYSERR; 417 return GNUNET_SYSERR;
390 if (GNUNET_OK != getStatValue (&success, 418 if (GNUNET_OK != getStatValue (&success,
391 &lsuccess, 419 &lsuccess,
392 NULL, "# gap routing successes (total)", 420 NULL, "# gap routes succeeded",
393 GNUNET_YES))
394 return GNUNET_SYSERR;
395 if (GNUNET_OK != getStatValue (&local,
396 &llocal,
397 NULL,
398 "# gap requests processed: local result",
399 GNUNET_YES)) 421 GNUNET_YES))
400 return GNUNET_SYSERR; 422 return GNUNET_SYSERR;
401 total -= ltotal; 423 if (total > 0)
402 data[0][0] = 0.0; 424 data[0][0] = 1.0 * success / total;
403 if (ltotal + total > 0)
404 {
405 data[0][1] = lastavg =
406 1.0 * (success + lsuccess - local - llocal) / (total + ltotal);
407 }
408 else 425 else
409 { 426 data[0][0] = 0.0;
410 data[0][1] = 0.0;
411 return GNUNET_OK;
412 }
413 if (total == 0)
414 return GNUNET_OK;
415 success -= lsuccess;
416 local -= llocal;
417 if (success <= local)
418 return GNUNET_OK;
419 success -= local;
420 lsuccess -= llocal;
421 data[0][0] = lastdata = 1.0 * success / total;
422 return GNUNET_OK; 427 return GNUNET_OK;
423} 428}
424 429
430
425static int 431static int
426statsProcessor (const char *optName, unsigned long long value, void *data) 432statsProcessor (const char *optName, unsigned long long value, void *data)
427{ 433{
@@ -687,12 +693,21 @@ StatEntry stats[] = {
687 } 693 }
688 , 694 ,
689 { 695 {
696 gettext_noop ("Trust"),
697 gettext_noop ("Spent (red) and Earned (green) Awarded (yellow)"),
698 &getTrustStats,
699 NULL,
700 3,
701 GNUNET_NO,
702 }
703 ,
704 {
690 gettext_noop ("Routing Effectiveness"), 705 gettext_noop ("Routing Effectiveness"),
691 gettext_noop 706 gettext_noop
692 ("Current (red) and average (green) effectiveness (100% = perfect)"), 707 ("Average (red) effectiveness (100% = perfect)"),
693 &getEffectivenessStats, 708 &getEffectivenessStats,
694 NULL, 709 NULL,
695 2, 710 1,
696 GNUNET_NO, 711 GNUNET_NO,
697 } 712 }
698 , 713 ,
@@ -728,7 +743,7 @@ init_functions (struct GNUNET_GE_Context *e,
728 GNUNET_cron_add_job (cron, 743 GNUNET_cron_add_job (cron,
729 &updateStatValues, UPDATE_INTERVAL, UPDATE_INTERVAL, 744 &updateStatValues, UPDATE_INTERVAL, UPDATE_INTERVAL,
730 NULL); 745 NULL);
731 GNUNET_cron_add_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_MINUTES, 746 GNUNET_cron_add_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_SECONDS,
732 5 * GNUNET_CRON_MINUTES, NULL); 747 5 * GNUNET_CRON_MINUTES, NULL);
733} 748}
734 749