# define SENSORS_HAVE_READ 0
#endif
-static data_source_t data_source_fanspeed[1] =
-{
- {"value", DS_TYPE_GAUGE, 0, NAN}
-};
-
-static data_set_t fanspeed_ds =
-{
- "fanspeed", 1, data_source_fanspeed
-};
-
-static data_source_t data_source_temperature[1] =
-{
- {"value", DS_TYPE_GAUGE, -273.15, NAN}
-};
-
-static data_set_t temperature_ds =
-{
- "temperature", 1, data_source_temperature
-};
-
-static data_source_t data_source_voltage[1] =
-{
- {"value", DS_TYPE_GAUGE, NAN, NAN}
-};
-
-static data_set_t voltage_ds =
-{
- "voltage", 1, data_source_voltage
-};
-
#if SENSORS_HAVE_READ
#define SENSOR_TYPE_VOLTAGE 0
#define SENSOR_TYPE_FANSPEED 1
{ "3.3V", SENSOR_TYPE_VOLTAGE },
{ "2.5V", SENSOR_TYPE_VOLTAGE },
{ "2.0V", SENSOR_TYPE_VOLTAGE },
- { "12V", SENSOR_TYPE_VOLTAGE },
- { (char *) 0, SENSOR_TYPE_UNKNOWN }
+ { "12V", SENSOR_TYPE_VOLTAGE }
};
+static int known_features_num = STATIC_ARRAY_SIZE (known_features);
/* end new naming */
static const char *config_keys[] =
status = stat (conffile, &statbuf);
if (status != 0)
{
- ERROR ("sensors plugin: stat (%s) failed: %s",
- conffile, strerror (errno));
+ char errbuf[1024];
+ ERROR ("sensors plugin: stat (%s) failed: %s", conffile,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
sensors_config_mtime = 0;
}
fh = fopen (conffile, "r");
if (fh == NULL)
{
- ERROR ("sensors plugin: fopen(%s) failed: %s",
- conffile, strerror(errno));
+ char errbuf[1024];
+ ERROR ("sensors plugin: fopen(%s) failed: %s", conffile,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return;
}
continue;
/* Only known features */
- for (i = 0; known_features[i].type >= 0; i++)
+ for (i = 0; i < known_features_num; i++)
{
if (strcmp (data->name, known_features[i].label) != 0)
continue;
if ((new_feature = (featurelist_t *) malloc (sizeof (featurelist_t))) == NULL)
{
- DEBUG ("malloc: %s", strerror (errno));
- ERROR ("sensors plugin: malloc: %s",
- strerror (errno));
+ char errbuf[1024];
+ ERROR ("sensors plugin: malloc: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
break;
}
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- if (ignorelist_match (sensor_list, type_instance))
+ if ((sensor_list != NULL)
+ && (ignorelist_match (sensor_list, type_instance)))
return;
values[0].gauge = val;
void module_register (void)
{
- plugin_register_data_set (&fanspeed_ds);
- plugin_register_data_set (&temperature_ds);
- plugin_register_data_set (&voltage_ds);
-
#if SENSORS_HAVE_READ
plugin_register_config ("sensors", sensors_config,
config_keys, config_keys_num);