X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcpu.c;h=28e6233808fa0d60e6c3954926cc38fb5a0a2800;hb=a802557560543782e606fa1d90f1b2d7b9c4ee9e;hp=6832b5239a1b9bad95d931b5061636e1fa01118c;hpb=73681054cbff428d352d8ed707d24fab1bf67b24;p=collectd.git diff --git a/src/cpu.c b/src/cpu.c index 6832b523..28e62338 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 */ @@ -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 @@ -71,16 +71,16 @@ static char *cpu_filename = "cpu-%s.rrd"; static char *ds_def[] = { - "DS:user:COUNTER:25:0:100", - "DS:nice:COUNTER:25:0:100", - "DS:syst:COUNTER:25:0:100", - "DS:idle:COUNTER:25:0:100", - "DS:wait:COUNTER:25:0:100", + "DS:user:COUNTER:25:0:U", + "DS:nice:COUNTER:25:0:U", + "DS:syst:COUNTER:25:0:U", + "DS:idle:COUNTER:25:0:U", + "DS:wait:COUNTER:25:0:U", NULL }; 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; @@ -130,6 +130,7 @@ 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 @@ -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