summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 67ea18d)
raw | patch | inline | side by side (parent: 67ea18d)
author | Christian Fetzer <fetzer.ch@gmail.com> | |
Mon, 24 Aug 2015 07:49:21 +0000 (09:49 +0200) | ||
committer | Christian Fetzer <fetzer.ch@gmail.com> | |
Thu, 3 Sep 2015 06:48:44 +0000 (08:48 +0200) |
Adds an option UseLabels to configure how sensor readings are
reported. The default reports readings using the sensor name (e.g.
"in0"). With this option set to true, the readings are reported using
the label (e.g. "VCore").
reported. The default reports readings using the sensor name (e.g.
"in0"). With this option set to true, the readings are reported using
the label (e.g. "VCore").
src/collectd.conf.pod | patch | blob | history | |
src/sensors.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index aaeeaf419b703913392ef5e78448ffa76fc451dc..78a348b33db624c902908d67c844aa0ae0c42945 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -6031,6 +6031,12 @@ few ones. This option enables you to do that: By setting B<IgnoreSelected> to
I<true> the effect of B<Sensor> is inverted: All selected sensors are ignored
and all other sensors are collected.
+=item B<UseLabels> I<true>|I<false>
+
+Configures how sensor readings are reported. When set to I<true>, sensor
+readings are reported using their descriptive label (e.g. "VCore"). When set to
+I<false> (the default) the sensor name is used ("in0").
+
=back
=head2 Plugin C<sigrok>
diff --git a/src/sensors.c b/src/sensors.c
index f5b09bd29be1c501fd2a807b78eb753f14683a56..2f3695f264401caa44b5feba6decfdec31636714 100644 (file)
--- a/src/sensors.c
+++ b/src/sensors.c
{
"Sensor",
"IgnoreSelected",
- "SensorConfigFile"
+ "SensorConfigFile",
+ "UseLabels"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
} 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 */
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);
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,
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";