+static struct sigaction sigint_action;
+static struct sigaction sigterm_action;
+
+static _Bool loop = 1;
+
+__attribute__((noreturn))
+static void exit_usage (int exit_status) /* {{{ */
+{
+ fprintf ((exit_status == EXIT_FAILURE) ? stderr : stdout,
+ "collectd-tg -- collectd traffic generator\n"
+ "\n"
+ " Usage: collectd-ng [OPTION]\n"
+ "\n"
+ " Valid options:\n"
+ " -n <number> Number of value lists. (Default: %i)\n"
+ " -H <number> Number of hosts to emulate. (Default: %i)\n"
+ " -p <number> Number of plugins to emulate. (Default: %i)\n"
+ " -i <seconds> Interval of each value in seconds. (Default: %.3f)\n"
+ " -d <dest> Destination address of the network packets.\n"
+ " (Default: %s)\n"
+ " -D <port> Destination port of the network packets.\n"
+ " (Default: %s)\n"
+ " -h Print usage information (this output).\n"
+ "\n"
+ "Copyright (C) 2010-2012 Florian Forster\n"
+ "Licensed under the MIT license.\n",
+ DEF_NUM_VALUES, DEF_NUM_HOSTS, DEF_NUM_PLUGINS,
+ DEF_INTERVAL,
+ NET_DEFAULT_V6_ADDR, NET_DEFAULT_PORT);
+ exit (exit_status);
+} /* }}} void exit_usage */
+
+static void signal_handler (int signal) /* {{{ */
+{
+ loop = 0;
+} /* }}} void signal_handler */
+
+#if HAVE_CLOCK_GETTIME
+static double dtime (void) /* {{{ */
+{
+ struct timespec ts = { 0 };
+
+ if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0)
+ perror ("clock_gettime");
+
+ return ((double) ts.tv_sec) + (((double) ts.tv_nsec) / 1e9);
+} /* }}} double dtime */
+#else
+/* Work around for Mac OS X which doesn't have clock_gettime(2). *sigh* */
+static double dtime (void) /* {{{ */
+{
+ struct timeval tv = { 0 };
+
+ if (gettimeofday (&tv, /* timezone = */ NULL) != 0)
+ perror ("gettimeofday");
+
+ return ((double) tv.tv_sec) + (((double) tv.tv_usec) / 1e6);
+} /* }}} double dtime */
+#endif
+