Code

core: Changed internal API to allow for per-plugin intervals.
[collectd.git] / src / curl_xml.c
index 240be6628bc4a258b88d6d1308e746693c036e1b..56cf6f727414506e184fb9a105560d34987eb4da 100644 (file)
@@ -429,7 +429,7 @@ static int  cx_handle_base_xpath (char *plugin_instance, /* {{{ */
   xmlXPathObjectPtr base_node_obj = NULL;
   xmlNodeSetPtr base_nodes = NULL;
 
-  value_list_t vl = VALUE_LIST_INIT;
+  value_list_t vl = VALUE_LIST_INIT (plugin_interval);
 
   base_node_obj = cx_evaluate_xpath (xpath_ctx, BAD_CAST base_xpath); 
   if (base_node_obj == NULL)
@@ -734,6 +734,7 @@ static int cx_init_curl (cx_t *db) /* {{{ */
     return (-1);
   }
 
+  curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1);
   curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cx_curl_callback);
   curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db);
   curl_easy_setopt (db->curl, CURLOPT_USERAGENT,
@@ -856,6 +857,7 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
   {
     user_data_t ud;
     char cb_name[DATA_MAX_NAME_LEN];
+    struct timespec cb_interval;
 
     if (db->instance == NULL)
       db->instance = strdup("default");
@@ -869,9 +871,14 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
 
     ssnprintf (cb_name, sizeof (cb_name), "curl_xml-%s-%s",
                db->instance, db->url);
+    CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval);
 
-    plugin_register_complex_read (cb_name, cx_read,
-                                  /* interval = */ NULL, &ud);
+    plugin_register_complex_read (/* group = */ NULL,
+                                  /* name = */ cb_name,
+                                  /* callback = */ cx_read,
+                                  /* interval = */ (plugin_interval != 0)
+                                    ? &cb_interval : NULL,
+                                  /* user_data = */ &ud);
   }
   else
   {
@@ -922,8 +929,9 @@ static int cx_config (oconfig_item_t *ci) /* {{{ */
   return (0);
 } /* }}} int cx_config */
 
-void module_register (void)
+void module_register (plugin_loaddata_t *data)
 {
+  PLUGIN_INIT_INTERVAL (data);
   plugin_register_complex_config ("curl_xml", cx_config);
 } /* void module_register */