From: octo Date: Sat, 17 Dec 2005 09:39:18 +0000 (+0000) Subject: Changed the cpu plugin to not use its headerfile anymore. X-Git-Tag: collectd-3.6.0~39 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=96cf2ccbed62d1a0557116e02c455fae611614b8;p=collectd.git Changed the cpu plugin to not use its headerfile anymore. Fixed a small bug in configfile.c: `==' -> `=' --- diff --git a/configure.in b/configure.in index e5cf5cb5..46bc8834 100644 --- a/configure.in +++ b/configure.in @@ -444,21 +444,22 @@ AC_COLLECTD([daemon], [disable], [feature], [daemon mode]) 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 - if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$have_sysctlbyname" = "xyes" - then - enable_cpu="yes" - else - enable_cpu="no" - fi -fi -if test "x$enable_cpu" = "xno" -then - AC_DEFINE(COLLECT_CPU, 0, [Wether or not to collect CPU usage statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_CPU, test "x$enable_cpu" = "xyes") +AC_COLLECTD([cpu], [disable], [module], [cpu usage statistics]) +#AC_ARG_ENABLE(cpu, AC_HELP_STRING([--disable-cpu], [Disable CPU usage statistics]),, [enable_cpu="yes"]) +#if test "x$enable_cpu" != "xno" +#then +# if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$have_sysctlbyname" = "xyes" +# then +# enable_cpu="yes" +# else +# enable_cpu="no" +# fi +#fi +#if test "x$enable_cpu" = "xno" +#then +# AC_DEFINE(COLLECT_CPU, 0, [Wether or not to collect 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" diff --git a/src/configfile.c b/src/configfile.c index cbe2de9f..14b9dfbc 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -297,7 +297,7 @@ int cf_callback_section_module (const char *shortvar, const char *var, if (current_module != NULL) { free (current_module); - current_module == NULL; + current_module = NULL; } nesting_depth--; diff --git a/src/cpu.c b/src/cpu.c index 7a9700ae..67db5bcc 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -20,40 +20,36 @@ * Florian octo Forster **/ -#include "cpu.h" - -#if COLLECT_CPU -#define MODULE_NAME "cpu" +#include "collectd.h" +#include "plugin.h" +#include "common.h" #ifdef HAVE_LIBKSTAT -#include +# include #endif /* HAVE_LIBKSTAT */ #ifdef HAVE_SYSCTLBYNAME -#ifdef HAVE_SYS_SYSCTL_H -#include -#endif - -#ifdef HAVE_SYS_DKSTAT_H -#include -#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 -#define CP_SYS 2 -#define CP_INTR 3 -#define CP_IDLE 4 -#define CPUSTATES 5 -#endif +# ifdef HAVE_SYS_SYSCTL_H +# include +# endif + +# ifdef HAVE_SYS_DKSTAT_H +# include +# 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 +# define CP_SYS 2 +# define CP_INTR 3 +# define CP_IDLE 4 +# define CPUSTATES 5 +# endif #endif /* HAVE_SYSCTLBYNAME */ -#include "plugin.h" -#include "common.h" - #ifdef HAVE_LIBKSTAT /* colleague tells me that Sun doesn't sell systems with more than 100 or so CPUs.. */ -#define MAX_NUMCPU 256 +# define MAX_NUMCPU 256 extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMCPU]; static int numcpu; @@ -63,6 +59,8 @@ static int numcpu; static int numcpu; #endif /* HAVE_SYSCTLBYNAME */ +#define MODULE_NAME "cpu" + static char *cpu_filename = "cpu-%s.rrd"; static char *ds_def[] = @@ -127,7 +125,8 @@ void cpu_write (char *host, char *inst, char *val) } #define BUFSIZE 512 -void cpu_submit (int cpu_num, unsigned long long user, unsigned long long nice, unsigned long long syst, +static void cpu_submit (int cpu_num, unsigned long long user, + unsigned long long nice, unsigned long long syst, unsigned long long idle, unsigned long long wait) { char buf[BUFSIZE]; @@ -142,7 +141,7 @@ void cpu_submit (int cpu_num, unsigned long long user, unsigned long long nice, } #undef BUFSIZE -void cpu_read (void) +static void cpu_read (void) { #ifdef KERNEL_LINUX #define BUFSIZE 1024 @@ -240,6 +239,8 @@ void cpu_read (void) /* FIXME: Instance is always `0' */ cpu_submit (0, cpuinfo[CP_USER], cpuinfo[CP_NICE], cpuinfo[CP_SYS], cpuinfo[CP_IDLE], 0LL); #endif + + return; } void module_register (void) @@ -248,4 +249,3 @@ void module_register (void) } #undef MODULE_NAME -#endif /* COLLECT_CPU */