#include "libcollectdclient/collectd/network.h"
#include "libcollectdclient/collectd/network_buffer.h"
-#define DEF_NUM_HOSTS 1000
-#define DEF_NUM_PLUGINS 20
+#define DEF_NUM_HOSTS 1000
+#define DEF_NUM_PLUGINS 20
#define DEF_NUM_VALUES 100000
+#define DEF_INTERVAL 10
static int conf_num_hosts = DEF_NUM_HOSTS;
static int conf_num_plugins = DEF_NUM_PLUGINS;
static int conf_num_values = DEF_NUM_VALUES;
+static int conf_interval = DEF_INTERVAL;
static const char *conf_destination = NET_DEFAULT_V6_ADDR;
static const char *conf_service = NET_DEFAULT_PORT;
" -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: %i)\n"
" -d <dest> Destination address of the network packets.\n"
" (Default: %s)\n"
" -D <port> Destination port of the network packets.\n"
"Copyright (C) 2010 Florian Forster\n"
"Licensed under the GNU General Public License, version 2 (GPLv2)\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 */
return (min + ((int) (((double) range) * ((double) random ()) / (((double) RAND_MAX) + 1.0))));
} /* }}} int get_boundet_random */
-#if 0
-static int dump_network_buffer (void) /* {{{ */
-{
- char buffer[LCC_NETWORK_BUFFER_SIZE_DEFAULT];
- size_t buffer_size;
- int status;
- size_t offset;
-
- memset (buffer, 0, sizeof (buffer));
- buffer_size = sizeof (buffer);
-
- status = lcc_network_buffer_get (nb, buffer, &buffer_size);
- if (status != 0)
- {
- fprintf (stderr, "lcc_network_buffer_get failed with status %i.\n",
- status);
- return (status);
- }
-
- if (buffer_size > sizeof (buffer))
- buffer_size = sizeof (buffer);
-
- for (offset = 0; offset < buffer_size; offset += 16)
- {
- size_t i;
-
- for (i = 0; (i < 16) && ((offset + i) < buffer_size); i++)
- {
- uint8_t v = (uint8_t) buffer[offset + i];
- printf ("%02"PRIx8" ", v);
- }
- for (; i < 16; i++)
- printf (" ");
- printf (" ");
- for (i = 0; (i < 16) && ((offset + i) < buffer_size); i++)
- {
- uint8_t v = (uint8_t) buffer[offset + i];
- if ((v >= 32) && (v < 128))
- printf ("%c", (int) buffer[offset + i]);
- else
- printf (".");
- }
- printf ("\n");
- }
-
- return (0);
-} /* }}} int dump_network_buffer */
-#endif
-
static lcc_value_list_t *create_value_list (void) /* {{{ */
{
lcc_value_list_t *vl;
host_num = get_boundet_random (0, conf_num_hosts);
- vl->interval = 10;
- vl->time = time (NULL) - (host_num % vl->interval);
+ vl->interval = conf_interval;
+ vl->time = time (NULL) + (host_num % vl->interval) + 1;
if (get_boundet_random (0, 2) == 0)
vl->values_types[0] = LCC_TYPE_GAUGE;
get_integer_opt (optarg, &conf_num_plugins);
break;
+ case 'i':
+ get_integer_opt (optarg, &conf_interval);
+ break;
+
case 'd':
conf_destination = optarg;
break;
struct timespec ts = { 0, 10000000 };
nanosleep (&ts, /* remaining = */ NULL);
now = time (NULL);
+
+ if (!loop)
+ break;
}
last_time = vl->time;
}