+ bson_append_finish_array (ret); /* }}} values */
+
+ bson_append_start_array (ret, "dstypes"); /* {{{ */
+ for (i = 0; i < ds->ds_num; i++)
+ {
+ char key[16];
+
+ ssnprintf (key, sizeof (key), "%i", i);
+
+ if (store_rates)
+ bson_append_string (ret, key, "gauge");
+ else
+ bson_append_string (ret, key, DS_TYPE_TO_STRING (ds->ds[i].type));
+ }
+ bson_append_finish_array (ret); /* }}} dstypes */
+
+ bson_append_start_array (ret, "dsnames"); /* {{{ */
+ for (i = 0; i < ds->ds_num; i++)
+ {
+ char key[16];
+
+ ssnprintf (key, sizeof (key), "%i", i);
+ bson_append_string (ret, key, ds->ds[i].name);
+ }
+ bson_append_finish_array (ret); /* }}} dsnames */
+
+ bson_finish (ret);
+
+ sfree (rates);
+ return (ret);
+} /* }}} bson *wm_create_bson */
+
+static int wm_write (const data_set_t *ds, /* {{{ */
+ const value_list_t *vl,
+ user_data_t *ud)
+{
+ wm_node_t *node = ud->data;
+ char collection_name[512];
+ bson *bson_record;
+ int status;
+
+ ssnprintf (collection_name, sizeof (collection_name), "collectd.%s",
+ vl->plugin);
+
+ bson_record = wm_create_bson (ds, vl, node->store_rates);
+ if (bson_record == NULL)
+ return (ENOMEM);