From: octo Date: Sat, 17 Dec 2005 12:11:54 +0000 (+0000) Subject: Moved the *_HAVE_READ defines: *_submit may only be included when *_read is included... X-Git-Tag: collectd-3.6.0~35 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=55b439475d492599de5134536710180b39dac593;p=collectd.git Moved the *_HAVE_READ defines: *_submit may only be included when *_read is included too. Otherwise the compiler will complain. --- diff --git a/configure.in b/configure.in index 46bc8834..3777f7d8 100644 --- a/configure.in +++ b/configure.in @@ -413,38 +413,32 @@ fi ]dnl )# AC_COLLECTD(name, enable/disable, info-text, feature/module) - - -#m4_divert_once([HELP_ENABLE], [ -#collectd modules:]) -#AC_COLLECTD([cpu], [disable], [module], [cpu usage statistics]) -#AC_COLLECTD([cpufreq], [disable], [module], [system cpu frequency statistics]) -#AC_COLLECTD([disk], [disable], [module], [disk/partition statistics]) -#AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)]) -#AC_COLLECTD([hddtemp], [disable], [module], [hdd temperature statistics]) -#AC_COLLECTD([load], [disable], [module], [system load statistics]) -#AC_COLLECTD([memory], [disable], [module], [memory statistics]) -#AC_COLLECTD([nfs], [disable], [module], [nfs statistics]) -#AC_COLLECTD([ping], [disable], [module], [ping statistics]) -#AC_COLLECTD([processes], [disable], [module], [processes statistics]) -#AC_COLLECTD([sensors], [disable], [module], [lm_sensors statistics]) -#AC_COLLECTD([serial], [disable], [module], [serial statistics]) -#AC_COLLECTD([swap], [disable], [module], [swap statistics]) -#AC_COLLECTD([tape], [disable], [module], [tape statistics]) -#AC_COLLECTD([traffic], [disable], [module], [system traffic statistics]) -#AC_COLLECTD([users], [disable], [module], [user count statistics]) - - - m4_divert_once([HELP_ENABLE], [ collectd features:]) - AC_COLLECTD([debug], [enable], [feature], [debugging]) AC_COLLECTD([daemon], [disable], [feature], [daemon mode]) m4_divert_once([HELP_ENABLE], [ collectd modules:]) AC_COLLECTD([cpu], [disable], [module], [cpu usage statistics]) +AC_COLLECTD([cpufreq], [disable], [module], [system cpu frequency statistics]) +AC_COLLECTD([disk], [disable], [module], [disk/partition statistics]) +AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)]) +AC_COLLECTD([hddtemp], [disable], [module], [hdd temperature statistics]) +AC_COLLECTD([load], [disable], [module], [system load statistics]) +AC_COLLECTD([memory], [disable], [module], [memory statistics]) +AC_COLLECTD([nfs], [disable], [module], [nfs statistics]) +AC_COLLECTD([ping], [disable], [module], [ping statistics]) +AC_COLLECTD([processes], [disable], [module], [processes statistics]) +AC_COLLECTD([sensors], [disable], [module], [lm_sensors statistics]) +AC_COLLECTD([serial], [disable], [module], [serial statistics]) +AC_COLLECTD([swap], [disable], [module], [swap statistics]) +AC_COLLECTD([tape], [disable], [module], [tape statistics]) +AC_COLLECTD([traffic], [disable], [module], [system traffic statistics]) +AC_COLLECTD([users], [disable], [module], [user count statistics]) + +#m4_divert_once([HELP_ENABLE], [ +#collectd modules:]) #AC_ARG_ENABLE(cpu, AC_HELP_STRING([--disable-cpu], [Disable CPU usage statistics]),, [enable_cpu="yes"]) #if test "x$enable_cpu" != "xno" #then @@ -461,203 +455,203 @@ AC_COLLECTD([cpu], [disable], [module], [cpu usage statistics]) #fi #AM_CONDITIONAL(BUILD_MODULE_CPU, test "x$enable_cpu" = "xyes") -AC_ARG_ENABLE(cpufreq, AC_HELP_STRING([--disable-cpufreq], [Disable system cpu frequency statistics]),, [enable_cpufreq="yes"]) -if test "x$enable_cpufreq" != "xno" -then - if test "x$ac_system" = "xLinux" - then - enable_cpufreq="yes" - else - enable_cpufreq="no" - fi -fi -if test "x$enable_cpufreq" = "xno" -then - AC_DEFINE(COLLECT_CPUFREQ, 0, [Wether or not to collect cpu frequency statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_CPUFREQ, test "x$enable_cpufreq" = "xyes") +#AC_ARG_ENABLE(cpufreq, AC_HELP_STRING([--disable-cpufreq], [Disable system cpu frequency statistics]),, [enable_cpufreq="yes"]) +#if test "x$enable_cpufreq" != "xno" +#then +# if test "x$ac_system" = "xLinux" +# then +# enable_cpufreq="yes" +# else +# enable_cpufreq="no" +# fi +#fi +#if test "x$enable_cpufreq" = "xno" +#then +# AC_DEFINE(COLLECT_CPUFREQ, 0, [Wether or not to collect cpu frequency statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_CPUFREQ, test "x$enable_cpufreq" = "xyes") -AC_ARG_ENABLE(disk, AC_HELP_STRING([--disable-disk], [Disable disk/partition statistics]),, [enable_disk="yes"]) -if test "x$enable_disk" != "xno" -then - if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" - then - enable_disk="yes" - else - enable_disk="no" - fi -fi -if test "x$enable_disk" = "xno" -then - AC_DEFINE(COLLECT_DISK, 0, [Wether or not to collect diskstats]) -fi -AM_CONDITIONAL(BUILD_MODULE_DISK, test "x$enable_disk" = "xyes") +#AC_ARG_ENABLE(disk, AC_HELP_STRING([--disable-disk], [Disable disk/partition statistics]),, [enable_disk="yes"]) +#if test "x$enable_disk" != "xno" +#then +# if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" +# then +# enable_disk="yes" +# else +# enable_disk="no" +# fi +#fi +#if test "x$enable_disk" = "xno" +#then +# AC_DEFINE(COLLECT_DISK, 0, [Wether or not to collect diskstats]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_DISK, test "x$enable_disk" = "xyes") -AC_ARG_ENABLE(hddtemp, AC_HELP_STRING([--disable-hddtemp], [Disable hdd temperature statistics]),, [enable_hddtemp="yes"]) -if test "x$enable_hddtemp" = "xno" -then - AC_DEFINE(COLLECT_HDDTEMP, 0, [Wether or not to collect hdd temperature statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_HDDTEMP, test "x$enable_hddtemp" = "xyes") +#AC_ARG_ENABLE(hddtemp, AC_HELP_STRING([--disable-hddtemp], [Disable hdd temperature statistics]),, [enable_hddtemp="yes"]) +#if test "x$enable_hddtemp" = "xno" +#then +# AC_DEFINE(COLLECT_HDDTEMP, 0, [Wether or not to collect hdd temperature statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_HDDTEMP, test "x$enable_hddtemp" = "xyes") -AC_ARG_ENABLE(load, AC_HELP_STRING([--disable-load], [Disable system load statistics]),, [enable_load="yes"]) -if test "x$enable_load" != "xno" -then - if test "x$have_getloadavg" = "xyes" -o "x$ac_system" = "xLinux" -o "x$with_libstatgrab" = "xyes" - then - enable_load="yes" - else - enable_load="no" - fi -fi -if test "x$enable_load" = "xno" -then - AC_DEFINE(COLLECT_LOAD, 0, [Wether or not to collect system load statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_LOAD, test "x$enable_load" = "xyes") +#AC_ARG_ENABLE(load, AC_HELP_STRING([--disable-load], [Disable system load statistics]),, [enable_load="yes"]) +#if test "x$enable_load" != "xno" +#then +# if test "x$have_getloadavg" = "xyes" -o "x$ac_system" = "xLinux" -o "x$with_libstatgrab" = "xyes" +# then +# enable_load="yes" +# else +# enable_load="no" +# fi +#fi +#if test "x$enable_load" = "xno" +#then +# AC_DEFINE(COLLECT_LOAD, 0, [Wether or not to collect system load statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_LOAD, test "x$enable_load" = "xyes") -AC_ARG_ENABLE(memory, AC_HELP_STRING([--disable-memory], [Disable memory statistics]),, [enable_memory="yes"]) -if test "x$enable_memory" != "xno" -then - if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes" - then - enable_memory="yes" - else - enable_memory="no" - fi -fi -if test "x$enable_memory" = "xno" -then - AC_DEFINE(COLLECT_MEMORY, 0, [Wether or not to collect memory statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_MEMORY, test "x$enable_memory" = "xyes") +#AC_ARG_ENABLE(memory, AC_HELP_STRING([--disable-memory], [Disable memory statistics]),, [enable_memory="yes"]) +#if test "x$enable_memory" != "xno" +#then +# if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes" +# then +# enable_memory="yes" +# else +# enable_memory="no" +# fi +#fi +#if test "x$enable_memory" = "xno" +#then +# AC_DEFINE(COLLECT_MEMORY, 0, [Wether or not to collect memory statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_MEMORY, test "x$enable_memory" = "xyes") -AC_ARG_ENABLE(nfs, AC_HELP_STRING([--disable-nfs], [Disable nfs statistics]),, [enable_nfs="yes"]) -if test "x$enable_nfs" != "xno" -then - if test "x$ac_system" = "xLinux" - then - enable_nfs="yes" - else - enable_nfs="no" - fi -fi -if test "x$enable_nfs" = "xno" -then - AC_DEFINE(COLLECT_NFS, 0, [Wether or not to collect nfs statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_NFS, test "x$enable_nfs" = "xyes") +#AC_ARG_ENABLE(nfs, AC_HELP_STRING([--disable-nfs], [Disable nfs statistics]),, [enable_nfs="yes"]) +#if test "x$enable_nfs" != "xno" +#then +# if test "x$ac_system" = "xLinux" +# then +# enable_nfs="yes" +# else +# enable_nfs="no" +# fi +#fi +#if test "x$enable_nfs" = "xno" +#then +# AC_DEFINE(COLLECT_NFS, 0, [Wether or not to collect nfs statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_NFS, test "x$enable_nfs" = "xyes") -AC_ARG_ENABLE(ping, AC_HELP_STRING([--disable-ping], [Disable ping statistics]),, [enable_ping="yes"]) -if test "x$enable_ping" != "xno" -then - enable_ping="yes" -fi -if test "x$enable_ping" = "xno" -then - AC_DEFINE(COLLECT_PING, 0, [Wether or not to collect ping statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_PING, test "x$enable_ping" = "xyes") +#AC_ARG_ENABLE(ping, AC_HELP_STRING([--disable-ping], [Disable ping statistics]),, [enable_ping="yes"]) +#if test "x$enable_ping" != "xno" +#then +# enable_ping="yes" +#fi +#if test "x$enable_ping" = "xno" +#then +# AC_DEFINE(COLLECT_PING, 0, [Wether or not to collect ping statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_PING, test "x$enable_ping" = "xyes") -AC_ARG_ENABLE(processes, AC_HELP_STRING([--disable-processes], [Disable processes statistics]),, [enable_processes="yes"]) -if test "x$enable_processes" != "xno" -then - if test "x$ac_system" = "xLinux" - then - enable_processes="yes" - else - enable_processes="no" - fi -fi -if test "x$enable_processes" = "xno" -then - AC_DEFINE(COLLECT_PROCESSES, 0, [Wether or not to collect processes statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_PROCESSES, test "x$enable_processes" = "xyes") +#AC_ARG_ENABLE(processes, AC_HELP_STRING([--disable-processes], [Disable processes statistics]),, [enable_processes="yes"]) +#if test "x$enable_processes" != "xno" +#then +# if test "x$ac_system" = "xLinux" +# then +# enable_processes="yes" +# else +# enable_processes="no" +# fi +#fi +#if test "x$enable_processes" = "xno" +#then +# AC_DEFINE(COLLECT_PROCESSES, 0, [Wether or not to collect processes statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_PROCESSES, test "x$enable_processes" = "xyes") -#AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)]) +##AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)]) -AC_ARG_ENABLE(sensors, AC_HELP_STRING([--disable-sensors], [Disable lm_sensors statistics]),, [enable_sensors=$with_lm_sensors]) -if test "x$enable_sensors" != "xno" -then - if test "x$with_lm_sensors" = "xyes" - then - enable_sensors="yes" - else - enable_sensors="no" - fi -fi -if test "x$enable_sensors" = "xno" -then - AC_DEFINE(COLLECT_SENSORS, 0, [Wether or not to collect lm_sensors statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_SENSORS, test "x$enable_sensors" = "xyes") +#AC_ARG_ENABLE(sensors, AC_HELP_STRING([--disable-sensors], [Disable lm_sensors statistics]),, [enable_sensors=$with_lm_sensors]) +#if test "x$enable_sensors" != "xno" +#then +# if test "x$with_lm_sensors" = "xyes" +# then +# enable_sensors="yes" +# else +# enable_sensors="no" +# fi +#fi +#if test "x$enable_sensors" = "xno" +#then +# AC_DEFINE(COLLECT_SENSORS, 0, [Wether or not to collect lm_sensors statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_SENSORS, test "x$enable_sensors" = "xyes") -AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [Disable serial statistics]),, [enable_serial="yes"]) -if test "x$enable_serial" != "xno" -then - if test "x$ac_system" = "xLinux" - then - enable_serial="yes" - else - enable_serial="no" - fi -fi -if test "x$enable_serial" = "xno" -then - AC_DEFINE(COLLECT_SERIAL, 0, [Wether or not to collect serial statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_SERIAL, test "x$enable_serial" = "xyes") +#AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [Disable serial statistics]),, [enable_serial="yes"]) +#if test "x$enable_serial" != "xno" +#then +# if test "x$ac_system" = "xLinux" +# then +# enable_serial="yes" +# else +# enable_serial="no" +# fi +#fi +#if test "x$enable_serial" = "xno" +#then +# AC_DEFINE(COLLECT_SERIAL, 0, [Wether or not to collect serial statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_SERIAL, test "x$enable_serial" = "xyes") -AC_ARG_ENABLE(swap, AC_HELP_STRING([--disable-swap], [Disable swap statistics]),, [enable_swap="yes"]) -if test "x$enable_swap" != "xno" -then - if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes" - then - enable_swap="yes" - else - enable_swap="no" - fi -fi -if test "x$enable_swap" = "xno" -then - AC_DEFINE(COLLECT_SWAP, 0, [Wether or not to collect swap statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_SWAP, test "x$enable_swap" = "xyes") +#AC_ARG_ENABLE(swap, AC_HELP_STRING([--disable-swap], [Disable swap statistics]),, [enable_swap="yes"]) +#if test "x$enable_swap" != "xno" +#then +# if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes" +# then +# enable_swap="yes" +# else +# enable_swap="no" +# fi +#fi +#if test "x$enable_swap" = "xno" +#then +# AC_DEFINE(COLLECT_SWAP, 0, [Wether or not to collect swap statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_SWAP, test "x$enable_swap" = "xyes") -AC_ARG_ENABLE(tape, AC_HELP_STRING([--disable-tape], [Disable tape statistics]),, [enable_tape="yes"]) -if test "x$enable_tape" != "xno" -then - if test "x$with_kstat" = "xyes" - then - enable_tape="yes" - else - enable_tape="no" - fi -fi -if test "x$enable_tape" = "xno" -then - AC_DEFINE(COLLECT_TAPE, 0, [Wether or not to collect tape statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_TAPE, test "x$enable_tape" = "xyes") +#AC_ARG_ENABLE(tape, AC_HELP_STRING([--disable-tape], [Disable tape statistics]),, [enable_tape="yes"]) +#if test "x$enable_tape" != "xno" +#then +# if test "x$with_kstat" = "xyes" +# then +# enable_tape="yes" +# else +# enable_tape="no" +# fi +#fi +#if test "x$enable_tape" = "xno" +#then +# AC_DEFINE(COLLECT_TAPE, 0, [Wether or not to collect tape statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_TAPE, test "x$enable_tape" = "xyes") -AC_ARG_ENABLE(traffic, AC_HELP_STRING([--disable-traffic], [Disable system traffic statistics]),, [enable_traffic="yes"]) -if test "x$enable_traffic" != "xno" -then - if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes" - then - enable_traffic="yes" - else - enable_traffic="no" - fi -fi -if test "x$enable_traffic" = "xno" -then - AC_DEFINE(COLLECT_TRAFFIC, 0, [Wether or not to collect network traffic statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_TRAFFIC, test "x$enable_traffic" = "xyes") +#AC_ARG_ENABLE(traffic, AC_HELP_STRING([--disable-traffic], [Disable system traffic statistics]),, [enable_traffic="yes"]) +#if test "x$enable_traffic" != "xno" +#then +# if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes" +# then +# enable_traffic="yes" +# else +# enable_traffic="no" +# fi +#fi +#if test "x$enable_traffic" = "xno" +#then +# AC_DEFINE(COLLECT_TRAFFIC, 0, [Wether or not to collect network traffic statistics]) +#fi +#AM_CONDITIONAL(BUILD_MODULE_TRAFFIC, test "x$enable_traffic" = "xyes") -AC_COLLECTD([users], [disable], [module], [user count statistics]) +#AC_COLLECTD([users], [disable], [module], [user count statistics]) AC_OUTPUT(Makefile src/libconfig/Makefile src/libping/Makefile src/Makefile) diff --git a/src/cpu.c b/src/cpu.c index 5252324a..62e81457 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -39,12 +39,6 @@ # include # endif -#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) || defined(HAVE_SYSCTLBYNAME) -# define CPU_HAVE_READ 1 -#else -# define CPU_HAVE_READ 0 -#endif - # if !defined(CP_USER) || !defined(CP_NICE) || !defined(CP_SYS) || !defined(CP_INTR) || !defined(CP_IDLE) || !defined(CPUSTATES) # define CP_USER 0 # define CP_NICE 1 @@ -55,6 +49,12 @@ # endif #endif /* HAVE_SYSCTLBYNAME */ +#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 /* colleague tells me that Sun doesn't sell systems with more than 100 or so CPUs.. */ # define MAX_NUMCPU 256 @@ -130,6 +130,7 @@ static void cpu_write (char *host, char *inst, char *val) rrd_update_file (host, file, val, ds_def, ds_num); } +#if CPU_HAVE_READ #define BUFSIZE 512 static void cpu_submit (int cpu_num, unsigned long long user, unsigned long long nice, unsigned long long syst, @@ -147,7 +148,6 @@ 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 diff --git a/src/cpufreq.c b/src/cpufreq.c index 6806c3e6..9d74c576 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -85,6 +85,7 @@ static void cpufreq_write (char *host, char *inst, char *val) rrd_update_file (host, file, val, ds_def, ds_num); } +#if CPUFREQ_HAVE_READ static void cpufreq_submit (int cpu_num, unsigned long long val) { char buf[BUFSIZE]; @@ -97,7 +98,6 @@ static void cpufreq_submit (int cpu_num, unsigned long long val) plugin_submit (MODULE_NAME, cpu, buf); } -#if CPUFREQ_HAVE_READ static void cpufreq_read (void) { #ifdef KERNEL_LINUX diff --git a/src/disk.c b/src/disk.c index cd876014..e3638f22 100644 --- a/src/disk.c +++ b/src/disk.c @@ -161,6 +161,7 @@ static void disk_submit (char *disk_name, plugin_submit (MODULE_NAME, disk_name, buf); } +#if DISK_HAVE_READ static void partition_submit (char *part_name, unsigned long long read_count, unsigned long long read_bytes, @@ -179,7 +180,6 @@ static void partition_submit (char *part_name, } #undef BUFSIZE -#if DISK_HAVE_READ static void disk_read (void) { #ifdef KERNEL_LINUX diff --git a/src/load.c b/src/load.c index 8d0963bc..913eb538 100644 --- a/src/load.c +++ b/src/load.c @@ -65,6 +65,7 @@ static void load_write (char *host, char *inst, char *val) rrd_update_file (host, load_file, val, ds_def, ds_num); } +#if LOAD_HAVE_READ #define BUFSIZE 256 static void load_submit (double snum, double mnum, double lnum) { @@ -78,7 +79,6 @@ static void load_submit (double snum, double mnum, double lnum) } #undef BUFSIZE -#if LOAD_HAVE_READ static void load_read (void) { #if defined(HAVE_GETLOADAVG) diff --git a/src/memory.c b/src/memory.c index dd8bd787..3ab19e65 100644 --- a/src/memory.c +++ b/src/memory.c @@ -67,6 +67,7 @@ static void memory_write (char *host, char *inst, char *val) rrd_update_file (host, memory_file, val, ds_def, ds_num); } +#if MEMORY_HAVE_READ #define BUFSIZE 512 static void memory_submit (long long mem_used, long long mem_buffered, long long mem_cached, long long mem_free) @@ -82,7 +83,6 @@ static void memory_submit (long long mem_used, long long mem_buffered, } #undef BUFSIZE -#if MEMORY_HAVE_READ static void memory_read (void) { #ifdef KERNEL_LINUX diff --git a/src/nfs.c b/src/nfs.c index c9fbd8f5..1592c911 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -206,6 +206,7 @@ static void nfs3_procedures_write (char *host, char *inst, char *val) nfs3_procedures_ds_num); } +#if NFS_HAVE_READ static void nfs2_procedures_submit (unsigned long long *val, char *inst) { char buf[BUFSIZE]; @@ -255,6 +256,7 @@ static void nfs3_procedures_submit (unsigned long long *val, char *inst) plugin_submit("nfs3_procedures", inst, buf); } +#endif /* NFS_HAVE_READ */ #if defined(KERNEL_LINUX) static void nfs_read_stats_file (FILE *fh, char *inst) diff --git a/src/processes.c b/src/processes.c index d1fe696a..3a731890 100644 --- a/src/processes.c +++ b/src/processes.c @@ -33,6 +33,8 @@ # define PROCESSES_HAVE_READ 0 #endif +#define BUFSIZE 256 + static char *ps_file = "processes.rrd"; static char *ds_def[] = @@ -56,7 +58,7 @@ static void ps_write (char *host, char *inst, char *val) rrd_update_file (host, ps_file, val, ds_def, ds_num); } -#define BUFSIZE 256 +#if PROCESSES_HAVE_READ static void ps_submit (unsigned int running, unsigned int sleeping, unsigned int zombies, @@ -75,7 +77,6 @@ static void ps_submit (unsigned int running, plugin_submit (MODULE_NAME, "-", buf); } -#if PROCESSES_HAVE_READ static void ps_read (void) { #ifdef KERNEL_LINUX @@ -83,7 +84,7 @@ static void ps_read (void) char buf[BUFSIZE]; char filename[20]; /* need 17 bytes */ - char *fields[256]; + char *fields[BUFSIZE]; struct dirent *ent; DIR *proc; @@ -119,7 +120,7 @@ static void ps_read (void) fclose (fh); - if (strsplit (buf, fields, 256) < 3) + if (strsplit (buf, fields, BUFSIZE) < 3) continue; switch (fields[2][0]) @@ -141,11 +142,11 @@ static void ps_read (void) #else # define ps_read NULL #endif /* PROCESSES_HAVE_READ */ -#undef BUFSIZE void module_register (void) { plugin_register (MODULE_NAME, ps_init, ps_read, ps_write); } +#undef BUFSIZE #undef MODULE_NAME diff --git a/src/sensors.c b/src/sensors.c index b6c76f88..75981e84 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -38,6 +38,8 @@ # define SENSORS_HAVE_READ 0 #endif +#define BUFSIZE 512 + static char *filename_format = "sensors-%s.rrd"; static char *ds_def[] = @@ -147,7 +149,6 @@ static void collectd_sensors_init (void) return; } -#define BUFSIZE 512 static void sensors_write (char *host, char *inst, char *val) { char file[BUFSIZE]; @@ -162,6 +163,7 @@ static void sensors_write (char *host, char *inst, char *val) rrd_update_file (host, file, val, ds_def, ds_num); } +#if SENSORS_HAVE_READ static void sensors_submit (const char *feat_name, const char *chip_prefix, double value) { char buf[BUFSIZE]; @@ -175,9 +177,7 @@ static void sensors_submit (const char *feat_name, const char *chip_prefix, doub plugin_submit (MODULE_NAME, inst, buf); } -#undef BUFSIZE -#if SENSORS_HAVE_READ static void sensors_read (void) { featurelist_t *feature; @@ -200,4 +200,5 @@ void module_register (void) plugin_register (MODULE_NAME, collectd_sensors_init, sensors_read, sensors_write); } +#undef BUFSIZE #undef MODULE_NAME diff --git a/src/serial.c b/src/serial.c index a823ecf3..31b6148e 100644 --- a/src/serial.c +++ b/src/serial.c @@ -62,6 +62,7 @@ static void serial_write (char *host, char *inst, char *val) rrd_update_file (host, file, val, ds_def, ds_num); } +#if SERIAL_HAVE_READ #define BUFSIZE 512 static void serial_submit (char *device, unsigned long long incoming, @@ -77,7 +78,6 @@ static void serial_submit (char *device, } #undef BUFSIZE -#if SERIAL_HAVE_READ static void serial_read (void) { #ifdef KERNEL_LINUX diff --git a/src/swap.c b/src/swap.c index 9667b583..8ffa4536 100644 --- a/src/swap.c +++ b/src/swap.c @@ -74,6 +74,7 @@ static void swap_write (char *host, char *inst, char *val) rrd_update_file (host, swap_file, val, ds_def, ds_num); } +#if SWAP_HAVE_READ static void swap_submit (unsigned long long swap_used, unsigned long long swap_free, unsigned long long swap_cached, @@ -88,7 +89,6 @@ static void swap_submit (unsigned long long swap_used, plugin_submit (MODULE_NAME, "-", buffer); } -#if SWAP_HAVE_READ static void swap_read (void) { #ifdef KERNEL_LINUX diff --git a/src/tape.c b/src/tape.c index 0fc8f2c5..4671ed46 100644 --- a/src/tape.c +++ b/src/tape.c @@ -96,6 +96,7 @@ static void tape_write (char *host, char *inst, char *val) } +#if TAPE_HAVE_READ #define BUFSIZE 512 static void tape_submit (char *tape_name, unsigned long long read_count, @@ -122,7 +123,6 @@ static void tape_submit (char *tape_name, #undef BUFSIZE -#if TAPE_HAVE_READ static void tape_read (void) { diff --git a/src/traffic.c b/src/traffic.c index d3cea5af..7c852f81 100644 --- a/src/traffic.c +++ b/src/traffic.c @@ -32,6 +32,8 @@ # define TRAFFIC_HAVE_READ 0 #endif +#define BUFSIZE 512 + static char *traffic_filename_template = "traffic-%s.rrd"; static char *ds_def[] = @@ -80,19 +82,19 @@ static void traffic_init (void) static void traffic_write (char *host, char *inst, char *val) { - char file[512]; + char file[BUFSIZE]; int status; - status = snprintf (file, 512, traffic_filename_template, inst); + status = snprintf (file, BUFSIZE, traffic_filename_template, 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 +#if TRAFFIC_HAVE_READ static void traffic_submit (char *device, unsigned long long incoming, unsigned long long outgoing) @@ -104,9 +106,7 @@ static void traffic_submit (char *device, plugin_submit (MODULE_NAME, device, buf); } -#undef BUFSIZE -#if TRAFFIC_HAVE_READ static void traffic_read (void) { #ifdef KERNEL_LINUX @@ -193,4 +193,5 @@ void module_register (void) plugin_register (MODULE_NAME, traffic_init, traffic_read, traffic_write); } +#undef BUFSIZE #undef MODULE_NAME diff --git a/src/users.c b/src/users.c index e2b741c9..5fe1b711 100644 --- a/src/users.c +++ b/src/users.c @@ -60,6 +60,7 @@ static void users_write (char *host, char *inst, char *val) return; } /* static void users_write(char *host, char *inst, char *val) */ +#if USERS_HAVE_READ /* I don't like this temporary macro definition - well it's used everywhere else in the collectd-sources, so I will just stick with it... */ #define BUFSIZE 256 @@ -78,7 +79,6 @@ static void users_submit (unsigned int users) } /* static void users_submit(unsigned int users) */ #undef BUFSIZE -#if USERS_HAVE_READ static void users_read (void) { #if HAVE_GETUTXENT