Skip to content

Commit 6f2d0db

Browse files
committed
write_graphite plugin: Rename "ForceReconnectTimeout" to "ReconnectInterval".
1 parent 48aea1c commit 6f2d0db

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

src/collectd.conf.in

+1
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@
13471347
# Host "localhost"
13481348
# Port "2003"
13491349
# Protocol "tcp"
1350+
# ReconnectInterval 0
13501351
# LogSendErrors true
13511352
# Prefix "collectd"
13521353
# Postfix "collectd"

src/collectd.conf.pod

+6-2
Original file line numberDiff line numberDiff line change
@@ -7271,9 +7271,13 @@ Service name or port number to connect to. Defaults to C<2003>.
72717271

72727272
Protocol to use when connecting to I<Graphite>. Defaults to C<tcp>.
72737273

7274-
=item B<ForceReconnectTimeout> I<Timeout Seconds>
7274+
=item B<ReconnectInterval> I<Seconds>
72757275

7276-
This parameter enables a forced close and re-open of the established connection with the Graphite backend after the specified timeout in seconds. This behavior is desirable in environments where the connection to the Graphite backend is done through load balancers. Default to 0 seconds (0 seconds = disabled).
7276+
When set to non-zero, forces the connection to the Graphite backend to be
7277+
closed and re-opend periodically. This behavior is desirable in environments
7278+
where the connection to the Graphite backend is done through load balancers,
7279+
for example. When set to zero, the default, the connetion is kept open for as
7280+
long as possible.
72777281

72787282
=item B<LogSendErrors> B<false>|B<true>
72797283

src/write_graphite.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -96,33 +96,33 @@ struct wg_callback
9696
cdtime_t last_connect_time;
9797

9898
/* Force reconnect useful for load balanced environments */
99-
cdtime_t last_force_reconnect_time;
100-
cdtime_t force_reconnect_timeout;
101-
_Bool conn_forced_closed;
99+
cdtime_t last_reconnect_time;
100+
cdtime_t reconnect_interval;
101+
_Bool reconnect_interval_reached;
102102
};
103103

104104
/* wg_force_reconnect_check closes cb->sock_fd when it was open for longer
105-
* than cb->force_reconnect_timeout. Must hold cb->send_lock when calling. */
105+
* than cb->reconnect_interval. Must hold cb->send_lock when calling. */
106106
static void wg_force_reconnect_check (struct wg_callback *cb)
107107
{
108108
cdtime_t now;
109109

110-
if (cb->force_reconnect_timeout == 0)
110+
if (cb->reconnect_interval == 0)
111111
return;
112112

113113
/* check if address changes if addr_timeout */
114114
now = cdtime ();
115-
if ((now - cb->last_force_reconnect_time) < cb->force_reconnect_timeout)
115+
if ((now - cb->last_reconnect_time) < cb->reconnect_interval)
116116
return;
117117

118118
/* here we should close connection on next */
119119
close (cb->sock_fd);
120120
cb->sock_fd = -1;
121-
cb->last_force_reconnect_time = now;
122-
cb->conn_forced_closed = 1;
121+
cb->last_reconnect_time = now;
122+
cb->reconnect_interval_reached = 1;
123123

124124
INFO ("write_graphite plugin: Connection closed after %.3f seconds.",
125-
CDTIME_T_TO_DOUBLE (now - cb->last_force_reconnect_time));
125+
CDTIME_T_TO_DOUBLE (now - cb->last_reconnect_time));
126126
}
127127

128128
/*
@@ -280,11 +280,11 @@ static int wg_callback_init (struct wg_callback *cb)
280280

281281
/* wg_force_reconnect_check does not flush the buffer before closing a
282282
* sending socket, so only call wg_reset_buffer() if the socket was closed
283-
* for a different reason (tracked in cb->conn_forced_closed). */
284-
if (!cb->conn_forced_closed || (cb->send_buf_free == 0))
283+
* for a different reason (tracked in cb->reconnect_interval_reached). */
284+
if (!cb->reconnect_interval_reached || (cb->send_buf_free == 0))
285285
wg_reset_buffer (cb);
286286
else
287-
cb->conn_forced_closed = 0;
287+
cb->reconnect_interval_reached = 0;
288288

289289
return (0);
290290
}
@@ -498,9 +498,9 @@ static int wg_config_node (oconfig_item_t *ci)
498498
cb->node = strdup (WG_DEFAULT_NODE);
499499
cb->service = strdup (WG_DEFAULT_SERVICE);
500500
cb->protocol = strdup (WG_DEFAULT_PROTOCOL);
501-
cb->last_force_reconnect_time = cdtime();
502-
cb->force_reconnect_timeout = 0;
503-
cb->conn_forced_closed = 0;
501+
cb->last_reconnect_time = cdtime();
502+
cb->reconnect_interval = 0;
503+
cb->reconnect_interval_reached = 0;
504504
cb->log_send_errors = WG_DEFAULT_LOG_SEND_ERRORS;
505505
cb->prefix = NULL;
506506
cb->postfix = NULL;
@@ -541,8 +541,8 @@ static int wg_config_node (oconfig_item_t *ci)
541541
status = -1;
542542
}
543543
}
544-
else if (strcasecmp ("ForceReconnectTimeout", child->key) == 0)
545-
cf_util_get_cdtime (child, &cb->force_reconnect_timeout);
544+
else if (strcasecmp ("ReconnectInterval", child->key) == 0)
545+
cf_util_get_cdtime (child, &cb->reconnect_interval);
546546
else if (strcasecmp ("LogSendErrors", child->key) == 0)
547547
cf_util_get_boolean (child, &cb->log_send_errors);
548548
else if (strcasecmp ("Prefix", child->key) == 0)

0 commit comments

Comments
 (0)