From: octo Date: Sat, 17 Dec 2005 11:26:00 +0000 (+0000) Subject: Changed plugins `serial' through `users' to be able to build in read-only mode X-Git-Tag: collectd-3.6.0~37 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=89ef5df52d495315cd26b8e3467153b93b2c2742;p=collectd.git Changed plugins `serial' through `users' to be able to build in read-only mode --- diff --git a/src/Makefile.am b/src/Makefile.am index 3252aec3..92402395 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -141,6 +141,7 @@ if BUILD_MODULE_SERIAL pkglib_LTLIBRARIES += serial.la serial_la_SOURCES = serial.c serial.h serial_la_LDFLAGS = -module -avoid-version +serial_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" serial.la collectd_DEPENDENCIES += serial.la endif @@ -149,6 +150,7 @@ if BUILD_MODULE_SWAP pkglib_LTLIBRARIES += swap.la swap_la_SOURCES = swap.c swap.h swap_la_LDFLAGS = -module -avoid-version +swap_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" swap.la collectd_DEPENDENCIES += swap.la endif @@ -157,6 +159,7 @@ if BUILD_MODULE_TAPE pkglib_LTLIBRARIES += tape.la tape_la_SOURCES = tape.c tape.h tape_la_LDFLAGS = -module -avoid-version +tape_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" tape.la collectd_DEPENDENCIES += tape.la endif @@ -165,6 +168,7 @@ if BUILD_MODULE_TRAFFIC pkglib_LTLIBRARIES += traffic.la traffic_la_SOURCES = traffic.c traffic.h traffic_la_LDFLAGS = -module -avoid-version +traffic_la_CFLAGS = -Wall -Werror collectd_LDADD += "-dlopen" traffic.la collectd_DEPENDENCIES += traffic.la endif diff --git a/src/serial.c b/src/serial.c index 78210300..20a51e70 100644 --- a/src/serial.c +++ b/src/serial.c @@ -21,13 +21,17 @@ * Florian octo Forster **/ -#include "serial.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_SERIAL #define MODULE_NAME "serial" -#include "plugin.h" -#include "common.h" +#if defined(KERNEL_LINUX) +# define SERIAL_HAVE_READ 1 +#else +# define SERIAL_HAVE_READ 0 +#endif static char *serial_filename_template = "serial-%s.rrd"; @@ -39,11 +43,12 @@ static char *ds_def[] = }; static int ds_num = 2; -void serial_init (void) +static void serial_init (void) { + return; } -void serial_write (char *host, char *inst, char *val) +static void serial_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -58,7 +63,7 @@ void serial_write (char *host, char *inst, char *val) } #define BUFSIZE 512 -void serial_submit (char *device, +static void serial_submit (char *device, unsigned long long incoming, unsigned long long outgoing) { @@ -72,7 +77,8 @@ void serial_submit (char *device, } #undef BUFSIZE -void serial_read (void) +#if SERIAL_HAVE_READ +static void serial_read (void) { #ifdef KERNEL_LINUX @@ -96,6 +102,13 @@ void serial_read (void) { int have_rx = 0, have_tx = 0; + /* stupid compiler: + * serial.c:87: warning: 'incoming' may be used uninitialized in this function + * serial.c:87: warning: 'outgoing' may be used uninitialized in this function + */ + incoming = 0ULL; + outgoing = 0ULL; + numfields = strsplit (buffer, fields, 16); if (numfields < 6) @@ -139,11 +152,17 @@ void serial_read (void) fclose (fh); #endif /* KERNEL_LINUX */ } +#endif /* SERIAL_HAVE_READ */ void module_register (void) { - plugin_register (MODULE_NAME, serial_init, serial_read, serial_write); + plugin_register (MODULE_NAME, serial_init, +#if SERIAL_HAVE_READ + serial_read, +#else + NULL, +#endif + serial_write); } #undef MODULE_NAME -#endif /* COLLECT_SERIAL */ diff --git a/src/swap.c b/src/swap.c index c3e399d8..eb476a42 100644 --- a/src/swap.c +++ b/src/swap.c @@ -20,18 +20,22 @@ * Florian octo Forster **/ -#include "swap.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_SWAP #define MODULE_NAME "swap" +#if defined(KERNEL_LINUX) || defined(KERNEL_SOLARIS) || defined(HAVE_LIBSTATGRAB) +# define SWAP_HAVE_READ 1 +#else +# define SWAP_HAVE_READ 0 +#endif + #ifdef KERNEL_SOLARIS #include #endif /* KERNEL_SOLARIS */ -#include "plugin.h" -#include "common.h" - #undef MAX #define MAX(x,y) ((x) > (y) ? (x) : (y)) @@ -53,7 +57,7 @@ static int pagesize; static kstat_t *ksp; #endif /* KERNEL_SOLARIS */ -void module_init (void) +static void module_init (void) { #ifdef KERNEL_SOLARIS /* getpagesize(3C) tells me this does not fail.. */ @@ -65,12 +69,12 @@ void module_init (void) return; } -void module_write (char *host, char *inst, char *val) +static void module_write (char *host, char *inst, char *val) { rrd_update_file (host, swap_file, val, ds_def, ds_num); } -void module_submit (unsigned long long swap_used, +static void module_submit (unsigned long long swap_used, unsigned long long swap_free, unsigned long long swap_cached, unsigned long long swap_resv) @@ -84,7 +88,8 @@ void module_submit (unsigned long long swap_used, plugin_submit (MODULE_NAME, "-", buffer); } -void module_read (void) +#if SWAP_HAVE_READ +static void module_read (void) { #ifdef KERNEL_LINUX FILE *fh; @@ -186,6 +191,9 @@ void module_read (void) module_submit (swap->used, swap->free, -1LL, -1LL); #endif /* HAVE_LIBSTATGRAB */ } +#else +# define module_read NULL +#endif /* SWAP_HAVE_READ */ void module_register (void) { @@ -193,4 +201,3 @@ void module_register (void) } #undef MODULE_NAME -#endif /* COLLECT_SWAP */ diff --git a/src/tape.c b/src/tape.c index 3697c633..c6271de7 100644 --- a/src/tape.c +++ b/src/tape.c @@ -20,20 +20,17 @@ * Scott Garrett **/ -#include "tape.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_TAPE #define MODULE_NAME "tape" -#include "plugin.h" -#include "common.h" - #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 */ +# define TAPE_HAVE_READ 1 +#else +# define TAPE_HAVE_READ 0 +#endif static char *tape_filename_template = "tape-%s.rrd"; @@ -52,7 +49,14 @@ static char *tape_ds_def[] = }; static int tape_ds_num = 8; -void tape_init (void) +#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 void tape_init (void) { #ifdef HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -77,7 +81,7 @@ void tape_init (void) return; } -void tape_write (char *host, char *inst, char *val) +static void tape_write (char *host, char *inst, char *val) { char file[512]; int status; @@ -93,7 +97,7 @@ void tape_write (char *host, char *inst, char *val) #define BUFSIZE 512 -void tape_submit (char *tape_name, +static void tape_submit (char *tape_name, unsigned long long read_count, unsigned long long read_merged, unsigned long long read_bytes, @@ -118,6 +122,7 @@ void tape_submit (char *tape_name, #undef BUFSIZE +#if TAPE_HAVE_READ void tape_read (void) { @@ -140,6 +145,9 @@ void tape_read (void) } #endif /* defined(HAVE_LIBKSTAT) */ } +#else +# define tape_read NULL +#endif /* TAPE_HAVE_READ */ void module_register (void) { @@ -147,4 +155,3 @@ void module_register (void) } #undef MODULE_NAME -#endif /* COLLECT_TAPE */ diff --git a/src/traffic.c b/src/traffic.c index 5a276a82..ab2c8cc2 100644 --- a/src/traffic.c +++ b/src/traffic.c @@ -20,20 +20,17 @@ * Florian octo Forster **/ -#include "traffic.h" +#include "collectd.h" +#include "common.h" +#include "plugin.h" -#if COLLECT_TRAFFIC #define MODULE_NAME "traffic" -#include "plugin.h" -#include "common.h" - -#ifdef HAVE_LIBKSTAT -#define MAX_NUMIF 256 -extern kstat_ctl_t *kc; -static kstat_t *ksp[MAX_NUMIF]; -static int numif = 0; -#endif /* HAVE_LIBKSTAT */ +#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) || defined(HAVE_LIBSTATGRAB) +# define TRAFFIC_HAVE_READ 1 +#else +# define TRAFFIC_HAVE_READ 0 +#endif static char *traffic_filename_template = "traffic-%s.rrd"; @@ -45,6 +42,13 @@ static char *ds_def[] = }; static int ds_num = 2; +#ifdef HAVE_LIBKSTAT +#define MAX_NUMIF 256 +extern kstat_ctl_t *kc; +static kstat_t *ksp[MAX_NUMIF]; +static int numif = 0; +#endif /* HAVE_LIBKSTAT */ + void traffic_init (void) { #ifdef HAVE_LIBKSTAT @@ -102,6 +106,7 @@ void traffic_submit (char *device, } #undef BUFSIZE +#if TRAFFIC_HAVE_READ void traffic_read (void) { #ifdef KERNEL_LINUX @@ -179,6 +184,9 @@ void traffic_read (void) traffic_submit (ios[i].interface_name, ios[i].rx, ios[i].tx); #endif /* HAVE_LIBSTATGRAB */ } +#else +#define traffic_read NULL +#endif /* TRAFFIC_HAVE_READ */ void module_register (void) { @@ -186,4 +194,3 @@ void module_register (void) } #undef MODULE_NAME -#endif /* COLLECT_TRAFFIC */ diff --git a/src/users.c b/src/users.c index 2739c2be..e2b741c9 100644 --- a/src/users.c +++ b/src/users.c @@ -20,9 +20,9 @@ * Sebastian Harl **/ +#include "collectd.h" #include "common.h" #include "plugin.h" -#include "users.h" #if HAVE_UTMPX_H # include @@ -34,6 +34,12 @@ #define MODULE_NAME "users" +#if HAVE_GETUTXENT || HAVE_GETUTENT +# define USERS_HAVE_READ 1 +#else +# define USERS_HAVE_READ 0 +#endif + static char *rrd_file = "users.rrd"; static char *ds_def[] = { @@ -72,6 +78,7 @@ 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 @@ -112,6 +119,9 @@ static void users_read (void) return; } /* static void users_read(void) */ +#else +# define users_read NULL +#endif /* USERS_HAVE_READ */ void module_register (void) {