X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fwrite_graphite.c;h=c17b7f36a6dc787e1eeac749388f5a8f6c5e8123;hb=de155ccd5c6ec9f58ae26ef8041b0b634c9d59cf;hp=667c11e3dd9aca469c438c27d477fb718b6ad904;hpb=6be256a584f4d19d105f6fa06e5634cedc21db64;p=collectd.git diff --git a/src/write_graphite.c b/src/write_graphite.c index 667c11e3..c17b7f36 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -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;