summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df69fe8)
raw | patch | inline | side by side (parent: df69fe8)
author | Luke Heberling <collectd@c-ware.com> | |
Sun, 30 Aug 2009 19:41:13 +0000 (12:41 -0700) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 3 Jun 2010 12:48:31 +0000 (14:48 +0200) |
powerdns version 2.9.22 (and above) require a newline at the end of
commands sent to the server.
Signed-off-by: Sebastian Harl <tokkee@debian.org>
commands sent to the server.
Signed-off-by: Sebastian Harl <tokkee@debian.org>
src/powerdns.c | patch | blob | history |
diff --git a/src/powerdns.c b/src/powerdns.c
index 3e7ebb339b6a044eb2bca7e64cc38d5127aa74c4..29f6bca502c7b48be0ecbadd2bc4befabf337885 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
#define FUNC_ERROR(func) do { char errbuf[1024]; ERROR ("powerdns plugin: %s failed: %s", func, sstrerror (errno, errbuf, sizeof (errbuf))); } while (0)
#define SERVER_SOCKET LOCALSTATEDIR"/run/pdns.controlsocket"
-#define SERVER_COMMAND "SHOW *"
+#define SERVER_COMMAND "SHOW * \n"
#define RECURSOR_SOCKET LOCALSTATEDIR"/run/pdns_recursor.controlsocket"
#define RECURSOR_COMMAND "get noerror-answers nxdomain-answers " \
"servfail-answers sys-msec user-msec qa-latency cache-entries cache-hits " \
- "cache-misses questions"
+ "cache-misses questions\n"
struct list_item_s;
typedef struct list_item_s list_item_t;
return (-1);
}
+ struct timeval timeout;
+ timeout.tv_sec=5;
+ timeout.tv_usec=0;
+ status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout));
+
status = connect (sd, (struct sockaddr *) &item->sockaddr,
sizeof (item->sockaddr));
if (status != 0)
int fields_num;
if (item->command == NULL)
- item->command = strdup ("SHOW *");
+ item->command = strdup (SERVER_COMMAND);
if (item->command == NULL)
{
ERROR ("powerdns plugin: strdup failed.");
else
{
sstrncpy (buffer, "get ", sizeof (buffer));
- status = strjoin (&buffer[4], sizeof (buffer) - strlen ("get "),
+ status = strjoin (&buffer[strlen("get ")], sizeof (buffer) - strlen ("get "),
li->fields, li->fields_num,
/* seperator = */ " ");
if (status < 0)
ERROR ("powerdns plugin: strjoin failed.");
return (-1);
}
+ buffer[sizeof (buffer) - 1] = 0;
+ int i = strlen (buffer);
+ if (i < sizeof (buffer) - 2)
+ {
+ buffer[i++] = ' ';
+ buffer[i++] = '\n';
+ buffer[i++] = '\0';
+ }
}
buffer[sizeof (buffer) - 1] = 0;