author | Florian Forster <octo@collectd.org> | |
Sun, 21 Aug 2011 14:43:22 +0000 (16:43 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 21 Aug 2011 14:43:22 +0000 (16:43 +0200) |
Conflicts:
src/curl_json.c
src/libvirt.c
Change-Id: I0852495b416435fa3cfd36068d967e0cd5ff689f
src/curl_json.c
src/libvirt.c
Change-Id: I0852495b416435fa3cfd36068d967e0cd5ff689f
18 files changed:
1 | 2 | |||
---|---|---|---|---|
configure.in | patch | | diff1 | | diff2 | | blob | history |
src/apache.c | patch | | diff1 | | diff2 | | blob | history |
src/bind.c | patch | | diff1 | | diff2 | | blob | history |
src/csv.c | patch | | diff1 | | diff2 | | blob | history |
src/curl.c | patch | | diff1 | | diff2 | | blob | history |
src/curl_json.c | patch | | diff1 | | diff2 | | blob | history |
src/df.c | patch | | diff1 | | diff2 | | blob | history |
src/disk.c | patch | | diff1 | | diff2 | | blob | history |
src/java.c | patch | | diff1 | | diff2 | | blob | history |
src/libvirt.c | patch | | diff1 | | diff2 | | blob | history |
src/mysql.c | patch | | diff1 | | diff2 | | blob | history |
src/network.c | patch | | diff1 | | diff2 | | blob | history |
src/nginx.c | patch | | diff1 | | diff2 | | blob | history |
src/notify_email.c | patch | | diff1 | | diff2 | | blob | history |
src/processes.c | patch | | diff1 | | diff2 | | blob | history |
src/teamspeak2.c | patch | | diff1 | | diff2 | | blob | history |
src/utils_dns.c | patch | | diff1 | | diff2 | | blob | history |
src/write_http.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc configure.in
Simple merge
diff --cc src/apache.c
Simple merge
diff --cc src/bind.c
Simple merge
diff --cc src/csv.c
Simple merge
diff --cc src/curl.c
Simple merge
diff --cc src/curl_json.c
index 5549f0abf5d58a01876ae6479d2bc09455d2e23b,55527282ce6ff32a20da6b84062907e47234561a..988ed58df3442459d23ef25b20894df6f82ae21e
--- 1/src/curl_json.c
--- 2/src/curl_json.c
+++ b/src/curl_json.c
if (db == NULL)
return (0);
-- status = yajl_parse(db->yajl, (unsigned char *)buf, len);
- if ((status != yajl_status_ok)
- && (status != yajl_status_insufficient_data))
++ status = yajl_parse(db->yajl, (unsigned char *) buf, len);
+ if (status == yajl_status_ok)
+ {
+ #if HAVE_YAJL_V2
+ status = yajl_complete_parse(db->yajl);
+ #else
+ status = yajl_parse_complete(db->yajl);
+ #endif
+ return (len);
+ }
+ #if !HAVE_YAJL_V2
+ else if (status == yajl_status_insufficient_data)
+ return (len);
+ #endif
+
+ if (status != yajl_status_ok)
{
unsigned char *msg =
- yajl_get_error(db->yajl, 1, (unsigned char *)buf, len);
+ yajl_get_error(db->yajl, /* verbose = */ 1,
+ /* jsonText = */ (unsigned char *) buf, (unsigned int) len);
ERROR ("curl_json plugin: yajl_parse failed: %s", msg);
yajl_free_error(db->yajl, msg);
return (0); /* abort write callback */
}
static int cj_cb_string (void *ctx, const unsigned char *val,
- unsigned int len)
+ yajl_len_t len)
{
cj_t *db = (cj_t *)ctx;
- c_avl_tree_t *tree;
- char *ptr;
+ char str[len + 1];
- if (db->depth != 1) /* e.g. _all_dbs */
- return (CJ_CB_CONTINUE);
+ /* Create a null-terminated version of the string. */
+ memcpy (str, val, len);
+ str[len] = 0;
- cj_cb_map_key (ctx, val, len); /* same logic */
-
- tree = db->state[db->depth].tree;
+ /* No configuration for this string -> simply return. */
+ if (db->state[db->depth].key == NULL)
+ return (CJ_CB_CONTINUE);
- if ((tree != NULL) && (ptr = rindex (db->url, '/')))
+ if (!CJ_IS_KEY (db->state[db->depth].key))
{
- char url[PATH_MAX];
- CURL *curl;
-
- /* url =~ s,[^/]+$,$name, */
- len = (ptr - db->url) + 1;
- ptr = url;
- sstrncpy (ptr, db->url, sizeof (url));
- sstrncpy (ptr + len, db->state[db->depth].name, sizeof (url) - len);
-
- curl = curl_easy_duphandle (db->curl);
- curl_easy_setopt (curl, CURLOPT_URL, url);
- cj_curl_perform (db, curl);
- curl_easy_cleanup (curl);
+ NOTICE ("curl_json plugin: Found string \"%s\", but the configuration "
+ "expects a map here.", str);
+ return (CJ_CB_CONTINUE);
}
- return (CJ_CB_CONTINUE);
-}
+
+ /* Handle the string as if it was a number. */
+ return (cj_cb_number (ctx, (const char *) val, len));
+} /* int cj_cb_string */
static int cj_cb_start (void *ctx)
{
diff --cc src/df.c
Simple merge
diff --cc src/disk.c
index 697d850f662be2dde164a83397a0d0885a0c5887,6187459f8e93fd0088d6b5646f19b204e1e1827e..fde0dcde9abd5112c48633a6dcd588ef8bb0f69b
--- 1/src/disk.c
--- 2/src/disk.c
+++ b/src/disk.c
int numfields;
int fieldshift = 0;
- int major = 0;
int minor = 0;
- counter_t read_sectors = 0;
- counter_t write_sectors = 0;
+ derive_t read_sectors = 0;
+ derive_t write_sectors = 0;
- counter_t read_ops = 0;
- counter_t read_merged = 0;
- counter_t read_time = 0;
- counter_t write_ops = 0;
- counter_t write_merged = 0;
- counter_t write_time = 0;
+ derive_t read_ops = 0;
+ derive_t read_merged = 0;
+ derive_t read_time = 0;
+ derive_t write_ops = 0;
+ derive_t write_merged = 0;
+ derive_t write_time = 0;
int is_disk = 0;
diskstats_t *ds, *pre_ds;
diff --cc src/java.c
Simple merge
diff --cc src/libvirt.c
index c74b937e39a2bb7e1569cfd0fe22fc5592a3dba2,1f6287923fae47fbcd48bee83c660f66352da35c..774067cdf016a09e1c9279f9ec2e86d987a3fd0b
--- 1/src/libvirt.c
--- 2/src/libvirt.c
+++ b/src/libvirt.c
if (err) ERROR ("%s: %s", (s), err->message); \
} while(0)
- char *host_ptr;
- size_t host_len;
+static void
+init_value_list (value_list_t *vl, virDomainPtr dom)
+{
+ int i, n;
+ const char *name;
+ char uuid[VIR_UUID_STRING_BUFLEN];
- host_ptr = vl->host;
- host_len = sizeof (vl->host);
+
+ vl->interval = interval_g;
+
+ sstrncpy (vl->plugin, "libvirt", sizeof (vl->plugin));
+
+ vl->host[0] = '\0';
+
+ /* Construct the hostname field according to HostnameFormat. */
+ for (i = 0; i < HF_MAX_FIELDS; ++i) {
+ if (hostname_format[i] == hf_none)
+ continue;
+
+ n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
+
+ if (i > 0 && n >= 1) {
+ strncat (vl->host, ":", 1);
+ n--;
+ }
+
+ switch (hostname_format[i]) {
+ case hf_none: break;
+ case hf_hostname:
+ strncat (vl->host, hostname_g, n);
+ break;
+ case hf_name:
+ name = virDomainGetName (dom);
+ if (name)
+ strncat (vl->host, name, n);
+ break;
+ case hf_uuid:
+ if (virDomainGetUUIDString (dom, uuid) == 0)
+ strncat (vl->host, uuid, n);
+ break;
+ }
+ }
+
+ vl->host[sizeof (vl->host) - 1] = '\0';
+} /* void init_value_list */
+
+static void
+cpu_submit (unsigned long long cpu_time,
+ virDomainPtr dom, const char *type)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ init_value_list (&vl, dom);
+
+ values[0].derive = cpu_time;
+
+ vl.values = values;
+ vl.values_len = 1;
+
+ sstrncpy (vl.type, type, sizeof (vl.type));
+
+ plugin_dispatch_values (&vl);
+}
+
+static void
+vcpu_submit (derive_t cpu_time,
+ virDomainPtr dom, int vcpu_nr, const char *type)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ init_value_list (&vl, dom);
+
+ values[0].derive = cpu_time;
+ vl.values = values;
+ vl.values_len = 1;
+
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
+
+ plugin_dispatch_values (&vl);
+}
+
+static void
+submit_derive2 (const char *type, derive_t v0, derive_t v1,
+ virDomainPtr dom, const char *devname)
+{
+ value_t values[2];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ init_value_list (&vl, dom);
+
+ values[0].derive = v0;
+ values[1].derive = v1;
+ vl.values = values;
+ vl.values_len = 2;
+
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+} /* void submit_derive2 */
+
static int
lv_init (void)
{
diff --cc src/mysql.c
index cae6760b1d1f50f3d8cfe06413712112367722d0,69df7c708acce1c9f19a034cb2eb094590d46a02..6b636787555b7e177a09abf20b71cd7cbbb7f9a7
--- 1/src/mysql.c
--- 2/src/mysql.c
+++ b/src/mysql.c
MYSQL_RES *res;
MYSQL_ROW row;
char *query;
- int field_num;
- unsigned long long qcache_hits = 0ULL;
- unsigned long long qcache_inserts = 0ULL;
- unsigned long long qcache_not_cached = 0ULL;
- unsigned long long qcache_lowmem_prunes = 0ULL;
- int qcache_queries_in_cache = -1;
+ derive_t qcache_hits = 0;
+ derive_t qcache_inserts = 0;
+ derive_t qcache_not_cached = 0;
+ derive_t qcache_lowmem_prunes = 0;
+ gauge_t qcache_queries_in_cache = NAN;
- int threads_running = -1;
- int threads_connected = -1;
- int threads_cached = -1;
- unsigned long long threads_created = 0ULL;
+ gauge_t threads_running = NAN;
+ gauge_t threads_connected = NAN;
+ gauge_t threads_cached = NAN;
+ derive_t threads_created = 0;
unsigned long long traffic_incoming = 0ULL;
unsigned long long traffic_outgoing = 0ULL;
diff --cc src/network.c
Simple merge
diff --cc src/nginx.c
Simple merge
diff --cc src/notify_email.c
index da6894a3db4dc8d0de24fbde2408ff03f194f47a,6b4678a7882a22baa010a569ba06cf1e7993ab6b..cd216ca2da753a2e1a2895486f706c62c280e42d
--- 1/src/notify_email.c
--- 2/src/notify_email.c
+++ b/src/notify_email.c
static int notify_email_notification (const notification_t *n,
user_data_t __attribute__((unused)) *user_data)
{
- smtp_recipient_t recipient;
+ time_t tt;
struct tm timestamp_tm;
char timestamp_str[64];
diff --cc src/processes.c
index 72442f093f080b1aae99d99f6eb5f54443e48875,bab7080faa753eb8c80605bef8712dfe41b560a4..0c24cb70bb5a83f72543c949a0f37e021cf5280c
--- 1/src/processes.c
--- 2/src/processes.c
+++ b/src/processes.c
int i;
- int ppid;
int name_len;
- long long unsigned cpu_user_counter;
- long long unsigned cpu_system_counter;
+ derive_t cpu_user_counter;
+ derive_t cpu_system_counter;
long long unsigned vmem_size;
long long unsigned vmem_rss;
long long unsigned stack_size;
diff --cc src/teamspeak2.c
Simple merge
diff --cc src/utils_dns.c
Simple merge
diff --cc src/write_http.c
Simple merge