From: Florian Forster Date: Mon, 2 Jul 2007 13:46:31 +0000 (+0200) Subject: Removed the `XXX_HAVE_READ' defines from all plugins. X-Git-Tag: collectd-4.1.0~40^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e4b274ed754af52196d3390b8ce101a7f94e318a;p=collectd.git Removed the `XXX_HAVE_READ' defines from all plugins. --- diff --git a/src/apache.c b/src/apache.c index 573a116a..2365d1ff 100644 --- a/src/apache.c +++ b/src/apache.c @@ -1,6 +1,6 @@ /** * collectd - src/apache.c - * Copyright (C) 2006 Florian octo Forster + * Copyright (C) 2006,2007 Florian octo Forster * Copyright (C) 2007 Florent EppO Monbillard * * This program is free software; you can redistribute it and/or modify it @@ -27,14 +27,8 @@ #include "plugin.h" #include "configfile.h" -#if HAVE_LIBCURL && HAVE_CURL_CURL_H -# define APACHE_HAVE_READ 1 -# include -#else -# define APACHE_HAVE_READ 0 -#endif +#include -#if APACHE_HAVE_READ static char *url = NULL; static char *user = NULL; static char *pass = NULL; @@ -309,14 +303,11 @@ static int apache_read (void) return (0); } /* int apache_read */ -#endif /* APACHE_HAVE_READ */ void module_register (void) { -#if APACHE_HAVE_READ plugin_register_config ("apache", config, config_keys, config_keys_num); plugin_register_init ("apache", init); plugin_register_read ("apache", apache_read); -#endif } /* void module_register */ diff --git a/src/apcups.c b/src/apcups.c index 75de03e8..62c7a3c4 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -1,9 +1,11 @@ /* * collectd - src/apcups.c + * Copyright (C) 2007 Florian octo Forster * Copyright (C) 2006 Anthony Gialluca * Copyright (C) 2000-2004 Kern Sibbald * Copyright (C) 1996-99 Andre M. Hedrick * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General * Public License as published by the Free Software Foundation. diff --git a/src/apple_sensors.c b/src/apple_sensors.c index e13bdc8a..2726ad2e 100644 --- a/src/apple_sensors.c +++ b/src/apple_sensors.c @@ -49,17 +49,8 @@ # include #endif -#if HAVE_IOKIT_IOKITLIB_H -# define IOKIT_HAVE_READ 1 -#else -# define IOKIT_HAVE_READ 0 -#endif - -#if HAVE_IOKIT_IOKITLIB_H static mach_port_t io_master_port = MACH_PORT_NULL; -#endif -#if IOKIT_HAVE_READ static int as_init (void) { kern_return_t status; @@ -240,12 +231,9 @@ static int as_read (void) return (0); } /* int as_read */ -#endif /* IOKIT_HAVE_READ */ void module_register (void) { -#if IOKIT_HAVE_READ plugin_register_init ("apple_sensors", as_init); plugin_register_read ("apple_sensors", as_read); -#endif /* IOKIT_HAVE_READ */ } /* void module_register */ diff --git a/src/battery.c b/src/battery.c index 952c56c0..2e27e60e 100644 --- a/src/battery.c +++ b/src/battery.c @@ -48,15 +48,12 @@ # include #endif -#if HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H || KERNEL_LINUX -# define BATTERY_HAVE_READ 1 -#else -# define BATTERY_HAVE_READ 0 +#if !HAVE_IOKIT_IOKITLIB_H && !HAVE_IOKIT_PS_IOPOWERSOURCES_H && !KERNEL_LINUX +# error "No applicable input method." #endif #define INVALID_VALUE 47841.29 -#if BATTERY_HAVE_READ #if HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H /* No global variables */ /* #endif HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H */ @@ -523,12 +520,9 @@ static int battery_read (void) return (0); } -#endif /* BATTERY_HAVE_READ */ void module_register (void) { -#if BATTERY_HAVE_READ plugin_register_init ("battery", battery_init); plugin_register_read ("battery", battery_read); -#endif /* BATTERY_HAVE_READ */ } /* void module_register */ diff --git a/src/cpu.c b/src/cpu.c index cbdde1ec..ba0c1b1a 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -68,13 +68,10 @@ # endif #endif /* HAVE_SYSCTLBYNAME */ -#if defined(PROCESSOR_CPU_LOAD_INFO) || defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) || defined(HAVE_SYSCTLBYNAME) -# define CPU_HAVE_READ 1 -#else -# define CPU_HAVE_READ 0 +#if !PROCESSOR_CPU_LOAD_INFO && !KERNEL_LINUX && !HAVE_LIBKSTAT && !HAVE_SYSCTLBYNAME +# error "No applicable input method." #endif -#if CPU_HAVE_READ #ifdef PROCESSOR_CPU_LOAD_INFO static mach_port_t port_host; static processor_port_array_t cpu_list; @@ -389,12 +386,9 @@ static int cpu_read (void) return (0); } -#endif /* CPU_HAVE_READ */ void module_register (void) { -#if CPU_HAVE_READ plugin_register_init ("cpu", init); plugin_register_read ("cpu", cpu_read); -#endif /* CPU_HAVE_READ */ } /* void module_register */ diff --git a/src/cpufreq.c b/src/cpufreq.c index 7a5c8fdf..b1037c38 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -26,20 +26,10 @@ #define MODULE_NAME "cpufreq" -#if defined(KERNEL_LINUX) -# define CPUFREQ_HAVE_READ 1 -#else -# define CPUFREQ_HAVE_READ 0 -#endif - -#if CPUFREQ_HAVE_READ -#ifdef KERNEL_LINUX static int num_cpu = 0; -#endif static int cpufreq_init (void) { -#ifdef KERNEL_LINUX int status; char filename[256]; @@ -64,7 +54,6 @@ static int cpufreq_init (void) if (num_cpu == 0) plugin_unregister_read ("cpufreq"); -#endif /* defined(KERNEL_LINUX) */ return (0); } /* int cpufreq_init */ @@ -89,7 +78,6 @@ static void cpufreq_submit (int cpu_num, double value) static int cpufreq_read (void) { -#ifdef KERNEL_LINUX int status; unsigned long long val; int i = 0; @@ -138,17 +126,12 @@ static int cpufreq_read (void) cpufreq_submit (i, val); } -#endif /* defined(KERNEL_LINUX) */ return (0); } /* int cpufreq_read */ -#endif /* CPUFREQ_HAVE_READ */ -#undef BUFSIZE void module_register (void) { -#if CPUFREQ_HAVE_READ plugin_register_init ("cpufreq", cpufreq_init); plugin_register_read ("cpufreq", cpufreq_read); -#endif /* CPUFREQ_HAVE_READ */ } diff --git a/src/df.c b/src/df.c index 433f4e2c..0f357d8d 100644 --- a/src/df.c +++ b/src/df.c @@ -26,12 +26,6 @@ #include "utils_mount.h" #include "utils_ignorelist.h" -#if HAVE_STATFS || HAVE_STATVFS -# define DF_HAVE_READ 1 -#else -# define DF_HAVE_READ 0 -#endif - #if HAVE_STATVFS # if HAVE_SYS_STATVFS_H # include @@ -44,9 +38,10 @@ # endif # define STATANYFS statfs # define BLOCKSIZE(s) (s).f_bsize +#else +# error "No applicable input method." #endif -#if DF_HAVE_READ static const char *config_keys[] = { "Device", @@ -209,14 +204,11 @@ static int df_read (void) return (0); } /* int df_read */ -#endif /* DF_HAVE_READ */ void module_register (void) { -#if DF_HAVE_READ plugin_register_config ("df", df_config, config_keys, config_keys_num); plugin_register_init ("df", df_init); plugin_register_read ("df", df_read); -#endif } /* void module_register */ diff --git a/src/disk.c b/src/disk.c index 38c161f5..490da07a 100644 --- a/src/disk.c +++ b/src/disk.c @@ -58,13 +58,6 @@ # define UINT_MAX 4294967295U #endif -#if HAVE_IOKIT_IOKITLIB_H || KERNEL_LINUX || HAVE_LIBKSTAT -# define DISK_HAVE_READ 1 -#else -# define DISK_HAVE_READ 0 -#endif - -#if DISK_HAVE_READ #if HAVE_IOKIT_IOKITLIB_H static mach_port_t io_master_port = MACH_PORT_NULL; /* #endif HAVE_IOKIT_IOKITLIB_H */ @@ -102,7 +95,11 @@ static diskstats_t *disklist; extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMDISK]; static int numdisk = 0; -#endif /* HAVE_LIBKSTAT */ +/* #endif HAVE_LIBKSTAT */ + +#else +# error "No applicable input method." +#endif static int disk_init (void) { @@ -639,12 +636,9 @@ static int disk_read (void) return (0); } /* int disk_read */ -#endif /* DISK_HAVE_READ */ void module_register (void) { -#if DISK_HAVE_READ plugin_register_init ("disk", disk_init); plugin_register_read ("disk", disk_read); -#endif /* DISK_HAVE_READ */ } /* void module_register */ diff --git a/src/dns.c b/src/dns.c index 7ce7aad9..2cbd0c37 100644 --- a/src/dns.c +++ b/src/dns.c @@ -24,20 +24,14 @@ #include "plugin.h" #include "configfile.h" -#if HAVE_LIBPCAP && HAVE_LIBPTHREAD -# include "utils_dns.h" -# include -# include -# include -# define DNS_HAVE_READ 1 -#else -# define DNS_HAVE_READ 0 -#endif +#include "utils_dns.h" +#include +#include +#include /* * Private data types */ -#if DNS_HAVE_READ struct counter_list_s { unsigned int key; @@ -45,12 +39,10 @@ struct counter_list_s struct counter_list_s *next; }; typedef struct counter_list_s counter_list_t; -#endif /* * Private variables */ -#if DNS_HAVE_READ static const char *config_keys[] = { "Interface", @@ -75,12 +67,10 @@ static pthread_mutex_t traffic_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t qtype_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t opcode_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t rcode_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif /* DNS_HAVE_READ */ /* * Private functions */ -#if DNS_HAVE_READ static counter_list_t *counter_list_search (counter_list_t **list, unsigned int key) { counter_list_t *entry; @@ -402,13 +392,10 @@ static int dns_read (void) return (0); } /* int dns_read */ -#endif void module_register (void) { -#if DNS_HAVE_READ plugin_register_config ("dns", dns_config, config_keys, config_keys_num); plugin_register_init ("dns", dns_init); plugin_register_read ("dns", dns_read); -#endif } /* void module_register */ diff --git a/src/entropy.c b/src/entropy.c index 7e903953..5f9eb530 100644 --- a/src/entropy.c +++ b/src/entropy.c @@ -1,6 +1,6 @@ /** * collectd - src/entropy.c - * Copyright (C) 2005,2006 Florian octo Forster + * Copyright (C) 2007 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -23,15 +23,12 @@ #include "common.h" #include "plugin.h" -#if KERNEL_LINUX -# define ENTROPY_HAVE_READ 1 -#else -# define ENTROPY_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif #define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" -#if ENTROPY_HAVE_READ static void entropy_submit (double entropy) { value_t values[1]; @@ -52,7 +49,6 @@ static void entropy_submit (double entropy) static int entropy_read (void) { -#if KERNEL_LINUX double entropy; FILE *fh; char buffer[64]; @@ -72,15 +68,11 @@ static int entropy_read (void) if (entropy > 0.0) entropy_submit (entropy); -#endif /* KERNEL_LINUX */ return (0); } -#endif /* ENTROPY_HAVE_READ */ void module_register (void) { -#if ENTROPY_HAVE_READ plugin_register_read ("entropy", entropy_read); -#endif } /* void module_register */ diff --git a/src/hddtemp.c b/src/hddtemp.c index d60481e3..b994fab3 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -31,17 +31,11 @@ #include "plugin.h" #include "configfile.h" -#if HAVE_NETDB_H && HAVE_SYS_SOCKET_H && HAVE_NETINET_IN_H \ - && HAVE_NETINET_TCP_H && HAVE_LIBGEN_H # include # include # include # include # include /* for basename */ -# define HDDTEMP_HAVE_READ 1 -#else -# define HDDTEMP_HAVE_READ 0 -#endif #if HAVE_LINUX_MAJOR_H # include @@ -50,7 +44,6 @@ #define HDDTEMP_DEF_HOST "127.0.0.1" #define HDDTEMP_DEF_PORT "7634" -#if HDDTEMP_HAVE_READ static const char *config_keys[] = { "Host", @@ -504,16 +497,13 @@ static int hddtemp_read (void) return (0); } /* int hddtemp_read */ -#endif /* HDDTEMP_HAVE_READ */ /* module_register Register collectd plugin. */ void module_register (void) { -#if HDDTEMP_HAVE_READ plugin_register_config ("hddtemp", hddtemp_config, config_keys, config_keys_num); plugin_register_init ("hddtemp", hddtemp_init); plugin_register_read ("hddtemp", hddtemp_read); -#endif /* HDDTEMP_HAVE_READ */ } diff --git a/src/interface.c b/src/interface.c index 52b2ddf0..741ff764 100644 --- a/src/interface.c +++ b/src/interface.c @@ -58,10 +58,8 @@ # endif /* !COLLECT_GETIFADDRS */ #endif /* KERNEL_LINUX */ -#if HAVE_GETIFADDRS || KERNEL_LINUX || HAVE_LIBKSTAT || HAVE_LIBSTATGRAB -# define INTERFACE_HAVE_READ 1 -#else -# define INTERFACE_HAVE_READ 0 +#if !HAVE_GETIFADDRS && !KERNEL_LINUX && !HAVE_LIBKSTAT && !HAVE_LIBSTATGRAB +# error "No applicable input method." #endif /* @@ -132,7 +130,6 @@ static int interface_config (const char *key, const char *value) #if HAVE_LIBKSTAT static int interface_init (void) { -#if HAVE_LIBKSTAT kstat_t *ksp_chain; unsigned long long val; @@ -155,7 +152,6 @@ static int interface_init (void) continue; ksp[numif++] = ksp_chain; } -#endif /* HAVE_LIBKSTAT */ return (0); } /* int interface_init */ @@ -181,7 +177,6 @@ static int check_ignore_if (const char *interface) return (1 - if_list_action); } /* int check_ignore_if */ -#if INTERFACE_HAVE_READ static void if_submit (const char *dev, const char *type, unsigned long long rx, unsigned long long tx) @@ -353,7 +348,6 @@ static int interface_read (void) return (0); } /* int interface_read */ -#endif /* INTERFACE_HAVE_READ */ void module_register (void) { @@ -362,7 +356,5 @@ void module_register (void) #if HAVE_LIBKSTAT plugin_register_init ("interface", interface_init); #endif -#if INTERFACE_HAVE_READ plugin_register_read ("interface", interface_read); -#endif } /* void module_register */ diff --git a/src/iptables.c b/src/iptables.c index 8dc57109..5fa1f408 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -29,26 +29,11 @@ # include #endif -#if HAVE_LIBIPTC_LIBIPTC_H -# define IPTABLES_HAVE_READ 1 -#else -# define IPTABLES_HAVE_READ 0 -#endif - -#define MODULE_NAME "iptables" -#define BUFSIZE 512 - /* * (Module-)Global variables */ /* - * Removed packet count for now, should have config option if you want to save - * them Although other collectd models don't seem to care much for options - * eitherway for what to log - */ -#if IPTABLES_HAVE_READ -/* * Config format should be `Chain table chainname', * e. g. `Chain mangle incoming' */ @@ -205,9 +190,7 @@ static int iptables_config (const char *key, const char *value) return (0); } /* int iptables_config */ -#endif /* IPTABLES_HAVE_READ */ -#if IPTABLES_HAVE_READ /* This needs to return `int' for IPT_MATCH_ITERATE to work. */ static int submit_match (const struct ipt_entry_match *match, const struct ipt_entry *entry, @@ -350,21 +333,15 @@ static int iptables_shutdown (void) return (0); } /* int iptables_shutdown */ -#endif /* IPTABLES_HAVE_READ */ void module_register (void) { -#if IPTABLES_HAVE_READ plugin_register_config ("iptables", iptables_config, config_keys, config_keys_num); plugin_register_read ("iptables", iptables_read); plugin_register_shutdown ("iptables", iptables_shutdown); -#endif } /* void module_register */ -#undef BUFSIZE -#undef MODULE_NAME - /* * vim:shiftwidth=4:softtabstop=4:tabstop=8 */ diff --git a/src/irq.c b/src/irq.c index 1c7b5aec..b6b8c4c6 100644 --- a/src/irq.c +++ b/src/irq.c @@ -25,10 +25,8 @@ #include "plugin.h" #include "configfile.h" -#if KERNEL_LINUX -# define IRQ_HAVE_READ 1 -#else -# define IRQ_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif #define BUFSIZE 128 @@ -36,7 +34,6 @@ /* * (Module-)Global variables */ -#if IRQ_HAVE_READ static const char *config_keys[] = { "Irq", @@ -148,8 +145,6 @@ static void irq_submit (unsigned int irq, counter_t value) static int irq_read (void) { -#if KERNEL_LINUX - #undef BUFSIZE #define BUFSIZE 256 @@ -198,19 +193,15 @@ static int irq_read (void) irq_submit (irq, irq_value); } fclose (fh); -#endif /* KERNEL_LINUX */ return (0); } /* int irq_read */ -#endif /* IRQ_HAVE_READ */ void module_register (void) { -#if IRQ_HAVE_READ plugin_register_config ("irq", irq_config, config_keys, config_keys_num); plugin_register_read ("irq", irq_read); -#endif /* IRQ_HAVE_READ */ } /* void module_register */ #undef BUFSIZE diff --git a/src/load.c b/src/load.c index 22872f04..c9f130b7 100644 --- a/src/load.c +++ b/src/load.c @@ -1,6 +1,6 @@ /** * collectd - src/load.c - * Copyright (C) 2005,2006 Florian octo Forster + * Copyright (C) 2005-2007 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -23,12 +23,6 @@ #include "common.h" #include "plugin.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 #endif @@ -41,7 +35,6 @@ #endif #endif /* defined(HAVE_GETLOADAVG) */ -#if LOAD_HAVE_READ static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum) { value_t values[3]; @@ -131,15 +124,16 @@ static int load_read (void) lnum = ls->min15; load_submit (snum, mnum, lnum); -#endif /* HAVE_LIBSTATGRAB */ +/* #endif HAVE_LIBSTATGRAB */ + +#else +# error "No applicable input method." +#endif return (0); } -#endif /* LOAD_HAVE_READ */ void module_register (void) { -#if LOAD_HAVE_READ plugin_register_read ("load", load_read); -#endif } /* void module_register */ diff --git a/src/mbmon.c b/src/mbmon.c index 68a09850..c3909d57 100644 --- a/src/mbmon.c +++ b/src/mbmon.c @@ -26,15 +26,10 @@ #include "plugin.h" #include "configfile.h" -#if HAVE_NETDB_H && HAVE_SYS_SOCKET_H && HAVE_NETINET_IN_H && HAVE_NETINET_TCP_H -# include -# include -# include -# include -# define MBMON_HAVE_READ 1 -#else -# define MBMON_HAVE_READ 0 -#endif +#include +#include +#include +#include #define MBMON_DEF_HOST "127.0.0.1" #define MBMON_DEF_PORT "411" /* the default for Debian */ @@ -47,7 +42,6 @@ static const char *config_keys[] = }; static int config_keys_num = 2; -#if MBMON_HAVE_READ static char *mbmon_host = NULL; static char *mbmon_port = NULL; @@ -305,14 +299,11 @@ static int mbmon_read (void) return (0); } /* void mbmon_read */ -#endif /* MBMON_HAVE_READ */ /* module_register Register collectd plugin. */ void module_register (void) { -#if MBMON_HAVE_READ plugin_register_config ("mbmon", mbmon_config, config_keys, config_keys_num); plugin_register_read ("mbmon", mbmon_read); -#endif /* MBMON_HAVE_READ */ } /* void module_register */ diff --git a/src/memory.c b/src/memory.c index cb7e6882..47b3cb31 100644 --- a/src/memory.c +++ b/src/memory.c @@ -43,12 +43,6 @@ # include #endif -#if defined (HOST_VM_INFO) || HAVE_SYSCTLBYNAME || KERNEL_LINUX || HAVE_LIBKSTAT -# define MEMORY_HAVE_READ 1 -#else -# define MEMORY_HAVE_READ 0 -#endif - /* vm_statistics_data_t */ #if defined(HOST_VM_INFO) static mach_port_t port_host; @@ -66,9 +60,12 @@ static vm_size_t pagesize; #elif HAVE_LIBKSTAT static int pagesize; static kstat_t *ksp; -#endif /* HAVE_LIBKSTAT */ +/* #endif HAVE_LIBKSTAT */ + +#else +# error "No applicable input method." +#endif -#if MEMORY_HAVE_READ static int memory_init (void) { #if defined(HOST_VM_INFO) @@ -321,12 +318,9 @@ static int memory_read (void) return (0); } -#endif /* MEMORY_HAVE_READ */ void module_register (void) { -#if MEMORY_HAVE_READ plugin_register_init ("memory", memory_init); plugin_register_read ("memory", memory_read); -#endif /* MEMORY_HAVE_READ */ } /* void module_register */ diff --git a/src/multimeter.c b/src/multimeter.c index 21a21447..11ca42c1 100644 --- a/src/multimeter.c +++ b/src/multimeter.c @@ -30,13 +30,10 @@ # include # include # include -# define MULTIMETER_HAVE_READ 1 #else -# define MULTIMETER_HAVE_READ 0 -# error "multimeter cannot read!" +# error "No applicable input method." #endif -#if MULTIMETER_HAVE_READ static int fd = -1; static int multimeter_timeval_sub (struct timeval *tv1, struct timeval *tv2, @@ -58,6 +55,7 @@ static int multimeter_timeval_sub (struct timeval *tv1, struct timeval *tv2, } return (0); } + #define LINE_LENGTH 14 static int multimeter_read_value(double *value) { @@ -248,13 +246,10 @@ static int multimeter_shutdown (void) return (0); } -#endif /* MULTIMETER_HAVE_READ */ void module_register (void) { -#if MULTIMETER_HAVE_READ plugin_register_init ("multimeter", multimeter_init); plugin_register_read ("multimeter", multimeter_read); plugin_register_shutdown ("multimeter", multimeter_shutdown); -#endif /* MULTIMETER_HAVE_READ */ } /* void module_register */ diff --git a/src/mysql.c b/src/mysql.c index fccaedbd..d4728531 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -28,15 +28,8 @@ #include #endif -#if COLLECT_LIBMYSQL -# define MYSQL_HAVE_READ 1 -#else -# define MYSQL_HAVE_READ 0 -#endif - /* TODO: Understand `Select_*' and possibly do that stuff as well.. */ -#if MYSQL_HAVE_READ static const char *config_keys[] = { "Host", @@ -322,12 +315,9 @@ static int mysql_read (void) return (0); } /* int mysql_read */ -#endif /* MYSQL_HAVE_READ */ void module_register (void) { -#if MYSQL_HAVE_READ plugin_register_config ("mysql", config, config_keys, config_keys_num); plugin_register_read ("mysql", mysql_read); -#endif /* MYSQL_HAVE_READ */ } /* void module_register */ diff --git a/src/nfs.c b/src/nfs.c index 299d63b9..77c7f48f 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -24,11 +24,8 @@ #include "common.h" #include "plugin.h" -/* #if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) */ -#if KERNEL_LINUX -# define NFS_HAVE_READ 1 -#else -# define NFS_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif /* @@ -76,7 +73,6 @@ Number Procedures Procedures 21 commit */ -#if NFS_HAVE_READ static const char *nfs2_procedures_names[] = { "null", @@ -209,7 +205,6 @@ static void nfs_procedures_submit (const char *plugin_instance, } } /* void nfs_procedures_submit */ -#if KERNEL_LINUX static void nfs_read_stats_file (FILE *fh, char *inst) { char buffer[BUFSIZE]; @@ -307,7 +302,6 @@ static void nfs_read_stats_file (FILE *fh, char *inst) } } /* while (fgets (buffer, BUFSIZE, fh) != NULL) */ } /* void nfs_read_stats_file */ -#endif /* defined(KERNEL_LINUX) */ #undef BUFSIZE #if HAVE_LIBKSTAT && 0 @@ -340,7 +334,6 @@ static void nfs2_read_kstat (kstat_t *ksp, char *inst) static int nfs_read (void) { -#if KERNEL_LINUX FILE *fh; if ((fh = fopen ("/proc/net/rpc/nfs", "r")) != NULL) @@ -355,9 +348,7 @@ static int nfs_read (void) fclose (fh); } -/* #endif defined(KERNEL_LINUX) */ - -#elif HAVE_LIBKSTAT && 0 +#if HAVE_LIBKSTAT && 0 if (nfs2_ksp_client != NULL) nfs2_read_kstat (nfs2_ksp_client, "client"); if (nfs2_ksp_server != NULL) @@ -366,11 +357,8 @@ static int nfs_read (void) return (0); } -#endif /* NFS_HAVE_READ */ void module_register (void) { -#if NFS_HAVE_READ plugin_register_read ("nfs", nfs_read); -#endif } /* void module_register */ diff --git a/src/ntpd.c b/src/ntpd.c index 1c97e69a..8328a9c8 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -24,12 +24,6 @@ #include "plugin.h" #include "configfile.h" -#if HAVE_SYS_SOCKET_H -# define NTPD_HAVE_READ 1 -#else -# define NTPD_HAVE_READ 0 -#endif - #if HAVE_STDINT_H # include #endif @@ -60,7 +54,6 @@ static const char *config_keys[] = }; static int config_keys_num = 2; -#if NTPD_HAVE_READ # define NTPD_DEFAULT_HOST "localhost" # define NTPD_DEFAULT_PORT "123" static int sock_descr = -1; @@ -956,13 +949,10 @@ static int ntpd_read (void) return (0); } /* int ntpd_read */ -#endif /* NTPD_HAVE_READ */ void module_register (void) { -#if NTPD_HAVE_READ plugin_register_config ("ntpd", ntpd_config, config_keys, config_keys_num); plugin_register_read ("ntpd", ntpd_read); -#endif /* NTPD_HAVE_READ */ } /* void module_register */ diff --git a/src/nut.c b/src/nut.c index 6af12b82..bde5d820 100644 --- a/src/nut.c +++ b/src/nut.c @@ -29,12 +29,8 @@ #if HAVE_UPSCLIENT_H # include -# define NUT_HAVE_READ 1 -#else -# define NUT_HAVE_READ 0 #endif -#if NUT_HAVE_READ struct nut_ups_s; typedef struct nut_ups_s nut_ups_t; struct nut_ups_s @@ -286,15 +282,12 @@ static int nut_shutdown (void) return (0); } /* int nut_shutdown */ -#endif /* NUT_HAVE_READ */ void module_register (void) { -#if NUT_HAVE_READ plugin_register_config ("nut", nut_config, config_keys, config_keys_num); plugin_register_read ("nut", nut_read); plugin_register_shutdown ("nut", nut_shutdown); -#endif } /* void module_register */ /* vim: set sw=2 ts=8 sts=2 tw=78 : */ diff --git a/src/processes.c b/src/processes.c index ff401266..29492ac2 100644 --- a/src/processes.c +++ b/src/processes.c @@ -80,27 +80,20 @@ # ifndef CONFIG_HZ # define CONFIG_HZ 100 # endif -#endif /* KERNEL_LINUX */ - -#define MODULE_NAME "processes" +/* #endif KERNEL_LINUX */ -#if HAVE_THREAD_INFO || KERNEL_LINUX -# define PROCESSES_HAVE_READ 1 #else -# define PROCESSES_HAVE_READ 0 +# error "No applicable input method." #endif #define BUFSIZE 256 -#if PROCESSES_HAVE_READ -#if HAVE_THREAD_INFO | KERNEL_LINUX static const char *config_keys[] = { "Process", NULL }; static int config_keys_num = 1; -#endif typedef struct procstat_entry_s { @@ -143,9 +136,7 @@ typedef struct procstat struct procstat_entry_s *instances; } procstat_t; -#if HAVE_THREAD_INFO | KERNEL_LINUX static procstat_t *list_head_g = NULL; -#endif #if HAVE_THREAD_INFO static mach_port_t port_host_self; @@ -159,7 +150,6 @@ static mach_msg_type_number_t pset_list_len; static long pagesize_g; #endif /* KERNEL_LINUX */ -#if HAVE_THREAD_INFO | KERNEL_LINUX static void ps_list_register (const char *name) { procstat_t *new; @@ -370,7 +360,6 @@ static int ps_config (const char *key, const char *value) return (0); } -#endif /* HAVE_THREAD_INFO | KERNEL_LINUX */ static int ps_init (void) { @@ -1018,16 +1007,11 @@ static int ps_read (void) return (0); } /* int ps_read */ -#endif /* PROCESSES_HAVE_READ */ void module_register (void) { -#if PROCESSES_HAVE_READ -#if HAVE_THREAD_INFO | KERNEL_LINUX plugin_register_config ("processes", ps_config, config_keys, config_keys_num); -#endif plugin_register_init ("processes", ps_init); plugin_register_read ("processes", ps_read); -#endif /* PROCESSES_HAVE_READ */ } /* void module_register */ diff --git a/src/sensors.c b/src/sensors.c index e1bc7aaf..3e1d4f9a 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -36,17 +36,8 @@ #if defined(HAVE_SENSORS_SENSORS_H) # include -#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 @@ -421,14 +412,11 @@ static int sensors_read (void) 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 */ diff --git a/src/serial.c b/src/serial.c index dd063bb5..9cfe1dd4 100644 --- a/src/serial.c +++ b/src/serial.c @@ -25,13 +25,10 @@ #include "common.h" #include "plugin.h" -#if defined(KERNEL_LINUX) -# define SERIAL_HAVE_READ 1 -#else -# define SERIAL_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif -#if SERIAL_HAVE_READ static void serial_submit (const char *type_instance, counter_t rx, counter_t tx) { @@ -54,7 +51,6 @@ static void serial_submit (const char *type_instance, static int serial_read (void) { -#ifdef KERNEL_LINUX FILE *fh; char buffer[1024]; @@ -121,13 +117,9 @@ static int serial_read (void) fclose (fh); return (0); -#endif /* KERNEL_LINUX */ } /* int serial_read */ -#endif /* SERIAL_HAVE_READ */ void module_register (void) { -#if SERIAL_HAVE_READ plugin_register_read ("serial", serial_read); -#endif /* SERIAL_HAVE_READ */ } /* void module_register */ diff --git a/src/swap.c b/src/swap.c index 3018cb9e..4a414b70 100644 --- a/src/swap.c +++ b/src/swap.c @@ -36,16 +36,9 @@ # include #endif -#if KERNEL_LINUX || HAVE_LIBKSTAT || defined(VM_SWAPUSAGE) || HAVE_LIBKVM || HAVE_LIBSTATGRAB -# define SWAP_HAVE_READ 1 -#else -# define SWAP_HAVE_READ 0 -#endif - #undef MAX #define MAX(x,y) ((x) > (y) ? (x) : (y)) -#if SWAP_HAVE_READ #if KERNEL_LINUX /* No global variables */ /* #endif KERNEL_LINUX */ @@ -66,6 +59,10 @@ int kvm_pagesize; #elif HAVE_LIBSTATGRAB /* No global variables */ +/* #endif HAVE_LIBSTATGRAB */ + +#else +# error "No applicable input method." #endif /* HAVE_LIBSTATGRAB */ static int swap_init (void) @@ -300,12 +297,9 @@ static int swap_read (void) return (0); } /* int swap_read */ -#endif /* SWAP_HAVE_READ */ void module_register (void) { -#if SWAP_HAVE_READ plugin_register_init ("swap", swap_init); plugin_register_read ("swap", swap_read); -#endif /* SWAP_HAVE_READ */ } /* void module_register */ diff --git a/src/tape.c b/src/tape.c index 5e01f0d8..465688ed 100644 --- a/src/tape.c +++ b/src/tape.c @@ -24,23 +24,17 @@ #include "common.h" #include "plugin.h" -#if defined(HAVE_LIBKSTAT) -# define TAPE_HAVE_READ 1 -#else -# define TAPE_HAVE_READ 0 +#if !HAVE_LIBKSTAT +# error "No applicable input method." #endif -#if TAPE_HAVE_READ -#if defined(HAVE_LIBKSTAT) #define MAX_NUMTAPE 256 extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMTAPE]; static int numtape = 0; -#endif /* HAVE_LIBKSTAT */ static int tape_init (void) { -#ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; numtape = 0; @@ -58,10 +52,9 @@ static int tape_init (void) continue; ksp[numtape++] = ksp_chain; } -#endif return (0); -} +} /* int tape_init */ static void tape_submit (const char *plugin_instance, const char *type, @@ -87,24 +80,23 @@ static void tape_submit (const char *plugin_instance, static int tape_read (void) { -#if defined(HAVE_LIBKSTAT) -# if HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_NWRITES && HAVE_KSTAT_IO_T_WTIME -# define KIO_ROCTETS reads -# define KIO_WOCTETS writes -# define KIO_ROPS nreads -# define KIO_WOPS nwrites -# define KIO_RTIME rtime -# define KIO_WTIME wtime -# elif HAVE_KSTAT_IO_T_NWRITTEN && HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_WTIME -# define KIO_ROCTETS nread -# define KIO_WOCTETS nwritten -# define KIO_ROPS reads -# define KIO_WOPS writes -# define KIO_RTIME rtime -# define KIO_WTIME wtime -# else -# error "kstat_io_t does not have the required members" -# endif +#if HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_NWRITES && HAVE_KSTAT_IO_T_WTIME +# define KIO_ROCTETS reads +# define KIO_WOCTETS writes +# define KIO_ROPS nreads +# define KIO_WOPS nwrites +# define KIO_RTIME rtime +# define KIO_WTIME wtime +#elif HAVE_KSTAT_IO_T_NWRITTEN && HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_WTIME +# define KIO_ROCTETS nread +# define KIO_WOCTETS nwritten +# define KIO_ROPS reads +# define KIO_WOPS writes +# define KIO_RTIME rtime +# define KIO_WTIME wtime +#else +# error "kstat_io_t does not have the required members" +#endif static kstat_io_t kio; int i; @@ -130,16 +122,12 @@ static int tape_read (void) kio.KIO_RTIME, kio.KIO_WTIME); } } -#endif /* defined(HAVE_LIBKSTAT) */ return (0); } -#endif /* TAPE_HAVE_READ */ void module_register (void) { -#if TAPE_HAVE_READ plugin_register_init ("tape", tape_init); plugin_register_read ("tape", tape_read); -#endif /* TAPE_HAVE_READ */ } diff --git a/src/users.c b/src/users.c index 7df06c2b..afe26e1e 100644 --- a/src/users.c +++ b/src/users.c @@ -25,21 +25,16 @@ #if HAVE_UTMPX_H # include -#else /* !HAVE_UTMPX_H */ -# if HAVE_UTMP_H -# include -# endif /* HAVE_UTMP_H */ -#endif /* HAVE_UTMPX_H */ +/* #endif HAVE_UTMPX_H */ -#define MODULE_NAME "users" +#elif HAVE_UTMP_H +# include +/* #endif HAVE_UTMP_H */ -#if HAVE_GETUTXENT || HAVE_GETUTENT -# define USERS_HAVE_READ 1 #else -# define USERS_HAVE_READ 0 +# error "No applicable input method." #endif -#if USERS_HAVE_READ static void users_submit (gauge_t value) { value_t values[1]; @@ -92,15 +87,16 @@ static int users_read (void) endutent(); users_submit (users); -#endif /* HAVE_GETUTENT */ +/* #endif HAVE_GETUTENT */ + +#else +# error "No applicable input method." +#endif return (0); } /* int users_read */ -#endif /* USERS_HAVE_READ */ void module_register (void) { -#if USERS_HAVE_READ plugin_register_read ("users", users_read); -#endif } /* void module_register(void) */ diff --git a/src/vserver.c b/src/vserver.c index 8d524e77..7b83c617 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -28,16 +28,12 @@ #define BUFSIZE 512 -#define MODULE_NAME "vserver" #define PROCDIR "/proc/virtual" -#if defined(KERNEL_LINUX) -# define VSERVER_HAVE_READ 1 -#else -# define VSERVER_HAVE_READ 0 -#endif /* defined(KERNEL_LINUX) */ +#if !KERNEL_LINUX +# error "No applicable input method." +#endif -#if VSERVER_HAVE_READ static int pagesize = 0; static int vserver_init (void) @@ -306,14 +302,11 @@ static int vserver_read (void) return (0); } /* int vserver_read */ -#endif /* VSERVER_HAVE_READ */ void module_register (void) { -#if VSERVER_HAVE_READ plugin_register_init ("vserver", vserver_init); plugin_register_read ("vserver", vserver_read); -#endif /* VSERVER_HAVE_READ */ } /* void module_register(void) */ /* vim: set ts=4 sw=4 noexpandtab : */ diff --git a/src/wireless.c b/src/wireless.c index 81c968e8..09df4070 100644 --- a/src/wireless.c +++ b/src/wireless.c @@ -23,15 +23,12 @@ #include "common.h" #include "plugin.h" -#if defined(KERNEL_LINUX) -# define WIRELESS_HAVE_READ 1 -#else -# define WIRELESS_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif #define WIRELESS_PROC_FILE "/proc/net/wireless" -#if WIRELESS_HAVE_READ #if 0 static double wireless_dbm_to_watt (double dbm) { @@ -140,11 +137,8 @@ static int wireless_read (void) return (0); } /* int wireless_read */ -#endif /* WIRELESS_HAVE_READ */ void module_register (void) { -#if WIRELESS_HAVE_READ plugin_register_read ("wireless", wireless_read); -#endif /* WIRELESS_HAVE_READ */ } /* void module_register */