summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 714522f)
raw | patch | inline | side by side (parent: 714522f)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 19 Oct 2014 16:22:09 +0000 (18:22 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 19 Oct 2014 16:22:09 +0000 (18:22 +0200) |
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index 99c6f4d80a91a669ee0ac86f0bfe0620de6bb13f..392d57001310038bb65abaee93a6a3a1b27e706d 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
const char *node = cb->node ? cb->node : WG_DEFAULT_NODE;
const char *service = cb->service ? cb->service : WG_DEFAULT_SERVICE;
+ char connerr[1024] = "";
+
if (cb->sock_fd > 0)
return (0);
{
cb->sock_fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype,
ai_ptr->ai_protocol);
- if (cb->sock_fd < 0)
+ if (cb->sock_fd < 0) {
+ char errbuf[1024];
+ snprintf (connerr, sizeof (connerr), "failed to open socket: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
+ }
status = connect (cb->sock_fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0)
{
+ char errbuf[1024];
+ snprintf (connerr, sizeof (connerr), "failed to connect to remote "
+ "host: %s", sstrerror (errno, errbuf, sizeof (errbuf)));
close (cb->sock_fd);
cb->sock_fd = -1;
continue;
if (cb->sock_fd < 0)
{
- char errbuf[1024];
+ if (connerr[0] == '\0')
+ /* this should not happen but try to get a message anyway */
+ sstrerror (errno, connerr, sizeof (connerr));
c_complain (LOG_ERR, &cb->init_complaint,
"write_graphite plugin: Connecting to %s:%s failed. "
- "The last error was: %s", node, service,
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ "The last error was: %s", node, service, connerr);
return (-1);
}
else