Code

core: Changed internal API to allow for per-plugin intervals.
[collectd.git] / src / routeros.c
index d61ffe984d36cfa2eaa3b74efce9872abdc9d648..c35a0483bf2a40fb1788fd6ea1541fcc5ac39b78 100644 (file)
@@ -47,7 +47,7 @@ static void cr_submit_io (cr_data_t *rd, const char *type, /* {{{ */
     const char *type_instance, derive_t rx, derive_t tx)
 {
        value_t values[2];
-       value_list_t vl = VALUE_LIST_INIT;
+       value_list_t vl = VALUE_LIST_INIT (plugin_interval);
 
        values[0].derive = rx;
        values[1].derive = tx;
@@ -100,7 +100,7 @@ static void cr_submit_gauge (cr_data_t *rd, const char *type, /* {{{ */
     const char *type_instance, gauge_t value)
 {
        value_t values[1];
-       value_list_t vl = VALUE_LIST_INIT;
+       value_list_t vl = VALUE_LIST_INIT (plugin_interval);
 
        values[0].gauge = value;
 
@@ -119,7 +119,7 @@ static void cr_submit_counter (cr_data_t *rd, const char *type, /* {{{ */
     const char *type_instance, derive_t value)
 {
        value_t values[1];
-       value_list_t vl = VALUE_LIST_INIT;
+       value_list_t vl = VALUE_LIST_INIT (plugin_interval);
 
        values[0].derive = value;
 
@@ -319,6 +319,7 @@ static int cr_config_router (oconfig_item_t *ci) /* {{{ */
 {
   cr_data_t *router_data;
   char read_name[128];
+  struct timespec read_interval;
   user_data_t user_data;
   int status;
   int i;
@@ -405,11 +406,15 @@ static int cr_config_router (oconfig_item_t *ci) /* {{{ */
   }
 
   ssnprintf (read_name, sizeof (read_name), "routeros/%s", router_data->node);
+  CDTIME_T_TO_TIMESPEC (plugin_interval, &read_interval);
   user_data.data = router_data;
   user_data.free_func = (void *) cr_free_data;
   if (status == 0)
-    status = plugin_register_complex_read (/* group = */ NULL, read_name,
-       cr_read, /* interval = */ NULL, &user_data);
+    status = plugin_register_complex_read (/* group = */ NULL,
+       /* name = */ read_name,
+       /* callback = */ cr_read,
+       /* interval = */ (plugin_interval > 0) ? &read_interval : NULL,
+       /* user_data = */ &user_data);
 
   if (status != 0)
     cr_free_data (router_data);
@@ -436,8 +441,9 @@ static int cr_config (oconfig_item_t *ci)
   return (0);
 } /* }}} int cr_config */
 
-void module_register (void)
+void module_register (plugin_loaddata_t *data)
 {
+  PLUGIN_INIT_INTERVAL (data);
   plugin_register_complex_config ("routeros", cr_config);
 } /* void module_register */