projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Run all changed files 68 8.c/1 *.h through clang-format agin..
[collectd.git]
/
src
/
write_graphite.c
diff --git
a/src/write_graphite.c
b/src/write_graphite.c
index
1aa07f1
..
cb6793d
100644
(file)
--- a/
src/write_graphite.c
+++ b/
src/write_graphite.c
@@
-29,7
+29,7
@@
* Based on the write_http plugin.
**/
* Based on the write_http plugin.
**/
-/* write_graphite plugin configuation example
+/* write_graphite plugin configu
r
ation example
*
* <Plugin write_graphite>
* <Carbon>
*
* <Plugin write_graphite>
* <Carbon>
@@
-38,17
+38,19
@@
* Protocol "udp"
* LogSendErrors true
* Prefix "collectd"
* Protocol "udp"
* LogSendErrors true
* Prefix "collectd"
+ * UseTags true
+ * ReverseHost false
* </Carbon>
* </Plugin>
*/
#include "collectd.h"
* </Carbon>
* </Plugin>
*/
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
+#include "utils/common/common.h"
+#include "utils/format_graphite/format_graphite.h"
#include "utils_complain.h"
#include "utils_complain.h"
-#include "utils_format_graphite.h"
#include <netdb.h>
#include <netdb.h>
@@
-65,7
+67,7
@@
#endif
#ifndef WG_DEFAULT_LOG_SEND_ERRORS
#endif
#ifndef WG_DEFAULT_LOG_SEND_ERRORS
-#define WG_DEFAULT_LOG_SEND_ERRORS
1
+#define WG_DEFAULT_LOG_SEND_ERRORS
true
#endif
#ifndef WG_DEFAULT_ESCAPE
#endif
#ifndef WG_DEFAULT_ESCAPE
@@
-92,7
+94,7
@@
struct wg_callback {
char *node;
char *service;
char *protocol;
char *node;
char *service;
char *protocol;
-
_B
ool log_send_errors;
+
b
ool log_send_errors;
char *prefix;
char *postfix;
char escape_char;
char *prefix;
char *postfix;
char escape_char;
@@
-111,7
+113,7
@@
struct wg_callback {
/* Force reconnect useful for load balanced environments */
cdtime_t last_reconnect_time;
cdtime_t reconnect_interval;
/* Force reconnect useful for load balanced environments */
cdtime_t last_reconnect_time;
cdtime_t reconnect_interval;
-
_B
ool reconnect_interval_reached;
+
b
ool reconnect_interval_reached;
};
/* wg_force_reconnect_check closes cb->sock_fd when it was open for longer
};
/* wg_force_reconnect_check closes cb->sock_fd when it was open for longer
@@
-131,7
+133,7
@@
static void wg_force_reconnect_check(struct wg_callback *cb) {
close(cb->sock_fd);
cb->sock_fd = -1;
cb->last_reconnect_time = now;
close(cb->sock_fd);
cb->sock_fd = -1;
cb->last_reconnect_time = now;
- cb->reconnect_interval_reached =
1
;
+ cb->reconnect_interval_reached =
true
;
INFO("write_graphite plugin: Connection closed after %.3f seconds.",
CDTIME_T_TO_DOUBLE(now - cb->last_reconnect_time));
INFO("write_graphite plugin: Connection closed after %.3f seconds.",
CDTIME_T_TO_DOUBLE(now - cb->last_reconnect_time));
@@
-175,7
+177,7
@@
static int wg_flush_nolock(cdtime_t timeout, struct wg_callback *cb) {
int status;
DEBUG("write_graphite plugin: wg_flush_nolock: timeout = %.3f; "
int status;
DEBUG("write_graphite plugin: wg_flush_nolock: timeout = %.3f; "
- "send_buf_fill = %
zu
;",
+ "send_buf_fill = %
" PRIsz "
;",
(double)timeout, cb->send_buf_fill);
/* timeout == 0 => flush unconditionally */
(double)timeout, cb->send_buf_fill);
/* timeout == 0 => flush unconditionally */
@@
-274,7
+276,7
@@
static int wg_callback_init(struct wg_callback *cb) {
if (!cb->reconnect_interval_reached || (cb->send_buf_free == 0))
wg_reset_buffer(cb);
else
if (!cb->reconnect_interval_reached || (cb->send_buf_free == 0))
wg_reset_buffer(cb);
else
- cb->reconnect_interval_reached =
0
;
+ cb->reconnect_interval_reached =
false
;
return 0;
}
return 0;
}
@@
-303,6
+305,7
@@
static void wg_callback_free(void *data) {
sfree(cb->prefix);
sfree(cb->postfix);
sfree(cb->prefix);
sfree(cb->postfix);
+ pthread_mutex_unlock(&cb->send_lock);
pthread_mutex_destroy(&cb->send_lock);
sfree(cb);
pthread_mutex_destroy(&cb->send_lock);
sfree(cb);
@@
-372,7
+375,8
@@
static int wg_send_message(char const *message, struct wg_callback *cb) {
cb->send_buf_fill += message_len;
cb->send_buf_free -= message_len;
cb->send_buf_fill += message_len;
cb->send_buf_free -= message_len;
- DEBUG("write_graphite plugin: [%s]:%s (%s) buf %zu/%zu (%.1f %%) \"%s\"",
+ DEBUG("write_graphite plugin: [%s]:%s (%s) buf %" PRIsz "/%" PRIsz
+ " (%.1f %%) \"%s\"",
cb->node, cb->service, cb->protocol, cb->send_buf_fill,
sizeof(cb->send_buf),
100.0 * ((double)cb->send_buf_fill) / ((double)sizeof(cb->send_buf)),
cb->node, cb->service, cb->protocol, cb->send_buf_fill,
sizeof(cb->send_buf),
100.0 * ((double)cb->send_buf_fill) / ((double)sizeof(cb->send_buf)),
@@
-464,7
+468,7
@@
static int wg_config_node(oconfig_item_t *ci) {
cb->protocol = strdup(WG_DEFAULT_PROTOCOL);
cb->last_reconnect_time = cdtime();
cb->reconnect_interval = 0;
cb->protocol = strdup(WG_DEFAULT_PROTOCOL);
cb->last_reconnect_time = cdtime();
cb->reconnect_interval = 0;
- cb->reconnect_interval_reached =
0
;
+ cb->reconnect_interval_reached =
false
;
cb->log_send_errors = WG_DEFAULT_LOG_SEND_ERRORS;
cb->prefix = NULL;
cb->postfix = NULL;
cb->log_send_errors = WG_DEFAULT_LOG_SEND_ERRORS;
cb->prefix = NULL;
cb->postfix = NULL;
@@
-516,6
+520,10
@@
static int wg_config_node(oconfig_item_t *ci) {
cf_util_get_flag(child, &cb->format_flags, GRAPHITE_PRESERVE_SEPARATOR);
else if (strcasecmp("DropDuplicateFields", child->key) == 0)
cf_util_get_flag(child, &cb->format_flags, GRAPHITE_DROP_DUPE_FIELDS);
cf_util_get_flag(child, &cb->format_flags, GRAPHITE_PRESERVE_SEPARATOR);
else if (strcasecmp("DropDuplicateFields", child->key) == 0)
cf_util_get_flag(child, &cb->format_flags, GRAPHITE_DROP_DUPE_FIELDS);
+ else if (strcasecmp("UseTags", child->key) == 0)
+ cf_util_get_flag(child, &cb->format_flags, GRAPHITE_USE_TAGS);
+ else if (strcasecmp("ReverseHost", child->key) == 0)
+ cf_util_get_flag(child, &cb->format_flags, GRAPHITE_REVERSE_HOST);
else if (strcasecmp("EscapeCharacter", child->key) == 0)
config_set_char(&cb->escape_char, child);
else {
else if (strcasecmp("EscapeCharacter", child->key) == 0)
config_set_char(&cb->escape_char, child);
else {