X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_graphite.c;h=c17b7f36a6dc787e1eeac749388f5a8f6c5e8123;hb=67411e0794cfcab38e322b2ebbe2e5207cbdd86a;hp=6124d33edf5a07ae26f922b1cc7a151a959b6c28;hpb=10b92353ea2ccf66eabad273799c36225d2efc3f;p=collectd.git diff --git a/src/write_graphite.c b/src/write_graphite.c index 6124d33e..c17b7f36 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -67,7 +67,7 @@ #endif #ifndef WG_DEFAULT_PROTOCOL -# define WG_DEFAULT_PROTOCOL "udp" +# define WG_DEFAULT_PROTOCOL "tcp" #endif #ifndef WG_DEFAULT_LOG_SEND_ERRORS @@ -128,13 +128,17 @@ static int wg_send_buffer (struct wg_callback *cb) ssize_t status = 0; status = swrite (cb->sock_fd, cb->send_buf, strlen (cb->send_buf)); - if (cb->log_send_errors && status < 0) + if (status < 0) { - char errbuf[1024]; - ERROR ("write_graphite plugin: send to %s:%s (%s) failed with status %zi (%s)", - cb->node, cb->service, cb->protocol, - status, sstrerror (errno, errbuf, sizeof (errbuf))); + const char *protocol = cb->protocol ? cb->protocol : WG_DEFAULT_PROTOCOL; + if (cb->log_send_errors) + { + char errbuf[1024]; + ERROR ("write_graphite plugin: send to %s:%s (%s) failed with status %zi (%s)", + cb->node, cb->service, protocol, + status, sstrerror (errno, errbuf, sizeof (errbuf))); + } close (cb->sock_fd); cb->sock_fd = -1;