aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/stats/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/stats/functions.c')
-rw-r--r--src/plugins/stats/functions.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index 8b20557c..f96775fd 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -60,7 +60,7 @@ static int getStatValue(long long * value,
60 if (dtime != NULL) 60 if (dtime != NULL)
61 *dtime = lastStatValues[i].delta; 61 *dtime = lastStatValues[i].delta;
62 return OK; 62 return OK;
63 } 63 }
64 } 64 }
65#if FUNCTIONS_DEBUG 65#if FUNCTIONS_DEBUG
66 LOG(LOG_DEBUG, 66 LOG(LOG_DEBUG,
@@ -86,7 +86,7 @@ static void updateConnectionGoal(void * unused) {
86 "LOAD", 86 "LOAD",
87 "MAXNETUPBPSTOTAL"); 87 "MAXNETUPBPSTOTAL");
88 MUTEX_UNLOCK(&lock); 88 MUTEX_UNLOCK(&lock);
89 if (cmh == NULL) 89 if (cmh == NULL)
90 connectionGoal = 0; 90 connectionGoal = 0;
91 else 91 else
92 connectionGoal = atol(cmh); 92 connectionGoal = atol(cmh);
@@ -113,7 +113,7 @@ static int getConnectedNodesStat(const void * closure,
113 if (OK != getStatValue(&val, 113 if (OK != getStatValue(&val,
114 NULL, 114 NULL,
115 NULL, 115 NULL,
116 "# of connected peers")) 116 "# of connected peers"))
117 return SYSERR; 117 return SYSERR;
118 data[0][0] = 0.8 * val / connectionGoal; 118 data[0][0] = 0.8 * val / connectionGoal;
119 return OK; 119 return OK;
@@ -158,7 +158,7 @@ static int getTrafficRecvStats(const void * closure,
158 return SYSERR; 158 return SYSERR;
159 i = 0; 159 i = 0;
160 buffer = MALLOC(512); 160 buffer = MALLOC(512);
161 SNPRINTF(buffer, 161 SNPRINTF(buffer,
162 512, 162 512,
163 "# bytes received of type %d", 163 "# bytes received of type %d",
164 P2P_PROTO_gap_RESULT); 164 P2P_PROTO_gap_RESULT);
@@ -167,10 +167,10 @@ static int getTrafficRecvStats(const void * closure,
167 NULL, 167 NULL,
168 buffer)) { 168 buffer)) {
169 content += 0; 169 content += 0;
170 lcontent += 0; 170 lcontent += 0;
171 } 171 }
172 i = 0; 172 i = 0;
173 SNPRINTF(buffer, 173 SNPRINTF(buffer,
174 512, 174 512,
175 "# bytes received of type %d", 175 "# bytes received of type %d",
176 P2P_PROTO_gap_QUERY); 176 P2P_PROTO_gap_QUERY);
@@ -180,10 +180,10 @@ static int getTrafficRecvStats(const void * closure,
180 buffer)) { 180 buffer)) {
181 queries = 0; 181 queries = 0;
182 lqueries = 0; 182 lqueries = 0;
183 } 183 }
184 FREE(buffer); 184 FREE(buffer);
185 if (banddown == 0) 185 if (banddown == 0)
186 return SYSERR; 186 return SYSERR;
187 187
188 total -= ltotal; 188 total -= ltotal;
189 noise -= lnoise; 189 noise -= lnoise;
@@ -200,7 +200,7 @@ static int getTrafficRecvStats(const void * closure,
200 data[0][1] = 0.8 * (content+noise) / (banddown * dtime / cronSECONDS); /* green */ 200 data[0][1] = 0.8 * (content+noise) / (banddown * dtime / cronSECONDS); /* green */
201 data[0][2] = 0.8 * (queries+content+noise) / (banddown * dtime / cronSECONDS); /* yellow */ 201 data[0][2] = 0.8 * (queries+content+noise) / (banddown * dtime / cronSECONDS); /* yellow */
202 data[0][3] = 0.8 * total / (banddown * dtime / cronSECONDS); /* blue */ 202 data[0][3] = 0.8 * total / (banddown * dtime / cronSECONDS); /* blue */
203 /*printf("I: %f %f %f\n", 203 /*printf("I: %f %f %f\n",
204 data[0][0], 204 data[0][0],
205 data[0][1], 205 data[0][1],
206 data[0][2]);*/ 206 data[0][2]);*/
@@ -234,7 +234,7 @@ static int getTrafficSendStats(const void * closure,
234 return SYSERR; 234 return SYSERR;
235 i = 0; 235 i = 0;
236 buffer = MALLOC(512); 236 buffer = MALLOC(512);
237 SNPRINTF(buffer, 237 SNPRINTF(buffer,
238 512, 238 512,
239 "# bytes transmitted of type %d", 239 "# bytes transmitted of type %d",
240 P2P_PROTO_gap_RESULT); 240 P2P_PROTO_gap_RESULT);
@@ -243,10 +243,10 @@ static int getTrafficSendStats(const void * closure,
243 NULL, 243 NULL,
244 buffer)) { 244 buffer)) {
245 content = 0; 245 content = 0;
246 lcontent = 0; 246 lcontent = 0;
247 } 247 }
248 i = 0; 248 i = 0;
249 SNPRINTF(buffer, 249 SNPRINTF(buffer,
250 512, 250 512,
251 "# bytes received of type %d", 251 "# bytes received of type %d",
252 P2P_PROTO_gap_QUERY); 252 P2P_PROTO_gap_QUERY);
@@ -255,7 +255,7 @@ static int getTrafficSendStats(const void * closure,
255 NULL, 255 NULL,
256 buffer)) { 256 buffer)) {
257 queries = 0; 257 queries = 0;
258 lqueries = 0; 258 lqueries = 0;
259 } 259 }
260 FREE(buffer); 260 FREE(buffer);
261 if (bandup == 0) 261 if (bandup == 0)
@@ -275,10 +275,10 @@ static int getTrafficSendStats(const void * closure,
275 data[0][1] = 0.8 * (noise + content) / (bandup*dtime / cronSECONDS); /* green */ 275 data[0][1] = 0.8 * (noise + content) / (bandup*dtime / cronSECONDS); /* green */
276 data[0][2] = 0.8 * (noise + content + queries) / (bandup*dtime / cronSECONDS); /* yellow */ 276 data[0][2] = 0.8 * (noise + content + queries) / (bandup*dtime / cronSECONDS); /* yellow */
277 data[0][3] = 0.8 * total / (bandup*dtime / cronSECONDS); /* yellow */ 277 data[0][3] = 0.8 * total / (bandup*dtime / cronSECONDS); /* yellow */
278 /* printf("O: %f %f %f\n", 278 /* printf("O: %f %f %f\n",
279 data[0][0], 279 data[0][0],
280 data[0][1], 280 data[0][1],
281 data[0][2]);*/ 281 data[0][2]);*/
282 return OK; 282 return OK;
283} 283}
284 284
@@ -291,7 +291,7 @@ static int statsProcessor(const char * optName,
291 int found; 291 int found;
292 292
293 found = -1; 293 found = -1;
294 for (j=0;j<lsv_size;j++) 294 for (j=0;j<lsv_size;j++)
295 if (0 == strcmp(optName, 295 if (0 == strcmp(optName,
296 lastStatValues[j].statName)) 296 lastStatValues[j].statName))
297 found = j; 297 found = j;
@@ -310,7 +310,7 @@ static int statsProcessor(const char * optName,
310 lastStatValues[found].delta 310 lastStatValues[found].delta
311 = *delta; 311 = *delta;
312 return OK; 312 return OK;
313} 313}
314 314
315/** 315/**
316 * Cron-job that updates all stat values. 316 * Cron-job that updates all stat values.
@@ -325,22 +325,22 @@ static void updateStatValues(void * unused) {
325 MUTEX_LOCK(&lock); 325 MUTEX_LOCK(&lock);
326 if (OK == requestStatistics(sock, 326 if (OK == requestStatistics(sock,
327 &statsProcessor, 327 &statsProcessor,
328 &delta)) 328 &delta))
329 lastUpdate = now; 329 lastUpdate = now;
330 MUTEX_UNLOCK(&lock); 330 MUTEX_UNLOCK(&lock);
331} 331}
332 332
333 333
334StatEntry stats[] = { 334StatEntry stats[] = {
335 { 335 {
336 gettext_noop("Connectivity"), 336 gettext_noop("Connectivity"),
337 gettext_noop("# connected nodes (100% = connection table size)"), 337 gettext_noop("# connected nodes (100% = connection table size)"),
338 &getConnectedNodesStat, 338 &getConnectedNodesStat,
339 NULL, 339 NULL,
340 1, 340 1,
341 NO, 341 NO,
342 }, 342 },
343 { 343 {
344 gettext_noop("CPU load"), 344 gettext_noop("CPU load"),
345 gettext_noop("CPU load (in percent of allowed load)"), 345 gettext_noop("CPU load (in percent of allowed load)"),
346 &getCPULoadStat, 346 &getCPULoadStat,
@@ -348,7 +348,7 @@ StatEntry stats[] = {
348 1, 348 1,
349 NO, 349 NO,
350 }, 350 },
351 { 351 {
352 gettext_noop("Inbound Traffic"), 352 gettext_noop("Inbound Traffic"),
353 gettext_noop("Noise (red), Content (green), Queries (yellow), other (blue)"), 353 gettext_noop("Noise (red), Content (green), Queries (yellow), other (blue)"),
354 &getTrafficRecvStats, 354 &getTrafficRecvStats,
@@ -356,7 +356,7 @@ StatEntry stats[] = {
356 4, 356 4,
357 YES, 357 YES,
358 }, 358 },
359 { 359 {
360 gettext_noop("Outbound Traffic"), 360 gettext_noop("Outbound Traffic"),
361 gettext_noop("Noise (red), Content (green), Queries (yellow), other (blue)"), 361 gettext_noop("Noise (red), Content (green), Queries (yellow), other (blue)"),
362 &getTrafficSendStats, 362 &getTrafficSendStats,
@@ -377,7 +377,7 @@ StatEntry stats[] = {
377int UPDATE_INTERVAL; 377int UPDATE_INTERVAL;
378 378
379void init_functions() { 379void init_functions() {
380 UPDATE_INTERVAL 380 UPDATE_INTERVAL
381 = getConfigurationInt("GNUNET-GTK", 381 = getConfigurationInt("GNUNET-GTK",
382 "STATS-INTERVAL") * cronSECONDS; 382 "STATS-INTERVAL") * cronSECONDS;
383 if (UPDATE_INTERVAL == 0) 383 if (UPDATE_INTERVAL == 0)
@@ -414,5 +414,5 @@ void done_functions() {
414 sock = NULL; 414 sock = NULL;
415} 415}
416 416
417 417
418/* end of functions.c */ 418/* end of functions.c */