aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/functions.c')
-rw-r--r--src/statistics/functions.c321
1 files changed, 149 insertions, 172 deletions
diff --git a/src/statistics/functions.c b/src/statistics/functions.c
index 143860e7..129caada 100644
--- a/src/statistics/functions.c
+++ b/src/statistics/functions.c
@@ -50,8 +50,7 @@ static struct GNUNET_GC_Configuration *cfg;
50static struct GNUNET_CronManager *cron; 50static struct GNUNET_CronManager *cron;
51 51
52static int 52static int
53getStatValue (unsigned long long *value, 53getStatValue (unsigned long long *value, unsigned long long *lvalue,
54 unsigned long long *lvalue,
55 GNUNET_CronTime * dtime, const char *optName, int monotone) 54 GNUNET_CronTime * dtime, const char *optName, int monotone)
56{ 55{
57 unsigned int i; 56 unsigned int i;
@@ -60,25 +59,24 @@ getStatValue (unsigned long long *value,
60 if (lvalue != NULL) 59 if (lvalue != NULL)
61 *lvalue = 0; 60 *lvalue = 0;
62 for (i = 0; i < lsv_size; i++) 61 for (i = 0; i < lsv_size; i++)
62 {
63 if (0 == strcmp (optName, lastStatValues[i].statName))
63 { 64 {
64 if (0 == strcmp (optName, lastStatValues[i].statName)) 65 *value = lastStatValues[i].value;
65 { 66 if (lvalue != NULL)
66 *value = lastStatValues[i].value; 67 *lvalue = lastStatValues[i].lvalue;
67 if (lvalue != NULL) 68 if (dtime != NULL)
68 *lvalue = lastStatValues[i].lvalue; 69 *dtime = lastStatValues[i].delta;
69 if (dtime != NULL) 70 if ((monotone == GNUNET_YES) && (lvalue != NULL) && (*lvalue > *value))
70 *dtime = lastStatValues[i].delta; 71 return GNUNET_SYSERR; /* gnunetd restart? */
71 if ((monotone == GNUNET_YES) && (lvalue != NULL) 72 return GNUNET_OK;
72 && (*lvalue > *value))
73 return GNUNET_SYSERR; /* gnunetd restart? */
74 return GNUNET_OK;
75 }
76 } 73 }
74 }
77#if FUNCTIONS_DEBUG 75#if FUNCTIONS_DEBUG
78 GNUNET_GE_LOG (ectx, 76 GNUNET_GE_LOG (ectx,
79 GNUNET_GE_ERROR | GNUNET_GE_DEVELOPER | GNUNET_GE_ADMIN | 77 GNUNET_GE_ERROR | GNUNET_GE_DEVELOPER | GNUNET_GE_ADMIN |
80 GNUNET_GE_USER | GNUNET_GE_BULK, 78 GNUNET_GE_USER | GNUNET_GE_BULK, "Statistic not found: `%s'\n",
81 "Statistic not found: `%s'\n", optName); 79 optName);
82#endif 80#endif
83 return GNUNET_SYSERR; 81 return GNUNET_SYSERR;
84} 82}
@@ -92,13 +90,13 @@ updateConnectionGoal (void *unused)
92 90
93 GNUNET_mutex_lock (lock); 91 GNUNET_mutex_lock (lock);
94 cmh = 92 cmh =
95 GNUNET_get_daemon_configuration_value (sock, "gnunetd", 93 GNUNET_get_daemon_configuration_value (sock, "gnunetd",
96 "connection-max-hosts"); 94 "connection-max-hosts");
97 availableDown = 95 availableDown =
98 GNUNET_get_daemon_configuration_value (sock, "LOAD", 96 GNUNET_get_daemon_configuration_value (sock, "LOAD",
99 "MAXNETDOWNBPSTOTAL"); 97 "MAXNETDOWNBPSTOTAL");
100 availableUp = 98 availableUp =
101 GNUNET_get_daemon_configuration_value (sock, "LOAD", "MAXNETUPBPSTOTAL"); 99 GNUNET_get_daemon_configuration_value (sock, "LOAD", "MAXNETUPBPSTOTAL");
102 GNUNET_mutex_unlock (lock); 100 GNUNET_mutex_unlock (lock);
103 if (cmh == NULL) 101 if (cmh == NULL)
104 connectionGoal = 0; 102 connectionGoal = 0;
@@ -146,14 +144,13 @@ getLoadStat (const void *closure, gfloat ** data)
146 if (GNUNET_OK != 144 if (GNUNET_OK !=
147 getStatValue (&vali, NULL, NULL, "% of allowed io load", GNUNET_NO)) 145 getStatValue (&vali, NULL, NULL, "% of allowed io load", GNUNET_NO))
148 return GNUNET_SYSERR; 146 return GNUNET_SYSERR;
149 if (GNUNET_OK != getStatValue (&valu, 147 if (GNUNET_OK !=
150 NULL, NULL, "% of allowed network load (up)", 148 getStatValue (&valu, NULL, NULL, "% of allowed network load (up)",
151 GNUNET_NO)) 149 GNUNET_NO))
152 return GNUNET_SYSERR; 150 return GNUNET_SYSERR;
153 if (GNUNET_OK != getStatValue (&vald, 151 if (GNUNET_OK !=
154 NULL, NULL, 152 getStatValue (&vald, NULL, NULL, "% of allowed network load (down)",
155 "% of allowed network load (down)", 153 GNUNET_NO))
156 GNUNET_NO))
157 return GNUNET_SYSERR; 154 return GNUNET_SYSERR;
158 data[0][0] = (gfloat) valc / 100.0; 155 data[0][0] = (gfloat) valc / 100.0;
159 data[0][1] = (gfloat) vali / 100.0; 156 data[0][1] = (gfloat) vali / 100.0;
@@ -170,17 +167,15 @@ getQuotaStat (const void *closure, gfloat ** data)
170 167
171 data[0][0] = 0; 168 data[0][0] = 0;
172 data[0][1] = 0; 169 data[0][1] = 0;
173 if ((GNUNET_OK == getStatValue (&allowed, 170 if ((GNUNET_OK ==
174 NULL, NULL, "# bytes allowed in datastore", 171 getStatValue (&allowed, NULL, NULL, "# bytes allowed in datastore",
175 GNUNET_NO)) && 172 GNUNET_NO)) && (allowed != 0) &&
176 (allowed != 0) &&
177 (GNUNET_OK == 173 (GNUNET_OK ==
178 getStatValue (&have, NULL, NULL, "# bytes in datastore", GNUNET_NO))) 174 getStatValue (&have, NULL, NULL, "# bytes in datastore", GNUNET_NO)))
179 data[0][0] = ((gfloat) have) / allowed; 175 data[0][0] = ((gfloat) have) / allowed;
180 if ((GNUNET_OK == getStatValue (&allowed, 176 if ((GNUNET_OK ==
181 NULL, NULL, "# max bytes allowed in dstore", 177 getStatValue (&allowed, NULL, NULL, "# max bytes allowed in dstore",
182 GNUNET_NO)) && 178 GNUNET_NO)) && (allowed != 0) &&
183 (allowed != 0) &&
184 (GNUNET_OK == 179 (GNUNET_OK ==
185 getStatValue (&have, NULL, NULL, "# bytes in dstore", GNUNET_NO))) 180 getStatValue (&have, NULL, NULL, "# bytes in dstore", GNUNET_NO)))
186 data[0][1] = ((gfloat) have) / allowed; 181 data[0][1] = ((gfloat) have) / allowed;
@@ -208,43 +203,39 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
208 if (GNUNET_OK != 203 if (GNUNET_OK !=
209 getStatValue (&total, &ltotal, &dtime, "# bytes received", GNUNET_YES)) 204 getStatValue (&total, &ltotal, &dtime, "# bytes received", GNUNET_YES))
210 return GNUNET_SYSERR; 205 return GNUNET_SYSERR;
211 if (GNUNET_OK != getStatValue (&noise, 206 if (GNUNET_OK !=
212 &lnoise, NULL, "# bytes of noise received", 207 getStatValue (&noise, &lnoise, NULL, "# bytes of noise received",
213 GNUNET_YES)) 208 GNUNET_YES))
214 return GNUNET_SYSERR; 209 return GNUNET_SYSERR;
215 buffer = GNUNET_malloc (512); 210 buffer = GNUNET_malloc (512);
216 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", 211 GNUNET_snprintf (buffer, 512, "# bytes received of type %d",
217 GNUNET_P2P_PROTO_GAP_RESULT); 212 GNUNET_P2P_PROTO_GAP_RESULT);
218 if (GNUNET_OK != 213 if (GNUNET_OK != getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES))
219 getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES)) 214 {
220 { 215 content = 0;
221 content = 0; 216 lcontent = 0;
222 lcontent = 0; 217 }
223 }
224 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", 218 GNUNET_snprintf (buffer, 512, "# bytes received of type %d",
225 GNUNET_P2P_PROTO_HELLO); 219 GNUNET_P2P_PROTO_HELLO);
226 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES)) 220 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES))
227 { 221 {
228 hellos = 0; 222 hellos = 0;
229 lhellos = 0; 223 lhellos = 0;
230 } 224 }
231 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", 225 GNUNET_snprintf (buffer, 512, "# bytes received of type %d",
232 GNUNET_P2P_PROTO_GAP_QUERY); 226 GNUNET_P2P_PROTO_GAP_QUERY);
227 if (GNUNET_OK != getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES))
228 {
229 queries = 0;
230 lqueries = 0;
231 }
233 if (GNUNET_OK != 232 if (GNUNET_OK !=
234 getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES)) 233 getStatValue (&rlimit, &lrlimit, NULL,
235 { 234 "# total bytes per second receive limit", GNUNET_NO))
236 queries = 0; 235 {
237 lqueries = 0; 236 rlimit = 0;
238 } 237 lrlimit = 0;
239 if (GNUNET_OK != getStatValue (&rlimit, 238 }
240 &lrlimit,
241 NULL,
242 "# total bytes per second receive limit",
243 GNUNET_NO))
244 {
245 rlimit = 0;
246 lrlimit = 0;
247 }
248 GNUNET_free (buffer); 239 GNUNET_free (buffer);
249 if (banddown == 0) 240 if (banddown == 0)
250 return GNUNET_SYSERR; 241 return GNUNET_SYSERR;
@@ -255,15 +246,15 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
255 content -= lcontent; 246 content -= lcontent;
256 hellos -= lhellos; 247 hellos -= lhellos;
257 if (banddown <= 0) 248 if (banddown <= 0)
258 { 249 {
259 data[0][0] = 0.0; 250 data[0][0] = 0.0;
260 data[0][1] = 0.0; 251 data[0][1] = 0.0;
261 data[0][2] = 0.0; 252 data[0][2] = 0.0;
262 data[0][3] = 0.0; 253 data[0][3] = 0.0;
263 data[0][4] = 0.0; 254 data[0][4] = 0.0;
264 data[0][5] = 0.0; 255 data[0][5] = 0.0;
265 return GNUNET_OK; 256 return GNUNET_OK;
266 } 257 }
267 data[0][0] = ((gfloat) noise) / (banddown * dtime / GNUNET_CRON_SECONDS); /* red */ 258 data[0][0] = ((gfloat) noise) / (banddown * dtime / GNUNET_CRON_SECONDS); /* red */
268 data[0][1] = ((gfloat) (content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* green */ 259 data[0][1] = ((gfloat) (content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* green */
269 data[0][2] = ((gfloat) (queries + content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* yellow */ 260 data[0][2] = ((gfloat) (queries + content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* yellow */
@@ -294,47 +285,41 @@ getTrafficSendStats (const void *closure, gfloat ** data)
294 GNUNET_CronTime dtime; 285 GNUNET_CronTime dtime;
295 char *buffer; 286 char *buffer;
296 287
297 if (GNUNET_OK != getStatValue (&total, 288 if (GNUNET_OK !=
298 &ltotal, &dtime, "# bytes transmitted", 289 getStatValue (&total, &ltotal, &dtime, "# bytes transmitted", GNUNET_YES))
299 GNUNET_YES))
300 return GNUNET_SYSERR; 290 return GNUNET_SYSERR;
301 if (GNUNET_OK != 291 if (GNUNET_OK !=
302 getStatValue (&noise, &lnoise, NULL, "# bytes noise sent", GNUNET_YES)) 292 getStatValue (&noise, &lnoise, NULL, "# bytes noise sent", GNUNET_YES))
303 return GNUNET_SYSERR; 293 return GNUNET_SYSERR;
304 buffer = GNUNET_malloc (512); 294 buffer = GNUNET_malloc (512);
305 GNUNET_snprintf (buffer, 295 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d",
306 512, "# bytes transmitted of type %d",
307 GNUNET_P2P_PROTO_GAP_RESULT); 296 GNUNET_P2P_PROTO_GAP_RESULT);
308 if (GNUNET_OK != 297 if (GNUNET_OK != getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES))
309 getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES)) 298 {
310 { 299 content = 0;
311 content = 0; 300 lcontent = 0;
312 lcontent = 0; 301 }
313 } 302 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d",
314 GNUNET_snprintf (buffer,
315 512, "# bytes transmitted of type %d",
316 GNUNET_P2P_PROTO_GAP_QUERY); 303 GNUNET_P2P_PROTO_GAP_QUERY);
317 if (GNUNET_OK != 304 if (GNUNET_OK != getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES))
318 getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES)) 305 {
319 { 306 queries = 0;
320 queries = 0; 307 lqueries = 0;
321 lqueries = 0; 308 }
322 }
323 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d", 309 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d",
324 GNUNET_P2P_PROTO_HELLO); 310 GNUNET_P2P_PROTO_HELLO);
325 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES)) 311 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES))
326 { 312 {
327 queries = 0; 313 queries = 0;
328 lqueries = 0; 314 lqueries = 0;
329 } 315 }
330 if (GNUNET_OK != getStatValue (&slimit, 316 if (GNUNET_OK !=
331 &lslimit, 317 getStatValue (&slimit, &lslimit, NULL,
332 NULL, "# total bytes per second send limit", 318 "# total bytes per second send limit", GNUNET_NO))
333 GNUNET_NO)) 319 {
334 { 320 slimit = 0;
335 slimit = 0; 321 lslimit = 0;
336 lslimit = 0; 322 }
337 }
338 GNUNET_free (buffer); 323 GNUNET_free (buffer);
339 if (bandup == 0) 324 if (bandup == 0)
340 return GNUNET_SYSERR; 325 return GNUNET_SYSERR;
@@ -344,15 +329,15 @@ getTrafficSendStats (const void *closure, gfloat ** data)
344 content -= lcontent; 329 content -= lcontent;
345 hellos -= lhellos; 330 hellos -= lhellos;
346 if (bandup <= 0) 331 if (bandup <= 0)
347 { 332 {
348 data[0][0] = 0.0; 333 data[0][0] = 0.0;
349 data[0][1] = 0.0; 334 data[0][1] = 0.0;
350 data[0][2] = 0.0; 335 data[0][2] = 0.0;
351 data[0][3] = 0.0; 336 data[0][3] = 0.0;
352 data[0][4] = 0.0; 337 data[0][4] = 0.0;
353 data[0][5] = 0.0; 338 data[0][5] = 0.0;
354 return GNUNET_OK; 339 return GNUNET_OK;
355 } 340 }
356 data[0][0] = ((gfloat) noise) / (bandup * dtime / GNUNET_CRON_SECONDS); /* red */ 341 data[0][0] = ((gfloat) noise) / (bandup * dtime / GNUNET_CRON_SECONDS); /* red */
357 data[0][1] = ((gfloat) (noise + content)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* green */ 342 data[0][1] = ((gfloat) (noise + content)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* green */
358 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* yellow */ 343 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* yellow */
@@ -376,17 +361,15 @@ getTrustStats (const void *closure, gfloat ** data)
376 unsigned long long lawarded; 361 unsigned long long lawarded;
377 unsigned long long max; 362 unsigned long long max;
378 363
379 if (GNUNET_OK != getStatValue (&spent, 364 if (GNUNET_OK !=
380 &lspent, NULL, "# trust spent", GNUNET_YES)) 365 getStatValue (&spent, &lspent, NULL, "# trust spent", GNUNET_YES))
381 return GNUNET_SYSERR; 366 return GNUNET_SYSERR;
382 if (GNUNET_OK != getStatValue (&earned, 367 if (GNUNET_OK !=
383 &learned, 368 getStatValue (&earned, &learned, NULL, "# trust earned", GNUNET_YES))
384 NULL, "# trust earned", GNUNET_YES))
385 return GNUNET_SYSERR; 369 return GNUNET_SYSERR;
386 if (GNUNET_OK != getStatValue (&awarded, 370 if (GNUNET_OK !=
387 &lawarded, 371 getStatValue (&awarded, &lawarded, NULL, "# gap total trust awarded",
388 NULL, "# gap total trust awarded", 372 GNUNET_YES))
389 GNUNET_YES))
390 return GNUNET_SYSERR; 373 return GNUNET_SYSERR;
391 max = spent; 374 max = spent;
392 if (earned > max) 375 if (earned > max)
@@ -395,17 +378,17 @@ getTrustStats (const void *closure, gfloat ** data)
395 max = awarded; 378 max = awarded;
396 data[0][0] = 0.0; 379 data[0][0] = 0.0;
397 if (max > 0) 380 if (max > 0)
398 { 381 {
399 data[0][0] = (1.0 * spent) / max; 382 data[0][0] = (1.0 * spent) / max;
400 data[0][1] = (1.0 * earned) / max; 383 data[0][1] = (1.0 * earned) / max;
401 data[0][2] = (1.0 * awarded) / max; 384 data[0][2] = (1.0 * awarded) / max;
402 } 385 }
403 else 386 else
404 { 387 {
405 data[0][0] = 0.0; 388 data[0][0] = 0.0;
406 data[0][1] = 0.0; 389 data[0][1] = 0.0;
407 data[0][2] = 0.0; 390 data[0][2] = 0.0;
408 } 391 }
409 return GNUNET_OK; 392 return GNUNET_OK;
410} 393}
411 394
@@ -417,14 +400,13 @@ getEffectivenessStats (const void *closure, gfloat ** data)
417 unsigned long long ltotal; 400 unsigned long long ltotal;
418 unsigned long long lsuccess; 401 unsigned long long lsuccess;
419 402
420 if (GNUNET_OK != getStatValue (&total, 403 if (GNUNET_OK !=
421 &ltotal, 404 getStatValue (&total, &ltotal, NULL, "# gap requests total sent",
422 NULL, 405 GNUNET_YES))
423 "# gap requests total sent", GNUNET_YES))
424 return GNUNET_SYSERR; 406 return GNUNET_SYSERR;
425 if (GNUNET_OK != getStatValue (&success, 407 if (GNUNET_OK !=
426 &lsuccess, 408 getStatValue (&success, &lsuccess, NULL, "# gap routes succeeded",
427 NULL, "# gap routes succeeded", GNUNET_YES)) 409 GNUNET_YES))
428 return GNUNET_SYSERR; 410 return GNUNET_SYSERR;
429 if (total > 0) 411 if (total > 0)
430 data[0][0] = 1.0 * success / total; 412 data[0][0] = 1.0 * success / total;
@@ -455,22 +437,22 @@ statsProcessor (const char *optName, unsigned long long value, void *data)
455 if ((j < lsv_size) && (0 == strcmp (optName, lastStatValues[j].statName))) 437 if ((j < lsv_size) && (0 == strcmp (optName, lastStatValues[j].statName)))
456 found = j; 438 found = j;
457 if (found == (unsigned int) -1) 439 if (found == (unsigned int) -1)
440 {
441 for (j = 0; j < lsv_size; j++)
458 { 442 {
459 for (j = 0; j < lsv_size; j++) 443 if (0 == strcmp (optName, lastStatValues[j].statName))
460 { 444 {
461 if (0 == strcmp (optName, lastStatValues[j].statName)) 445 found = j;
462 { 446 break;
463 found = j; 447 }
464 break;
465 }
466 }
467 } 448 }
449 }
468 if (found == (unsigned int) -1) 450 if (found == (unsigned int) -1)
469 { 451 {
470 found = lsv_size; 452 found = lsv_size;
471 GNUNET_array_grow (lastStatValues, lsv_size, lsv_size + 1); 453 GNUNET_array_grow (lastStatValues, lsv_size, lsv_size + 1);
472 lastStatValues[found].statName = GNUNET_strdup (optName); 454 lastStatValues[found].statName = GNUNET_strdup (optName);
473 } 455 }
474 lastStatValues[found].lvalue = lastStatValues[found].value; 456 lastStatValues[found].lvalue = lastStatValues[found].value;
475 lastStatValues[found].value = value; 457 lastStatValues[found].value = value;
476 lastStatValues[found].delta = *delta; 458 lastStatValues[found].delta = *delta;
@@ -494,17 +476,17 @@ updateDaemonStatus (void *cls)
494 unsigned long long connected_peers; 476 unsigned long long connected_peers;
495 477
496 if (uc->is_running) 478 if (uc->is_running)
497 { 479 {
498 if (GNUNET_OK != 480 if (GNUNET_OK !=
499 getStatValue (&connected_peers, NULL, NULL, 481 getStatValue (&connected_peers, NULL, NULL, "# of connected peers",
500 "# of connected peers", GNUNET_NO)) 482 GNUNET_NO))
501 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_UNKNOWN, 0); 483 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_UNKNOWN, 0);
502 else if (connected_peers > 0) 484 else if (connected_peers > 0)
503 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_CONNECTED, 485 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_CONNECTED,
504 connected_peers); 486 connected_peers);
505 else 487 else
506 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_DISCONNECTED, 0); 488 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_DISCONNECTED, 0);
507 } 489 }
508 else 490 else
509 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_NODAEMON, 0); 491 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_NODAEMON, 0);
510 return NULL; 492 return NULL;
@@ -613,24 +595,19 @@ StatEntry stats[] = {
613static unsigned long long UPDATE_INTERVAL; 595static unsigned long long UPDATE_INTERVAL;
614 596
615void 597void
616init_functions (struct GNUNET_GE_Context *e, 598init_functions (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
617 struct GNUNET_GC_Configuration *c)
618{ 599{
619 ectx = e; 600 ectx = e;
620 cfg = c; 601 cfg = c;
621 GNUNET_GC_get_configuration_value_number (cfg, 602 GNUNET_GC_get_configuration_value_number (cfg, "GNUNET-GTK", "STATS-INTERVAL",
622 "GNUNET-GTK", 603 1, 99 * GNUNET_CRON_YEARS,
623 "STATS-INTERVAL",
624 1,
625 99 * GNUNET_CRON_YEARS,
626 30 * GNUNET_CRON_SECONDS, 604 30 * GNUNET_CRON_SECONDS,
627 &UPDATE_INTERVAL); 605 &UPDATE_INTERVAL);
628 sock = GNUNET_client_connection_create (ectx, cfg); 606 sock = GNUNET_client_connection_create (ectx, cfg);
629 lock = GNUNET_mutex_create (GNUNET_NO); 607 lock = GNUNET_mutex_create (GNUNET_NO);
630 cron = GNUNET_GTK_get_cron_manager (); 608 cron = GNUNET_GTK_get_cron_manager ();
631 GNUNET_cron_add_job (cron, 609 GNUNET_cron_add_job (cron, &updateStatValues, UPDATE_INTERVAL,
632 &updateStatValues, UPDATE_INTERVAL, UPDATE_INTERVAL, 610 UPDATE_INTERVAL, NULL);
633 NULL);
634 GNUNET_cron_add_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_SECONDS, 611 GNUNET_cron_add_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_SECONDS,
635 5 * GNUNET_CRON_MINUTES, NULL); 612 5 * GNUNET_CRON_MINUTES, NULL);
636 updateStatValues (NULL); 613 updateStatValues (NULL);