#if defined(HAVE_SENSORS_SENSORS_H)
# include <sensors/sensors.h>
-#else
-# undef HAVE_LIBSENSORS
#endif
-#if defined(HAVE_LIBSENSORS)
-# define SENSORS_HAVE_READ 1
-#else
-# define SENSORS_HAVE_READ 0
-#endif
-
-#if SENSORS_HAVE_READ
#define SENSOR_TYPE_VOLTAGE 0
#define SENSOR_TYPE_FANSPEED 1
#define SENSOR_TYPE_TEMPERATURE 2
first_feature = NULL;
}
-static void sensors_load_conf (void)
+static int sensors_load_conf (void)
{
FILE *fh;
featurelist_t *last_feature = NULL;
if ((sensors_config_mtime != 0)
&& (sensors_config_mtime == statbuf.st_mtime))
- return;
+ return (0);
if (sensors_config_mtime != 0)
{
char errbuf[1024];
ERROR ("sensors plugin: fopen(%s) failed: %s", conffile,
sstrerror (errno, errbuf, sizeof (errbuf)));
- return;
+ return (-1);
}
status = sensors_init (fh);
{
ERROR ("sensors plugin: Cannot initialize sensors. "
"Data will not be collected.");
- return;
+ return (-1);
}
sensors_config_mtime = statbuf.st_mtime;
sensors_cleanup ();
INFO ("sensors plugin: lm_sensors reports no "
"features. Data will not be collected.");
+ return (-1);
}
-} /* void sensors_load_conf */
+
+ return (0);
+} /* int sensors_load_conf */
static int sensors_shutdown (void)
{
const char *type, const char *type_instance,
double val)
{
+ char match_key[1024];
+ int status;
+
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- if ((sensor_list != NULL)
- && (ignorelist_match (sensor_list, type_instance)))
+ status = snprintf (match_key, sizeof (match_key), "%s/%s-%s",
+ plugin_instance, type, type_instance);
+ if ((status < 1) || (status >= sizeof (match_key)))
return;
+ match_key[sizeof (match_key) - 1] = '\0';
+
+ if (sensor_list != NULL)
+ {
+ DEBUG ("sensors plugin: Checking ignorelist for `%s'", match_key);
+ if (ignorelist_match (sensor_list, match_key))
+ return;
+ }
values[0].gauge = val;
char plugin_instance[DATA_MAX_NAME_LEN];
char type_instance[DATA_MAX_NAME_LEN];
- sensors_load_conf ();
+ if (sensors_load_conf () != 0)
+ return (-1);
for (feature = first_feature; feature != NULL; feature = feature->next)
{
return (0);
} /* int sensors_read */
-#endif /* SENSORS_HAVE_READ */
void module_register (void)
{
-#if SENSORS_HAVE_READ
plugin_register_config ("sensors", sensors_config,
config_keys, config_keys_num);
plugin_register_read ("sensors", sensors_read);
plugin_register_shutdown ("sensors", sensors_shutdown);
-#endif
} /* void module_register */