aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-26 15:15:03 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-26 15:15:03 +0000
commit3bf68f7cb4609c7288a17f2f2ce0f156a9e634e5 (patch)
treebc63cf617a6f7b420f7717a967cc7d22f3d69e86 /src/statistics
parent2d2d9cb40ffca230168235ecc0208b595b69efdc (diff)
downloadgnunet-3bf68f7cb4609c7288a17f2f2ce0f156a9e634e5.tar.gz
gnunet-3bf68f7cb4609c7288a17f2f2ce0f156a9e634e5.zip
- continous watch for statistics
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/gnunet-statistics.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index ce91572df..8b163ef89 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -53,6 +53,11 @@ static char *name;
53static int persistent; 53static int persistent;
54 54
55/** 55/**
56 * Watch value continuously
57 */
58static int watch;
59
60/**
56 * Quiet mode 61 * Quiet mode
57 */ 62 */
58static int quiet; 63static int quiet;
@@ -101,7 +106,14 @@ cleanup (void *cls, int success)
101 if (h != NULL) 106 if (h != NULL)
102 GNUNET_STATISTICS_destroy (h, GNUNET_NO); 107 GNUNET_STATISTICS_destroy (h, GNUNET_NO);
103} 108}
104 109static void
110shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
111{
112 struct GNUNET_STATISTICS_Handle *h = cls;
113 GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h);
114 if (h != NULL)
115 GNUNET_STATISTICS_destroy (h, GNUNET_NO);
116}
105 117
106/** 118/**
107 * Main function that will be run by the scheduler. 119 * Main function that will be run by the scheduler.
@@ -143,10 +155,26 @@ run (void *cls, char *const *args, const char *cfgfile,
143 ret = 1; 155 ret = 1;
144 return; 156 return;
145 } 157 }
146 if (NULL == 158 if (GNUNET_NO == watch)
159 {
160 if (NULL ==
147 GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup, 161 GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup,
148 &printer, h)) 162 &printer, h))
149 cleanup (h, GNUNET_SYSERR); 163 cleanup (h, GNUNET_SYSERR);
164 }
165 else
166 {
167 if ((NULL == subsystem) || (NULL == name))
168 {
169 printf (_("No subsystem or name given\n"));
170 if (h != NULL)
171 GNUNET_STATISTICS_destroy (h, GNUNET_NO);
172 ret = 1;
173 return;
174 }
175 GNUNET_STATISTICS_watch(h, subsystem, name, &printer, h);
176 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, h);
177 }
150} 178}
151 179
152/** 180/**
@@ -172,6 +200,9 @@ main (int argc, char *const *argv)
172 {'q', "quiet", NULL, 200 {'q', "quiet", NULL,
173 gettext_noop ("just print the statistics value"), 0, 201 gettext_noop ("just print the statistics value"), 0,
174 &GNUNET_GETOPT_set_one, &quiet}, 202 &GNUNET_GETOPT_set_one, &quiet},
203 {'w', "watch", NULL,
204 gettext_noop ("watch value continously"), 0,
205 &GNUNET_GETOPT_set_one, &watch},
175 GNUNET_GETOPT_OPTION_END 206 GNUNET_GETOPT_OPTION_END
176 }; 207 };
177 return (GNUNET_OK == 208 return (GNUNET_OK ==