aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-06-16 13:56:56 +0200
committerJulius Bünger <buenger@mytum.de>2018-06-16 13:56:56 +0200
commit89887cddfe69fb0582e0c9a26996a9c5b025e702 (patch)
treea29ae0860bad4325bfd0eb2e02398179e575a62f /src/statistics
parent298776c4185d99d2d64f9ff84d1eb662f2f16db7 (diff)
downloadgnunet-89887cddfe69fb0582e0c9a26996a9c5b025e702.tar.gz
gnunet-89887cddfe69fb0582e0c9a26996a9c5b025e702.zip
statistics-cli: add option for csv separator
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/gnunet-statistics.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 2aefcadee..81563a134 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -64,6 +64,11 @@ static int watch;
64static int quiet; 64static int quiet;
65 65
66/** 66/**
67 * @brief Separator string for csv.
68 */
69static char *csv_separator;
70
71/**
67 * Remote host 72 * Remote host
68 */ 73 */
69static char *remote_host; 74static char *remote_host;
@@ -206,26 +211,34 @@ printer (void *cls,
206 { 211 {
207 now_str = GNUNET_STRINGS_absolute_time_to_string (now); 212 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
208 FPRINTF (stdout, 213 FPRINTF (stdout,
209 "%24s %s%12s %50s: ", 214 "%24s%s %s%s%12s%s %50s%s ",
210 now_str, 215 now_str,
216 csv_separator,
211 value_set->is_persistent ? "!" : " ", 217 value_set->is_persistent ? "!" : " ",
218 csv_separator,
212 value_set->subsystem, 219 value_set->subsystem,
213 _(value_set->name)); 220 csv_separator,
221 _(value_set->name),
222 (0 == strlen (csv_separator) ? ":": csv_separator));
214 } 223 }
215 else 224 else
216 { 225 {
217 FPRINTF (stdout, 226 FPRINTF (stdout,
218 "%s%12s %50s: ", 227 "%s%s%12s%s %50s%s ",
219 value_set->is_persistent ? "!" : " ", 228 value_set->is_persistent ? "!" : " ",
229 csv_separator,
220 value_set->subsystem, 230 value_set->subsystem,
221 _(value_set->name)); 231 csv_separator,
232 _(value_set->name),
233 (0 == strlen (csv_separator) ? ":": csv_separator));
222 } 234 }
223 } 235 }
224 for (unsigned i = 0; i < num_nodes; i++) 236 for (unsigned i = 0; i < num_nodes; i++)
225 { 237 {
226 FPRINTF (stdout, 238 FPRINTF (stdout,
227 "%16llu", 239 "%16llu%s",
228 (unsigned long long) value_set->values[i]); 240 (unsigned long long) value_set->values[i],
241 csv_separator);
229 } 242 }
230 FPRINTF (stdout, "\n"); 243 FPRINTF (stdout, "\n");
231 GNUNET_free (value_set->subsystem); 244 GNUNET_free (value_set->subsystem);
@@ -297,21 +310,28 @@ printer_watch (void *cls,
297 { 310 {
298 now_str = GNUNET_STRINGS_absolute_time_to_string (now); 311 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
299 FPRINTF (stdout, 312 FPRINTF (stdout,
300 "%24s %s%12s %50s: %16llu\n", 313 "%24s%s %s%s%12s%s %50s%s %16llu\n",
301 now_str, 314 now_str,
315 csv_separator,
302 is_persistent ? "!" : " ", 316 is_persistent ? "!" : " ",
317 csv_separator,
303 subsystem, 318 subsystem,
304 _(name), 319 csv_separator,
305 (unsigned long long) value); 320 _(name),
321 (0 == strlen (csv_separator) ? ":": csv_separator),
322 (unsigned long long) value);
306 } 323 }
307 else 324 else
308 { 325 {
309 FPRINTF (stdout, 326 FPRINTF (stdout,
310 "%s%12s %50s: %16llu\n", 327 "%s%s%12s%s %50s%s %16llu\n",
311 is_persistent ? "!" : " ", 328 is_persistent ? "!" : " ",
329 csv_separator,
312 subsystem, 330 subsystem,
313 _(name), 331 csv_separator,
314 (unsigned long long) value); 332 _(name),
333 (0 == strlen (csv_separator) ? ":": csv_separator),
334 (unsigned long long) value);
315 } 335 }
316 } 336 }
317 else 337 else
@@ -672,6 +692,7 @@ run (void *cls,
672 692
673 c = (struct GNUNET_CONFIGURATION_Handle *) cfg; 693 c = (struct GNUNET_CONFIGURATION_Handle *) cfg;
674 set_value = GNUNET_NO; 694 set_value = GNUNET_NO;
695 if (NULL == csv_separator) csv_separator = "";
675 if (NULL != args[0]) 696 if (NULL != args[0])
676 { 697 {
677 if (1 != SSCANF (args[0], 698 if (1 != SSCANF (args[0],
@@ -766,6 +787,12 @@ int
766main (int argc, char *const *argv) 787main (int argc, char *const *argv)
767{ 788{
768 struct GNUNET_GETOPT_CommandLineOption options[] = { 789 struct GNUNET_GETOPT_CommandLineOption options[] = {
790 GNUNET_GETOPT_option_string ('d',
791 "csv-separator",
792 "CSV_SEPARATOR",
793 gettext_noop ("use as csv separator"),
794 &csv_separator),
795
769 GNUNET_GETOPT_option_string ('n', 796 GNUNET_GETOPT_option_string ('n',
770 "name", 797 "name",
771 "NAME", 798 "NAME",
@@ -804,11 +831,13 @@ main (int argc, char *const *argv)
804 "REMOTE", 831 "REMOTE",
805 gettext_noop ("connect to remote host"), 832 gettext_noop ("connect to remote host"),
806 &remote_host), 833 &remote_host),
834
807 GNUNET_GETOPT_option_ulong ('o', 835 GNUNET_GETOPT_option_ulong ('o',
808 "port", 836 "port",
809 "PORT", 837 "PORT",
810 gettext_noop ("port for remote host"), 838 gettext_noop ("port for remote host"),
811 &remote_port), 839 &remote_port),
840
812 GNUNET_GETOPT_OPTION_END 841 GNUNET_GETOPT_OPTION_END
813 }; 842 };
814 remote_port = 0; 843 remote_port = 0;