X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fnetwork.c;h=ad8d530e4780d4ff9ce8ab96d72b65455a243c42;hb=63cbff115ba03717e81087d1419fc07c24d205c2;hp=4b50ce2db727b4ae48f8a4474811e491c9f8b339;hpb=2f0dfdda8bc499fdb161c6a5850ec176e75bd4fa;p=collectd.git diff --git a/src/network.c b/src/network.c index 4b50ce2d..ad8d530e 100644 --- a/src/network.c +++ b/src/network.c @@ -162,7 +162,7 @@ static int listen_loop = 0; static char send_buffer[BUFF_SIZE]; static char *send_buffer_ptr; static int send_buffer_fill; -static value_list_t send_buffer_vl = VALUE_LIST_INIT; +static value_list_t send_buffer_vl = VALUE_LIST_STATIC; static char send_buffer_type[DATA_MAX_NAME_LEN]; static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER; @@ -385,7 +385,8 @@ static int parse_part_values (void **ret_buffer, int *ret_buffer_len, if (buffer_len < (15)) { - DEBUG ("packet is too short: buffer_len = %i", buffer_len); + DEBUG ("network plugin: packet is too short: buffer_len = %i", + buffer_len); return (-1); } @@ -556,6 +557,13 @@ static int parse_packet (void *buffer, int buffer_len) if (status == 0) vl.time = (time_t) tmp; } + else if (ntohs (header->type) == TYPE_INTERVAL) + { + uint64_t tmp = 0; + status = parse_part_number (&buffer, &buffer_len, &tmp); + if (status == 0) + vl.interval = (int) tmp; + } else if (ntohs (header->type) == TYPE_HOST) { status = parse_part_string (&buffer, &buffer_len, @@ -1047,7 +1055,7 @@ static void network_send_buffer (const char *buffer, int buffer_len) sockent_t *se; int status; - DEBUG ("buffer_len = %i", buffer_len); + DEBUG ("network plugin: network_send_buffer: buffer_len = %i", buffer_len); for (se = sending_sockets; se != NULL; se = se->next) { @@ -1096,6 +1104,16 @@ static int add_to_buffer (char *buffer, int buffer_size, (unsigned int) vl->time); } + if (vl_def->interval != vl->interval) + { + if (write_part_number (&buffer, &buffer_size, TYPE_INTERVAL, + (uint64_t) vl->interval)) + return (-1); + vl_def->interval = vl->interval; + DEBUG ("network plugin: add_to_buffer: interval = %i", + (int) vl->interval); + } + if (strcmp (vl_def->plugin, vl->plugin) != 0) { if (write_part_string (&buffer, &buffer_size, TYPE_PLUGIN, @@ -1343,7 +1361,7 @@ static int network_init (void) return (0); } /* int network_init */ -void module_register (modreg_e load) +void module_register (void) { plugin_register_config ("network", network_config, config_keys, config_keys_num);