diff --git a/src/sensors.c b/src/sensors.c
index 270ba035cfdfbbdf350fc00da36fa0b0eca5bfec..75981e84854ce1c4ae8b012169e73b3c7028cdf8 100644 (file)
--- a/src/sensors.c
+++ b/src/sensors.c
* Florian octo Forster <octo at verplant.org>
**/
-#include "sensors.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_SENSORS
#define MODULE_NAME "sensors"
-#include <sensors/sensors.h>
-
-#include "plugin.h"
-#include "common.h"
+#if defined(HAVE_SENSORS_SENSORS_H)
+# include <sensors/sensors.h>
+#else
+# undef HAVE_LIBSENSORS
+#endif
-typedef struct featurelist
-{
- const sensors_chip_name *chip;
- const sensors_feature_data *data;
- struct featurelist *next;
-} featurelist_t;
+#if defined(HAVE_LIBSENSORS)
+# define SENSORS_HAVE_READ 1
+#else
+# define SENSORS_HAVE_READ 0
+#endif
-featurelist_t *first_feature = NULL;
+#define BUFSIZE 512
static char *filename_format = "sensors-%s.rrd";
};
static int ds_num = 1;
-void collectd_sensors_init (void)
+#ifdef HAVE_LIBSENSORS
+typedef struct featurelist
+{
+ const sensors_chip_name *chip;
+ const sensors_feature_data *data;
+ struct featurelist *next;
+} featurelist_t;
+
+featurelist_t *first_feature = NULL;
+#endif /* defined (HAVE_LIBSENSORS) */
+
+static void collectd_sensors_init (void)
{
+#ifdef HAVE_LIBSENSORS
FILE *fh;
featurelist_t *last_feature = NULL;
featurelist_t *new_feature;
if (first_feature == NULL)
sensors_cleanup ();
+#endif /* defined(HAVE_LIBSENSORS) */
+
+ return;
}
-void sensors_write (char *host, char *inst, char *val)
+static void sensors_write (char *host, char *inst, char *val)
{
- char file[512];
+ char file[BUFSIZE];
int status;
- status = snprintf (file, 512, filename_format, inst);
+ status = snprintf (file, BUFSIZE, filename_format, inst);
if (status < 1)
return;
- else if (status >= 512)
+ else if (status >= BUFSIZE)
return;
rrd_update_file (host, file, val, ds_def, ds_num);
}
-#define BUFSIZE 512
-void sensors_submit (const char *feat_name, const char *chip_prefix, double value)
+#if SENSORS_HAVE_READ
+static void sensors_submit (const char *feat_name, const char *chip_prefix, double value)
{
char buf[BUFSIZE];
char inst[BUFSIZE];
@@ -161,9 +177,8 @@ void sensors_submit (const char *feat_name, const char *chip_prefix, double valu
plugin_submit (MODULE_NAME, inst, buf);
}
-#undef BUFSIZE
-void sensors_read (void)
+static void sensors_read (void)
{
featurelist_t *feature;
double value;
sensors_submit (feature->data->name, feature->chip->prefix, value);
}
}
+#else
+# define sensors_read NULL
+#endif /* SENSORS_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, collectd_sensors_init, sensors_read,
- sensors_write);
+ plugin_register (MODULE_NAME, collectd_sensors_init, sensors_read, sensors_write);
}
+#undef BUFSIZE
#undef MODULE_NAME
-#endif /* COLLECT_SENSORS */