From 73681054cbff428d352d8ed707d24fab1bf67b24 Mon Sep 17 00:00:00 2001 From: octo Date: Sat, 17 Dec 2005 10:56:39 +0000 Subject: [PATCH] Changed modules `cpu' through `sensors' to compile in `read-only' mode if dependencies are not fullfiled.. --- src/Makefile.am | 15 +++++++++- src/cpu.c | 24 ++++++++++++---- src/cpufreq.c | 35 +++++++++++++----------- src/disk.c | 85 ++++++++++++++++++++++++++++++++------------------------- src/hddtemp.c | 55 +++++++++++++++++-------------------- src/load.c | 23 ++++++++++++---- src/memory.c | 25 ++++++++++++----- src/nfs.c | 27 ++++++++++++------ src/ping.c | 13 ++++----- src/processes.c | 23 ++++++++++++---- src/sensors.c | 68 +++++++++++++++++++++++++++++---------------- 11 files changed, 246 insertions(+), 147 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 11e34a9f..3252aec3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,7 @@ if BUILD_MODULE_CPU pkglib_LTLIBRARIES += cpu.la cpu_la_SOURCES = cpu.c cpu.h cpu_la_LDFLAGS = -module -avoid-version +cpu_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" cpu.la collectd_DEPENDENCIES += cpu.la endif @@ -42,6 +43,7 @@ if BUILD_MODULE_CPUFREQ pkglib_LTLIBRARIES += cpufreq.la cpufreq_la_SOURCES = cpufreq.c cpufreq.h cpufreq_la_LDFLAGS = -module -avoid-version +cpufreq_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" cpufreq.la collectd_DEPENDENCIES += cpufreq.la endif @@ -50,6 +52,7 @@ if BUILD_MODULE_DISK pkglib_LTLIBRARIES += disk.la disk_la_SOURCES = disk.c disk.h disk_la_LDFLAGS = -module -avoid-version +disk_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" disk.la collectd_DEPENDENCIES += disk.la endif @@ -69,6 +72,7 @@ if BUILD_MODULE_HDDTEMP pkglib_LTLIBRARIES += hddtemp.la hddtemp_la_SOURCES = hddtemp.c hddtemp.h hddtemp_la_LDFLAGS = -module -avoid-version +hddtemp_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" hddtemp.la collectd_DEPENDENCIES += hddtemp.la endif @@ -77,6 +81,7 @@ if BUILD_MODULE_LOAD pkglib_LTLIBRARIES += load.la load_la_SOURCES = load.c load.h load_la_LDFLAGS = -module -avoid-version +load_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" load.la collectd_DEPENDENCIES += load.la endif @@ -85,6 +90,7 @@ if BUILD_MODULE_MEMORY pkglib_LTLIBRARIES += memory.la memory_la_SOURCES = memory.c memory.h memory_la_LDFLAGS = -module -avoid-version +memory_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" memory.la collectd_DEPENDENCIES += memory.la endif @@ -93,6 +99,7 @@ if BUILD_MODULE_NFS pkglib_LTLIBRARIES += nfs.la nfs_la_SOURCES = nfs.c nfs.h nfs_la_LDFLAGS = -module -avoid-version +nfs_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" nfs.la collectd_DEPENDENCIES += nfs.la endif @@ -103,6 +110,7 @@ ping_la_SOURCES = ping.c ping.h ping_la_LDFLAGS = -module -avoid-version ping_la_LIBADD = libping/libping.la ping_la_DEPENDENCIES = libping/libping.la +ping_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" ping.la collectd_DEPENDENCIES += ping.la endif @@ -111,6 +119,7 @@ if BUILD_MODULE_PROCESSES pkglib_LTLIBRARIES += processes.la processes_la_SOURCES = processes.c processes.h processes_la_LDFLAGS = -module -avoid-version +processes_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" processes.la collectd_DEPENDENCIES += processes.la endif @@ -118,8 +127,12 @@ endif if BUILD_MODULE_SENSORS pkglib_LTLIBRARIES += sensors.la sensors_la_SOURCES = sensors.c sensors.h -sensors_la_LDFLAGS = -module -avoid-version -lsensors +sensors_la_LDFLAGS = -module -avoid-version +if BUILD_WITH_LM_SENSORS +sensors_la_LDFLAGS += -lsensors +endif sensors_la_LIBADD = -lsensors +sensors_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" sensors.la collectd_DEPENDENCIES += sensors.la endif diff --git a/src/cpu.c b/src/cpu.c index 67db5bcc..6832b523 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -21,8 +21,16 @@ **/ #include "collectd.h" -#include "plugin.h" #include "common.h" +#include "plugin.h" + +#define MODULE_NAME "cpu" + +#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) || defined(HAVE_SYSCTLBYNAME) +# define CPU_HAVE_READ 1 +#else +# define CPU_HAVE_READ 0 +#endif #ifdef HAVE_LIBKSTAT # include @@ -59,8 +67,6 @@ static int numcpu; static int numcpu; #endif /* HAVE_SYSCTLBYNAME */ -#define MODULE_NAME "cpu" - static char *cpu_filename = "cpu-%s.rrd"; static char *ds_def[] = @@ -141,6 +147,7 @@ static void cpu_submit (int cpu_num, unsigned long long user, } #undef BUFSIZE +#if CPU_HAVE_READ static void cpu_read (void) { #ifdef KERNEL_LINUX @@ -222,7 +229,7 @@ static void cpu_read (void) } /* #endif defined(HAVE_LIBKSTAT) */ -#elif defined (HAVE_SYSCTLBYNAME) +#elif defined(HAVE_SYSCTLBYNAME) long cpuinfo[CPUSTATES]; size_t cpuinfo_size; @@ -242,10 +249,17 @@ static void cpu_read (void) return; } +#endif /* CPU_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, cpu_init, cpu_read, cpu_write); + plugin_register (MODULE_NAME, cpu_init, +#if CPU_HAVE_READ + cpu_read, +#else + NULL, +#endif + cpu_write); } #undef MODULE_NAME diff --git a/src/cpufreq.c b/src/cpufreq.c index 001ccec2..92f1cc58 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -20,19 +20,11 @@ * Peter Holik **/ -#include "cpufreq.h" - -/* - * Originally written by Peter Holik - */ - -#if COLLECT_CPUFREQ -#define MODULE_NAME "cpufreq" - -#include "plugin.h" +#include "collectd.h" #include "common.h" +#include "plugin.h" -static int num_cpu = 0; +#define MODULE_NAME "cpufreq" static char *cpufreq_file = "cpufreq-%s.rrd"; @@ -43,10 +35,15 @@ static char *ds_def[] = }; static int ds_num = 1; +#ifdef KERNEL_LINUX +static int num_cpu = 0; +#endif + #define BUFSIZE 256 -void cpufreq_init (void) +static void cpufreq_init (void) { +#ifdef KERNEL_LINUX int status; char filename[BUFSIZE]; @@ -65,9 +62,12 @@ void cpufreq_init (void) } syslog (LOG_INFO, MODULE_NAME" found %d cpu(s)", num_cpu); +#endif /* defined(KERNEL_LINUX) */ + + return; } -void cpufreq_write (char *host, char *inst, char *val) +static void cpufreq_write (char *host, char *inst, char *val) { int status; char file[BUFSIZE]; @@ -79,7 +79,7 @@ void cpufreq_write (char *host, char *inst, char *val) rrd_update_file (host, file, val, ds_def, ds_num); } -void cpufreq_submit (int cpu_num, unsigned long long val) +static void cpufreq_submit (int cpu_num, unsigned long long val) { char buf[BUFSIZE]; char cpu[16]; @@ -91,8 +91,9 @@ void cpufreq_submit (int cpu_num, unsigned long long val) plugin_submit (MODULE_NAME, cpu, buf); } -void cpufreq_read (void) +static void cpufreq_read (void) { +#ifdef KERNEL_LINUX int status; unsigned long long val; int i = 0; @@ -126,6 +127,9 @@ void cpufreq_read (void) cpufreq_submit (i, val); } +#endif /* defined(KERNEL_LINUX) */ + + return; } #undef BUFSIZE @@ -135,4 +139,3 @@ void module_register (void) } #undef MODULE_NAME -#endif /* COLLECT_CPUFREQ */ diff --git a/src/disk.c b/src/disk.c index dc0232d4..f6234c22 100644 --- a/src/disk.c +++ b/src/disk.c @@ -20,37 +20,17 @@ * Florian octo Forster **/ -#include "disk.h" - -#if COLLECT_DISK -#define MODULE_NAME "disk" - -#include "plugin.h" +#include "collectd.h" #include "common.h" +#include "plugin.h" -#ifdef KERNEL_LINUX -typedef struct diskstats -{ - char *name; - - unsigned int read_sectors; - unsigned int write_sectors; - - unsigned long long read_bytes; - unsigned long long write_bytes; - - struct diskstats *next; -} diskstats_t; - -static diskstats_t *disklist; -/* KERNEL_LINUX */ +#define MODULE_NAME "disk" -#elif defined(HAVE_LIBKSTAT) -#define MAX_NUMDISK 256 -extern kstat_ctl_t *kc; -static kstat_t *ksp[MAX_NUMDISK]; -static int numdisk = 0; -#endif /* HAVE_LIBKSTAT */ +#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) +# define DISK_HAVE_READ 1 +#else +# define DISK_HAVE_READ 0 +#endif static char *disk_filename_template = "disk-%s.rrd"; static char *part_filename_template = "partition-%s.rrd"; @@ -80,7 +60,31 @@ static char *part_ds_def[] = }; static int part_ds_num = 4; -void disk_init (void) +#ifdef KERNEL_LINUX +typedef struct diskstats +{ + char *name; + + unsigned int read_sectors; + unsigned int write_sectors; + + unsigned long long read_bytes; + unsigned long long write_bytes; + + struct diskstats *next; +} diskstats_t; + +static diskstats_t *disklist; +/* #endif defined(KERNEL_LINUX) */ + +#elif defined(HAVE_LIBKSTAT) +#define MAX_NUMDISK 256 +extern kstat_ctl_t *kc; +static kstat_t *ksp[MAX_NUMDISK]; +static int numdisk = 0; +#endif /* HAVE_LIBKSTAT */ + +static void disk_init (void) { #ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -106,7 +110,7 @@ void disk_init (void) return; } -void disk_write (char *host, char *inst, char *val) +static void disk_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -120,7 +124,7 @@ void disk_write (char *host, char *inst, char *val) rrd_update_file (host, file, val, disk_ds_def, disk_ds_num); } -void partition_write (char *host, char *inst, char *val) +static void partition_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -135,7 +139,7 @@ void partition_write (char *host, char *inst, char *val) } #define BUFSIZE 512 -void disk_submit (char *disk_name, +static void disk_submit (char *disk_name, unsigned long long read_count, unsigned long long read_merged, unsigned long long read_bytes, @@ -157,7 +161,7 @@ void disk_submit (char *disk_name, plugin_submit (MODULE_NAME, disk_name, buf); } -void partition_submit (char *part_name, +static void partition_submit (char *part_name, unsigned long long read_count, unsigned long long read_bytes, unsigned long long write_count, @@ -175,7 +179,8 @@ void partition_submit (char *part_name, } #undef BUFSIZE -void disk_read (void) +#if DISK_HAVE_READ +static void disk_read (void) { #ifdef KERNEL_LINUX FILE *fh; @@ -331,13 +336,19 @@ void disk_read (void) kio.writes,kio.nwritten); } #endif /* defined(HAVE_LIBKSTAT) */ -} +} /* static void disk_read (void) */ +#endif /* DISK_HAVE_READ */ void module_register (void) { plugin_register ("partition", NULL, NULL, partition_write); - plugin_register (MODULE_NAME, disk_init, disk_read, disk_write); + plugin_register (MODULE_NAME, disk_init, +#if DISK_HAVE_READ + disk_read, +#else + NULL, +#endif + disk_write); } #undef MODULE_NAME -#endif /* COLLECT_DISK */ diff --git a/src/hddtemp.c b/src/hddtemp.c index 64bd3008..f2e8262f 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -21,25 +21,17 @@ * Florian octo Forster **/ -#include "hddtemp.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_HDDTEMP #define MODULE_NAME "hddtemp" -#include #include #include #include -#include -#include -#include -#include -#include #include /* for basename */ -#include "plugin.h" -#include "common.h" - /* LOCALHOST_ADDR The ip address 127.0.0.1, as a 32 bit. */ #define LOCALHOST_ADDR 0x7F000001 @@ -71,23 +63,28 @@ typedef struct hddname static hddname_t *first_hddname = NULL; -/* hddtemp_query_daemon - Connect to the hddtemp daemon and receive data. - - Parameters: - buffer: the buffer where we put the received ascii string. - buffer_size: size of the buffer - - Return value: - >= 0 if ok, < 0 otherwise. - - Example of possible strings, as received from daemon: - - |/dev/hda|ST340014A|36|C| - |/dev/hda|ST380011A|46|C||/dev/hdd|ST340016A|SLP|*| - - FIXME: we need to create a new socket each time. Is there another way? */ - +/* + * NAME + * hddtemp_query_daemon + * + * DESCRIPTION + * Connect to the hddtemp daemon and receive data. + * + * ARGUMENTS: + * `buffer' The buffer where we put the received ascii string. + * `buffer_size' Size of the buffer + * + * RETURN VALUE: + * >= 0 if ok, < 0 otherwise. + * + * NOTES: + * Example of possible strings, as received from daemon: + * |/dev/hda|ST340014A|36|C| + * |/dev/hda|ST380011A|46|C||/dev/hdd|ST340016A|SLP|*| + * + * FIXME: + * we need to create a new socket each time. Is there another way? + */ static int hddtemp_query_daemon (char *buffer, int buffer_size) { int sock; @@ -368,5 +365,3 @@ void module_register (void) { plugin_register (MODULE_NAME, hddtemp_init, hddtemp_read, hddtemp_write); } - -#endif /* COLLECT_HDDTEMP */ diff --git a/src/load.c b/src/load.c index d082816a..2c02d8be 100644 --- a/src/load.c +++ b/src/load.c @@ -20,13 +20,17 @@ * Florian octo Forster **/ -#include "load.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_LOAD #define MODULE_NAME "load" -#include "plugin.h" -#include "common.h" +#if defined(HAVE_GETLOADAVG) || defined(KERNEL_LINUX) || defined(HAVE_LIBSTATGRAB) +# define LOAD_HAVE_READ 1 +#else +# define LOAD_HAVE_READ 0 +#endif #ifdef HAVE_SYS_LOADAVG_H #include @@ -74,6 +78,7 @@ void load_submit (double snum, double mnum, double lnum) } #undef BUFSIZE +#if LOAD_HAVE_READ void load_read (void) { #if defined(HAVE_GETLOADAVG) @@ -134,11 +139,17 @@ void load_read (void) load_submit (snum, mnum, lnum); #endif /* HAVE_LIBSTATGRAB */ } +#endif /* LOAD_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, load_init, load_read, load_write); + plugin_register (MODULE_NAME, load_init, +#if LOAD_HAVE_READ + load_read, +#else + NULL, +#endif + load_write); } #undef MODULE_NAME -#endif /* COLLECT_LOAD */ diff --git a/src/memory.c b/src/memory.c index f7924456..6ae35cbb 100644 --- a/src/memory.c +++ b/src/memory.c @@ -20,13 +20,17 @@ * Florian octo Forster **/ -#include "memory.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_MEMORY -#define MODULE_NAME "memory" +#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) +# define MEMORY_HAVE_READ 1 +#else +# define MEMORY_HAVE_READ 0 +#endif -#include "plugin.h" -#include "common.h" +#define MODULE_NAME "memory" static char *memory_file = "memory.rrd"; @@ -78,6 +82,7 @@ void memory_submit (long long mem_used, long long mem_buffered, } #undef BUFSIZE +#if MEMORY_HAVE_READ void memory_read (void) { #ifdef KERNEL_LINUX @@ -163,11 +168,17 @@ void memory_read (void) memory_submit (ios->used, 0LL, ios->cache, ios->free); #endif /* HAVE_LIBSTATGRAB */ } +#endif /* MEMORY_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, memory_init, memory_read, memory_write); + plugin_register (MODULE_NAME, memory_init, +#if MEMORY_HAVE_READ + memory_read, +#else + NULL, +#endif + memory_write); } #undef MODULE_NAME -#endif /* COLLECT_MEMORY */ diff --git a/src/nfs.c b/src/nfs.c index 3321630a..03331137 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -21,13 +21,17 @@ * Florian octo Forster **/ -#include "nfs.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_NFS #define MODULE_NAME "nfs" -#include "plugin.h" -#include "common.h" +#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) +# define NFS_HAVE_READ 1 +#else +# define NFS_HAVE_READ 0 +#endif static char *nfs2_procedures_file = "nfs2_procedures-%s.rrd"; static char *nfs3_procedures_file = "nfs3_procedures-%s.rrd"; @@ -351,6 +355,7 @@ void nfs2_read_kstat (kstat_t *ksp, char *inst) } #endif +#if NFS_HAVE_READ void nfs_read (void) { #if defined(KERNEL_LINUX) @@ -377,13 +382,19 @@ void nfs_read (void) nfs2_read_kstat (nfs2_ksp_server, "server"); #endif /* defined(HAVE_LIBKSTAT) */ } +#endif /* NFS_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, nfs_init, nfs_read, NULL); - plugin_register ("nfs2_procedures", NULL, NULL, nfs2_procedures_write); - plugin_register ("nfs3_procedures", NULL, NULL, nfs3_procedures_write); + plugin_register (MODULE_NAME, nfs_init, +#if NFS_HAVE_READ + nfs_read, +#else + NULL, +#endif + NULL); + plugin_register ("nfs2_procedures", NULL, NULL, nfs2_procedures_write); + plugin_register ("nfs3_procedures", NULL, NULL, nfs3_procedures_write); } #undef MODULE_NAME -#endif /* COLLECT_LOAD */ diff --git a/src/ping.c b/src/ping.c index e6456f8c..6a2b9068 100644 --- a/src/ping.c +++ b/src/ping.c @@ -20,18 +20,18 @@ * Florian octo Forster **/ -#include "ping.h" - -#if COLLECT_PING -#define MODULE_NAME "ping" - -#include "plugin.h" +#include "collectd.h" #include "common.h" +#include "plugin.h" #include "configfile.h" +#define MODULE_NAME "ping" + #include #include "libping/ping.h" +#define MAX_PINGHOSTS 32 + extern char *pinghosts[MAX_PINGHOSTS]; extern int num_pinghosts; static int pingerrors[MAX_PINGHOSTS]; @@ -163,4 +163,3 @@ void module_register (void) } #undef MODULE_NAME -#endif /* COLLECT_PING */ diff --git a/src/processes.c b/src/processes.c index 821472bd..e2bda15e 100644 --- a/src/processes.c +++ b/src/processes.c @@ -21,13 +21,17 @@ * Florian octo Forster **/ -#include "processes.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_PROCESSES #define MODULE_NAME "processes" -#include "common.h" -#include "plugin.h" +#ifdef KERNEL_LINUX +# define PROCESSES_HAVE_READ 1 +#else +# define PROCESSES_HAVE_READ 0 +#endif static char *ps_file = "processes.rrd"; @@ -71,6 +75,7 @@ void ps_submit (unsigned int running, plugin_submit (MODULE_NAME, "-", buf); } +#if PROCESSES_HAVE_READ void ps_read (void) { #ifdef KERNEL_LINUX @@ -133,12 +138,18 @@ void ps_read (void) ps_submit (running, sleeping, zombies, stopped, paging, blocked); #endif /* defined(KERNEL_LINUX) */ } +#endif /* PROCESSES_HAVE_READ */ #undef BUFSIZE void module_register (void) { - plugin_register (MODULE_NAME, ps_init, ps_read, ps_write); + plugin_register (MODULE_NAME, ps_init, +#if PROCESSES_HAVE_READ + ps_read, +#else + NULL, +#endif + ps_write); } #undef MODULE_NAME -#endif /* COLLECT_PROCESSES */ diff --git a/src/sensors.c b/src/sensors.c index 270ba035..13139636 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -20,24 +20,23 @@ * Florian octo Forster **/ -#include "sensors.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_SENSORS #define MODULE_NAME "sensors" -#include - -#include "plugin.h" -#include "common.h" - -typedef struct featurelist -{ - const sensors_chip_name *chip; - const sensors_feature_data *data; - struct featurelist *next; -} featurelist_t; +#if defined(HAVE_SENSORS_SENSORS_H) +# include +#else +# undef HAVE_LIBSENSORS +#endif -featurelist_t *first_feature = NULL; +#if defined(HAVE_LIBSENSORS) +# define SENSORS_HAVE_READ 1 +#else +# define SENSORS_HAVE_READ 0 +#endif static char *filename_format = "sensors-%s.rrd"; @@ -48,8 +47,20 @@ static char *ds_def[] = }; 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; @@ -131,24 +142,27 @@ void collectd_sensors_init (void) if (first_feature == NULL) sensors_cleanup (); +#endif /* defined(HAVE_LIBSENSORS) */ + + return; } -void sensors_write (char *host, char *inst, char *val) +#define BUFSIZE 512 +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) +static void sensors_submit (const char *feat_name, const char *chip_prefix, double value) { char buf[BUFSIZE]; char inst[BUFSIZE]; @@ -163,7 +177,8 @@ void sensors_submit (const char *feat_name, const char *chip_prefix, double valu } #undef BUFSIZE -void sensors_read (void) +#if SENSORS_HAVE_READ +static void sensors_read (void) { featurelist_t *feature; double value; @@ -176,12 +191,17 @@ void sensors_read (void) sensors_submit (feature->data->name, feature->chip->prefix, value); } } +#endif /* SENSORS_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, collectd_sensors_init, sensors_read, + plugin_register (MODULE_NAME, collectd_sensors_init, +#if SENSORS_HAVE_READ + sensors_read, +#else + NULL, +#endif sensors_write); } #undef MODULE_NAME -#endif /* COLLECT_SENSORS */ -- 2.11.0