summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c87e3fc)
raw | patch | inline | side by side (parent: c87e3fc)
author | Florian Forster <octo@noris.net> | |
Mon, 5 May 2008 14:20:38 +0000 (16:20 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Mon, 5 May 2008 14:20:38 +0000 (16:20 +0200) |
src/powerdns.c | patch | blob | history |
diff --git a/src/powerdns.c b/src/powerdns.c
index d91ce5baada860dc1820c804425fc3c959da0519..799a1185bd74c8fcf7155703669b574fc2909f75 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
user-msec number of CPU milliseconds spent in 'user' mode
}}} */
+const char* const default_server_fields[] = /* {{{ */
+{
+ "latency"
+ "packetcache-hit",
+ "packetcache-miss",
+ "packetcache-size",
+ "query-cache-hit",
+ "query-cache-miss",
+ "recursing-answers",
+ "recursing-questions",
+ "tcp-answers",
+ "tcp-queries",
+ "udp-answers",
+ "udp-queries",
+}; /* }}} */
+int default_server_fields_num = STATIC_ARRAY_SIZE (default_server_fields);
+
statname_lookup_t lookup_table[] = /* {{{ */
{
/*********************
char *key;
char *value;
+ const char* const *fields;
+ int fields_num;
+
if (item->command == NULL)
item->command = strdup ("SHOW *");
if (item->command == NULL)
if (status != 0)
return (-1);
+ if (item->fields_num != 0)
+ {
+ fields = (const char* const *) item->fields;
+ fields_num = item->fields_num;
+ }
+ else
+ {
+ fields = default_server_fields;
+ fields_num = default_server_fields_num;
+ }
+
+ assert (fields != NULL);
+ assert (fields_num > 0);
+
/* corrupt-packets=0,deferred-cache-inserts=0,deferred-cache-lookup=0,latency=0,packetcache-hit=0,packetcache-miss=0,packetcache-size=0,qsize-q=0,query-cache-hit=0,query-cache-miss=0,recursing-answers=0,recursing-questions=0,servfail-packets=0,tcp-answers=0,tcp-queries=0,timedout-packets=0,udp-answers=0,udp-queries=0,udp4-answers=0,udp4-queries=0,udp6-answers=0,udp6-queries=0, */
dummy = buffer;
saveptr = NULL;
continue;
/* Check if this item was requested. */
- for (i = 0; i < item->fields_num; i++)
- if (strcasecmp (key, item->fields[i]) == 0)
+ for (i = 0; i < fields_num; i++)
+ if (strcasecmp (key, fields[i]) == 0)
break;
- if (i >= item->fields_num)
+ if (i >= fields_num)
continue;
submit (item->instance, key, value);
char buffer[4096];
int status;
- if (li != NULL)
+ if (li == NULL)
return (0);
- strcpy (buffer, "get ");
- status = strjoin (&buffer[4], sizeof (buffer) - strlen ("get "),
- li->fields, li->fields_num,
- /* seperator = */ " ");
- if (status < 0)
+ if (li->fields_num < 1)
{
- ERROR ("powerdns plugin: strjoin failed.");
- return (-1);
+ sstrncpy (buffer, RECURSOR_COMMAND, sizeof (buffer));
+ }
+ else
+ {
+ strcpy (buffer, "get ");
+ status = strjoin (&buffer[4], 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;
li->command = strdup (buffer);
if (li->command == NULL)
{