From: octo Date: Sat, 17 Dec 2005 11:45:44 +0000 (+0000) Subject: Cleaned up all the modules, unified define order and the like.. X-Git-Tag: collectd-3.6.0~36 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9ac8dcf06e686456ed893acedf5f0ba68e3e3c97;p=collectd.git Cleaned up all the modules, unified define order and the like.. --- diff --git a/src/cpu.c b/src/cpu.c index 6832b523..5252324a 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -26,12 +26,6 @@ #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 #endif /* HAVE_LIBKSTAT */ @@ -45,6 +39,12 @@ # 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 @@ -80,7 +80,7 @@ static char *ds_def[] = }; static int ds_num = 5; -void cpu_init (void) +static void cpu_init (void) { #ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -116,7 +116,7 @@ void cpu_init (void) return; } -void cpu_write (char *host, char *inst, char *val) +static void cpu_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -249,17 +249,13 @@ static void cpu_read (void) return; } +#else +# define cpu_read NULL #endif /* CPU_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, cpu_init, -#if CPU_HAVE_READ - cpu_read, -#else - NULL, -#endif - cpu_write); + plugin_register (MODULE_NAME, cpu_init, cpu_read, cpu_write); } #undef MODULE_NAME diff --git a/src/cpufreq.c b/src/cpufreq.c index 92f1cc58..6806c3e6 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -26,6 +26,12 @@ #define MODULE_NAME "cpufreq" +#if defined(KERNEL_LINUX) +# define CPUFREQ_HAVE_READ 1 +#else +# define CPUFREQ_HAVE_READ 0 +#endif + static char *cpufreq_file = "cpufreq-%s.rrd"; static char *ds_def[] = @@ -91,6 +97,7 @@ 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 @@ -131,6 +138,9 @@ static void cpufreq_read (void) return; } +#else +#define cpufreq_read NULL +#endif #undef BUFSIZE void module_register (void) diff --git a/src/disk.c b/src/disk.c index f6234c22..cd876014 100644 --- a/src/disk.c +++ b/src/disk.c @@ -337,18 +337,14 @@ static void disk_read (void) } #endif /* defined(HAVE_LIBKSTAT) */ } /* static void disk_read (void) */ +#else +# define disk_read NULL #endif /* DISK_HAVE_READ */ void module_register (void) { plugin_register ("partition", NULL, NULL, partition_write); - plugin_register (MODULE_NAME, disk_init, -#if DISK_HAVE_READ - disk_read, -#else - NULL, -#endif - disk_write); + plugin_register (MODULE_NAME, disk_init, disk_read, disk_write); } #undef MODULE_NAME diff --git a/src/hddtemp.c b/src/hddtemp.c index f2e8262f..cfa7b8ff 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -365,3 +365,5 @@ void module_register (void) { plugin_register (MODULE_NAME, hddtemp_init, hddtemp_read, hddtemp_write); } + +#undef MODULE_NAME diff --git a/src/load.c b/src/load.c index 2c02d8be..8d0963bc 100644 --- a/src/load.c +++ b/src/load.c @@ -55,18 +55,18 @@ static char *ds_def[] = }; static int ds_num = 3; -void load_init (void) +static void load_init (void) { return; } -void load_write (char *host, char *inst, char *val) +static void load_write (char *host, char *inst, char *val) { rrd_update_file (host, load_file, val, ds_def, ds_num); } #define BUFSIZE 256 -void load_submit (double snum, double mnum, double lnum) +static void load_submit (double snum, double mnum, double lnum) { char buf[BUFSIZE]; @@ -79,7 +79,7 @@ void load_submit (double snum, double mnum, double lnum) #undef BUFSIZE #if LOAD_HAVE_READ -void load_read (void) +static void load_read (void) { #if defined(HAVE_GETLOADAVG) double load[3]; @@ -139,17 +139,13 @@ void load_read (void) load_submit (snum, mnum, lnum); #endif /* HAVE_LIBSTATGRAB */ } +#else +# define load_read NULL #endif /* LOAD_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, load_init, -#if LOAD_HAVE_READ - load_read, -#else - NULL, -#endif - load_write); + plugin_register (MODULE_NAME, load_init, load_read, load_write); } #undef MODULE_NAME diff --git a/src/memory.c b/src/memory.c index 6ae35cbb..dd8bd787 100644 --- a/src/memory.c +++ b/src/memory.c @@ -50,7 +50,7 @@ static int pagesize; static kstat_t *ksp; #endif /* HAVE_LIBKSTAT */ -void memory_init (void) +static void memory_init (void) { #ifdef HAVE_LIBKSTAT /* getpagesize(3C) tells me this does not fail.. */ @@ -62,13 +62,13 @@ void memory_init (void) return; } -void memory_write (char *host, char *inst, char *val) +static void memory_write (char *host, char *inst, char *val) { rrd_update_file (host, memory_file, val, ds_def, ds_num); } #define BUFSIZE 512 -void memory_submit (long long mem_used, long long mem_buffered, +static void memory_submit (long long mem_used, long long mem_buffered, long long mem_cached, long long mem_free) { char buf[BUFSIZE]; @@ -83,7 +83,7 @@ void memory_submit (long long mem_used, long long mem_buffered, #undef BUFSIZE #if MEMORY_HAVE_READ -void memory_read (void) +static void memory_read (void) { #ifdef KERNEL_LINUX FILE *fh; @@ -168,17 +168,13 @@ void memory_read (void) memory_submit (ios->used, 0LL, ios->cache, ios->free); #endif /* HAVE_LIBSTATGRAB */ } +#else +# define memory_read NULL #endif /* MEMORY_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, memory_init, -#if MEMORY_HAVE_READ - memory_read, -#else - NULL, -#endif - memory_write); + plugin_register (MODULE_NAME, memory_init, memory_read, memory_write); } #undef MODULE_NAME diff --git a/src/nfs.c b/src/nfs.c index 03331137..c9fbd8f5 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -145,7 +145,7 @@ static kstat_t *nfs4_ksp_server; /* Possibly TODO: NFSv4 statistics */ -void nfs_init (void) +static void nfs_init (void) { #ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -184,7 +184,7 @@ void nfs_init (void) } #define BUFSIZE 1024 -void nfs2_procedures_write (char *host, char *inst, char *val) +static void nfs2_procedures_write (char *host, char *inst, char *val) { char filename[BUFSIZE]; @@ -195,7 +195,7 @@ void nfs2_procedures_write (char *host, char *inst, char *val) nfs2_procedures_ds_num); } -void nfs3_procedures_write (char *host, char *inst, char *val) +static void nfs3_procedures_write (char *host, char *inst, char *val) { char filename[BUFSIZE]; @@ -206,7 +206,7 @@ void nfs3_procedures_write (char *host, char *inst, char *val) nfs3_procedures_ds_num); } -void nfs2_procedures_submit (unsigned long long *val, char *inst) +static void nfs2_procedures_submit (unsigned long long *val, char *inst) { char buf[BUFSIZE]; int retval = 0; @@ -231,7 +231,7 @@ void nfs2_procedures_submit (unsigned long long *val, char *inst) plugin_submit ("nfs2_procedures", inst, buf); } -void nfs3_procedures_submit (unsigned long long *val, char *inst) +static void nfs3_procedures_submit (unsigned long long *val, char *inst) { char buf[BUFSIZE]; int retval = 0; @@ -257,7 +257,7 @@ void nfs3_procedures_submit (unsigned long long *val, char *inst) } #if defined(KERNEL_LINUX) -void nfs_read_stats_file (FILE *fh, char *inst) +static void nfs_read_stats_file (FILE *fh, char *inst) { char buffer[BUFSIZE]; @@ -328,7 +328,7 @@ void nfs_read_stats_file (FILE *fh, char *inst) #undef BUFSIZE #ifdef HAVE_LIBKSTAT -void nfs2_read_kstat (kstat_t *ksp, char *inst) +static void nfs2_read_kstat (kstat_t *ksp, char *inst) { unsigned long long values[18]; @@ -356,7 +356,7 @@ void nfs2_read_kstat (kstat_t *ksp, char *inst) #endif #if NFS_HAVE_READ -void nfs_read (void) +static void nfs_read (void) { #if defined(KERNEL_LINUX) FILE *fh; @@ -382,17 +382,13 @@ void nfs_read (void) nfs2_read_kstat (nfs2_ksp_server, "server"); #endif /* defined(HAVE_LIBKSTAT) */ } +#else +# define nfs_read NULL #endif /* NFS_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, nfs_init, -#if NFS_HAVE_READ - nfs_read, -#else - NULL, -#endif - NULL); + 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); } diff --git a/src/ping.c b/src/ping.c index 6a2b9068..bdb8de96 100644 --- a/src/ping.c +++ b/src/ping.c @@ -52,7 +52,7 @@ static char *config_keys[] = }; static int config_keys_num = 1; -void ping_init (void) +static void ping_init (void) { int i; @@ -62,7 +62,7 @@ void ping_init (void) return; } -int ping_config (char *key, char *value) +static int ping_config (char *key, char *value) { if (strcasecmp (key, "host")) { @@ -84,7 +84,7 @@ int ping_config (char *key, char *value) } } -void ping_write (char *host, char *inst, char *val) +static void ping_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -99,7 +99,7 @@ void ping_write (char *host, char *inst, char *val) } #define BUFSIZE 256 -void ping_submit (int ping_time, char *host) +static void ping_submit (int ping_time, char *host) { char buf[BUFSIZE]; @@ -110,7 +110,7 @@ void ping_submit (int ping_time, char *host) } #undef BUFSIZE -void ping_read (void) +static void ping_read (void) { int ping; int i; diff --git a/src/processes.c b/src/processes.c index e2bda15e..d1fe696a 100644 --- a/src/processes.c +++ b/src/processes.c @@ -47,17 +47,17 @@ static char *ds_def[] = }; static int ds_num = 6; -void ps_init (void) +static void ps_init (void) { } -void ps_write (char *host, char *inst, char *val) +static void ps_write (char *host, char *inst, char *val) { rrd_update_file (host, ps_file, val, ds_def, ds_num); } #define BUFSIZE 256 -void ps_submit (unsigned int running, +static void ps_submit (unsigned int running, unsigned int sleeping, unsigned int zombies, unsigned int stopped, @@ -76,7 +76,7 @@ void ps_submit (unsigned int running, } #if PROCESSES_HAVE_READ -void ps_read (void) +static void ps_read (void) { #ifdef KERNEL_LINUX unsigned int running, sleeping, zombies, stopped, paging, blocked; @@ -138,18 +138,14 @@ void ps_read (void) ps_submit (running, sleeping, zombies, stopped, paging, blocked); #endif /* defined(KERNEL_LINUX) */ } +#else +# define ps_read NULL #endif /* PROCESSES_HAVE_READ */ #undef BUFSIZE void module_register (void) { - plugin_register (MODULE_NAME, ps_init, -#if PROCESSES_HAVE_READ - ps_read, -#else - NULL, -#endif - ps_write); + plugin_register (MODULE_NAME, ps_init, ps_read, ps_write); } #undef MODULE_NAME diff --git a/src/sensors.c b/src/sensors.c index 13139636..b6c76f88 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -191,17 +191,13 @@ static void sensors_read (void) 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, -#if SENSORS_HAVE_READ - sensors_read, -#else - NULL, -#endif - sensors_write); + plugin_register (MODULE_NAME, collectd_sensors_init, sensors_read, sensors_write); } #undef MODULE_NAME diff --git a/src/serial.c b/src/serial.c index 20a51e70..a823ecf3 100644 --- a/src/serial.c +++ b/src/serial.c @@ -152,17 +152,13 @@ static void serial_read (void) fclose (fh); #endif /* KERNEL_LINUX */ } +#else +# define serial_read NULL #endif /* SERIAL_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, serial_init, -#if SERIAL_HAVE_READ - serial_read, -#else - NULL, -#endif - serial_write); + plugin_register (MODULE_NAME, serial_init, serial_read, serial_write); } #undef MODULE_NAME diff --git a/src/swap.c b/src/swap.c index eb476a42..9667b583 100644 --- a/src/swap.c +++ b/src/swap.c @@ -57,7 +57,7 @@ static int pagesize; static kstat_t *ksp; #endif /* KERNEL_SOLARIS */ -static void module_init (void) +static void swap_init (void) { #ifdef KERNEL_SOLARIS /* getpagesize(3C) tells me this does not fail.. */ @@ -69,12 +69,12 @@ static void module_init (void) return; } -static void module_write (char *host, char *inst, char *val) +static void swap_write (char *host, char *inst, char *val) { rrd_update_file (host, swap_file, val, ds_def, ds_num); } -static void module_submit (unsigned long long swap_used, +static void swap_submit (unsigned long long swap_used, unsigned long long swap_free, unsigned long long swap_cached, unsigned long long swap_resv) @@ -89,7 +89,7 @@ static void module_submit (unsigned long long swap_used, } #if SWAP_HAVE_READ -static void module_read (void) +static void swap_read (void) { #ifdef KERNEL_LINUX FILE *fh; @@ -138,7 +138,7 @@ static void module_read (void) swap_used = swap_total - (swap_free + swap_cached); - module_submit (swap_used, swap_free, swap_cached, -1LL); + swap_submit (swap_used, swap_free, swap_cached, -1LL); /* #endif defined(KERNEL_LINUX) */ #elif defined(KERNEL_SOLARIS) @@ -181,23 +181,23 @@ static void module_read (void) swap_avail = pagesize * (MAX(ai.ani_max - ai.ani_resv, 0) + (availrmem - swapfs_minfree)); /* swap_free = pagesize * (ai.ani_free + (availrmem - swapfs_minfree)); */ - module_submit (swap_alloc, swap_avail, -1LL, swap_resv - swap_alloc); + swap_submit (swap_alloc, swap_avail, -1LL, swap_resv - swap_alloc); /* #endif defined(KERNEL_SOLARIS) */ #elif defined(HAVE_LIBSTATGRAB) sg_swap_stats *swap; if ((swap = sg_get_swap_stats ()) != NULL) - module_submit (swap->used, swap->free, -1LL, -1LL); + swap_submit (swap->used, swap->free, -1LL, -1LL); #endif /* HAVE_LIBSTATGRAB */ } #else -# define module_read NULL +# define swap_read NULL #endif /* SWAP_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, module_init, module_read, module_write); + plugin_register (MODULE_NAME, swap_init, swap_read, swap_write); } #undef MODULE_NAME diff --git a/src/tape.c b/src/tape.c index c6271de7..0fc8f2c5 100644 --- a/src/tape.c +++ b/src/tape.c @@ -123,7 +123,7 @@ static void tape_submit (char *tape_name, #undef BUFSIZE #if TAPE_HAVE_READ -void tape_read (void) +static void tape_read (void) { #if defined(HAVE_LIBKSTAT) diff --git a/src/traffic.c b/src/traffic.c index ab2c8cc2..d3cea5af 100644 --- a/src/traffic.c +++ b/src/traffic.c @@ -49,7 +49,7 @@ static kstat_t *ksp[MAX_NUMIF]; static int numif = 0; #endif /* HAVE_LIBKSTAT */ -void traffic_init (void) +static void traffic_init (void) { #ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -78,7 +78,7 @@ void traffic_init (void) #endif /* HAVE_LIBKSTAT */ } -void traffic_write (char *host, char *inst, char *val) +static void traffic_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -93,7 +93,7 @@ void traffic_write (char *host, char *inst, char *val) } #define BUFSIZE 512 -void traffic_submit (char *device, +static void traffic_submit (char *device, unsigned long long incoming, unsigned long long outgoing) { @@ -107,7 +107,7 @@ void traffic_submit (char *device, #undef BUFSIZE #if TRAFFIC_HAVE_READ -void traffic_read (void) +static void traffic_read (void) { #ifdef KERNEL_LINUX FILE *fh;