+ status = (*func) (&j);
+ if (status != 0)
+ break;
+ }
+ bson_destroy (&subobj);
+
+ return (status);
+} /* }}} int handle_field */
+
+static int handle_opcounters (bson_iterator *iter) /* {{{ */
+{
+ bson_type type;
+ const char *key;
+ derive_t value;
+
+ type = bson_iterator_type (iter);
+ if ((type != bson_long) && (type != bson_int))
+ return (0);
+
+ key = bson_iterator_key (iter);
+ if (key == NULL)
+ return (0);
+
+ value = (derive_t) bson_iterator_long (iter);
+
+ submit_derive ("total_operations", key, value);
+ return (0);
+} /* }}} int handle_opcounters */
+
+static int handle_mem (bson_iterator *iter) /* {{{ */
+{
+ bson_type type;
+ const char *key;
+ gauge_t value;
+
+ type = bson_iterator_type (iter);
+ if ((type != bson_double) && (type != bson_long) && (type != bson_int))
+ return (0);
+
+ key = bson_iterator_key (iter);
+ if (key == NULL)
+ return (0);
+
+ /* Is "virtual" really interesting?
+ * What exactly does "mapped" mean? */
+ if ((strcasecmp ("mapped", key) != 0)
+ && (strcasecmp ("resident", key) != 0)
+ && (strcasecmp ("virtual", key) != 0))
+ return (0);
+
+ value = (gauge_t) bson_iterator_double (iter);
+ /* All values are in MByte */
+ value *= 1048576.0;
+
+ submit_gauge ("memory", key, value);
+ return (0);
+} /* }}} int handle_mem */
+
+static int handle_connections (bson_iterator *iter) /* {{{ */
+{
+ bson_type type;
+ const char *key;
+ gauge_t value;
+
+ type = bson_iterator_type (iter);
+ if ((type != bson_double) && (type != bson_long) && (type != bson_int))
+ return (0);
+
+ key = bson_iterator_key (iter);
+ if (key == NULL)
+ return (0);
+
+ if (strcmp ("current", key) != 0)
+ return (0);
+
+ value = (gauge_t) bson_iterator_double (iter);
+
+ submit_gauge ("current_connections", NULL, value);
+ return (0);
+} /* }}} int handle_connections */
+
+static int handle_lock (bson_iterator *iter) /* {{{ */
+{
+ bson_type type;
+ const char *key;
+ derive_t value;
+
+ type = bson_iterator_type (iter);
+ if ((type != bson_double) && (type != bson_long) && (type != bson_int))
+ return (0);
+
+ key = bson_iterator_key (iter);
+ if (key == NULL)
+ return (0);
+
+ if (strcmp ("lockTime", key) != 0)
+ return (0);
+
+ value = (derive_t) bson_iterator_long (iter);
+ /* The time is measured in microseconds (us). We convert it to
+ * milliseconds (ms). */
+ value = value / 1000;
+
+ submit_derive ("total_time_in_ms", "lock_held", value);
+ return (0);
+} /* }}} int handle_lock */
+
+static int handle_btree (bson *obj) /* {{{ */
+{
+ bson_iterator i;
+
+ bson_iterator_init (&i, obj->data);
+ while (bson_iterator_next (&i))
+ {
+ bson_type type;