Merge branch 'collectd-5.7'
[collectd.git] / src / sensors.c
index 189a17e..2c09006 100644 (file)
@@ -367,6 +367,9 @@ static int sensors_load_conf(void) {
       if ((feature->type != SENSORS_FEATURE_IN) &&
           (feature->type != SENSORS_FEATURE_FAN) &&
           (feature->type != SENSORS_FEATURE_TEMP) &&
+#if SENSORS_API_VERSION >= 0x402
+          (feature->type != SENSORS_FEATURE_CURR) &&
+#endif
           (feature->type != SENSORS_FEATURE_POWER)) {
         DEBUG("sensors plugin: sensors_load_conf: "
               "Ignoring feature `%s', "
@@ -383,6 +386,9 @@ static int sensors_load_conf(void) {
         if ((subfeature->type != SENSORS_SUBFEATURE_IN_INPUT) &&
             (subfeature->type != SENSORS_SUBFEATURE_FAN_INPUT) &&
             (subfeature->type != SENSORS_SUBFEATURE_TEMP_INPUT) &&
+#if SENSORS_API_VERSION >= 0x402
+            (subfeature->type != SENSORS_SUBFEATURE_CURR_INPUT) &&
+#endif
             (subfeature->type != SENSORS_SUBFEATURE_POWER_INPUT))
           continue;
 
@@ -424,11 +430,10 @@ static int sensors_shutdown(void) {
 } /* int sensors_shutdown */
 
 static void sensors_submit(const char *plugin_instance, const char *type,
-                           const char *type_instance, double val) {
+                           const char *type_instance, double value) {
   char match_key[1024];
   int status;
 
-  value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;
 
   status = ssnprintf(match_key, sizeof(match_key), "%s/%s-%s", plugin_instance,
@@ -442,12 +447,9 @@ static void sensors_submit(const char *plugin_instance, const char *type,
       return;
   }
 
-  values[0].gauge = val;
-
-  vl.values = values;
+  vl.values = &(value_t){.gauge = value};
   vl.values_len = 1;
 
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, "sensors", sizeof(vl.plugin));
   sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
   sstrncpy(vl.type, type, sizeof(vl.type));
@@ -517,6 +519,10 @@ static int sensors_read(void) {
       type = "temperature";
     else if (fl->feature->type == SENSORS_FEATURE_POWER)
       type = "power";
+#if SENSORS_API_VERSION >= 0x402
+    else if (fl->feature->type == SENSORS_FEATURE_CURR)
+      type = "current";
+#endif
     else
       continue;