X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsensors.c;h=63a1c8ee01ae6f56bd10c081194b3f53b9680651;hb=edd9af8a874ebc9f2a7f02846807229a648917db;hp=852b41c1c47e80e8dccb08821482a8ddfd575265;hpb=5841d1fb13436af787c748a965084cb06e66d326;p=collectd.git diff --git a/src/sensors.c b/src/sensors.c index 852b41c1..63a1c8ee 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -140,7 +140,8 @@ static const char *config_keys[] = { "Sensor", "IgnoreSelected", - "SensorConfigFile" + "SensorConfigFile", + "UseLabels" }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); @@ -169,6 +170,7 @@ typedef struct featurelist } featurelist_t; static char *conffile = NULL; +static _Bool use_labels = 0; /* #endif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */ #else /* if SENSORS_API_VERSION >= 0x500 */ @@ -257,6 +259,12 @@ static int sensors_config (const char *key, const char *value) if (IS_TRUE (value)) ignorelist_set_invert (sensor_list, 0); } +#if (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) + else if (strcasecmp (key, "UseLabels") == 0) + { + use_labels = IS_TRUE (value) ? 1 : 0; + } +#endif else { return (-1); @@ -553,6 +561,7 @@ static int sensors_read (void) int status; char plugin_instance[DATA_MAX_NAME_LEN]; char type_instance[DATA_MAX_NAME_LEN]; + char *sensor_label; const char *type; status = sensors_get_value (fl->chip, @@ -565,8 +574,17 @@ static int sensors_read (void) if (status < 0) continue; - sstrncpy (type_instance, fl->feature->name, - sizeof (type_instance)); + if (use_labels) + { + sensor_label = sensors_get_label (fl->chip, fl->feature); + sstrncpy (type_instance, sensor_label, sizeof (type_instance)); + free (sensor_label); + } + else + { + sstrncpy (type_instance, fl->feature->name, + sizeof (type_instance)); + } if (fl->feature->type == SENSORS_FEATURE_IN) type = "voltage";