pkglib_LTLIBRARIES += cpu.la
cpu_la_SOURCES = cpu.c cpu.h
cpu_la_LDFLAGS = -module -avoid-version
+cpu_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" cpu.la
collectd_DEPENDENCIES += cpu.la
endif
pkglib_LTLIBRARIES += cpufreq.la
cpufreq_la_SOURCES = cpufreq.c cpufreq.h
cpufreq_la_LDFLAGS = -module -avoid-version
+cpufreq_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" cpufreq.la
collectd_DEPENDENCIES += cpufreq.la
endif
pkglib_LTLIBRARIES += disk.la
disk_la_SOURCES = disk.c disk.h
disk_la_LDFLAGS = -module -avoid-version
+disk_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" disk.la
collectd_DEPENDENCIES += disk.la
endif
pkglib_LTLIBRARIES += hddtemp.la
hddtemp_la_SOURCES = hddtemp.c hddtemp.h
hddtemp_la_LDFLAGS = -module -avoid-version
+hddtemp_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" hddtemp.la
collectd_DEPENDENCIES += hddtemp.la
endif
pkglib_LTLIBRARIES += load.la
load_la_SOURCES = load.c load.h
load_la_LDFLAGS = -module -avoid-version
+load_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" load.la
collectd_DEPENDENCIES += load.la
endif
pkglib_LTLIBRARIES += memory.la
memory_la_SOURCES = memory.c memory.h
memory_la_LDFLAGS = -module -avoid-version
+memory_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" memory.la
collectd_DEPENDENCIES += memory.la
endif
pkglib_LTLIBRARIES += nfs.la
nfs_la_SOURCES = nfs.c nfs.h
nfs_la_LDFLAGS = -module -avoid-version
+nfs_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" nfs.la
collectd_DEPENDENCIES += nfs.la
endif
ping_la_LDFLAGS = -module -avoid-version
ping_la_LIBADD = libping/libping.la
ping_la_DEPENDENCIES = libping/libping.la
+ping_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" ping.la
collectd_DEPENDENCIES += ping.la
endif
pkglib_LTLIBRARIES += processes.la
processes_la_SOURCES = processes.c processes.h
processes_la_LDFLAGS = -module -avoid-version
+processes_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" processes.la
collectd_DEPENDENCIES += processes.la
endif
if BUILD_MODULE_SENSORS
pkglib_LTLIBRARIES += sensors.la
sensors_la_SOURCES = sensors.c sensors.h
-sensors_la_LDFLAGS = -module -avoid-version -lsensors
+sensors_la_LDFLAGS = -module -avoid-version
+if BUILD_WITH_LM_SENSORS
+sensors_la_LDFLAGS += -lsensors
+endif
sensors_la_LIBADD = -lsensors
+sensors_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" sensors.la
collectd_DEPENDENCIES += sensors.la
endif
**/
#include "collectd.h"
-#include "plugin.h"
#include "common.h"
+#include "plugin.h"
+
+#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 <sys/sysinfo.h>
static int numcpu;
#endif /* HAVE_SYSCTLBYNAME */
-#define MODULE_NAME "cpu"
-
static char *cpu_filename = "cpu-%s.rrd";
static char *ds_def[] =
}
#undef BUFSIZE
+#if CPU_HAVE_READ
static void cpu_read (void)
{
#ifdef KERNEL_LINUX
}
/* #endif defined(HAVE_LIBKSTAT) */
-#elif defined (HAVE_SYSCTLBYNAME)
+#elif defined(HAVE_SYSCTLBYNAME)
long cpuinfo[CPUSTATES];
size_t cpuinfo_size;
return;
}
+#endif /* CPU_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, cpu_init, cpu_read, cpu_write);
+ plugin_register (MODULE_NAME, cpu_init,
+#if CPU_HAVE_READ
+ cpu_read,
+#else
+ NULL,
+#endif
+ cpu_write);
}
#undef MODULE_NAME
* Peter Holik <peter at holik.at>
**/
-#include "cpufreq.h"
-
-/*
- * Originally written by Peter Holik
- */
-
-#if COLLECT_CPUFREQ
-#define MODULE_NAME "cpufreq"
-
-#include "plugin.h"
+#include "collectd.h"
#include "common.h"
+#include "plugin.h"
-static int num_cpu = 0;
+#define MODULE_NAME "cpufreq"
static char *cpufreq_file = "cpufreq-%s.rrd";
};
static int ds_num = 1;
+#ifdef KERNEL_LINUX
+static int num_cpu = 0;
+#endif
+
#define BUFSIZE 256
-void cpufreq_init (void)
+static void cpufreq_init (void)
{
+#ifdef KERNEL_LINUX
int status;
char filename[BUFSIZE];
}
syslog (LOG_INFO, MODULE_NAME" found %d cpu(s)", num_cpu);
+#endif /* defined(KERNEL_LINUX) */
+
+ return;
}
-void cpufreq_write (char *host, char *inst, char *val)
+static void cpufreq_write (char *host, char *inst, char *val)
{
int status;
char file[BUFSIZE];
rrd_update_file (host, file, val, ds_def, ds_num);
}
-void cpufreq_submit (int cpu_num, unsigned long long val)
+static void cpufreq_submit (int cpu_num, unsigned long long val)
{
char buf[BUFSIZE];
char cpu[16];
plugin_submit (MODULE_NAME, cpu, buf);
}
-void cpufreq_read (void)
+static void cpufreq_read (void)
{
+#ifdef KERNEL_LINUX
int status;
unsigned long long val;
int i = 0;
cpufreq_submit (i, val);
}
+#endif /* defined(KERNEL_LINUX) */
+
+ return;
}
#undef BUFSIZE
}
#undef MODULE_NAME
-#endif /* COLLECT_CPUFREQ */
* Florian octo Forster <octo at verplant.org>
**/
-#include "disk.h"
-
-#if COLLECT_DISK
-#define MODULE_NAME "disk"
-
-#include "plugin.h"
+#include "collectd.h"
#include "common.h"
+#include "plugin.h"
-#ifdef KERNEL_LINUX
-typedef struct diskstats
-{
- char *name;
-
- unsigned int read_sectors;
- unsigned int write_sectors;
-
- unsigned long long read_bytes;
- unsigned long long write_bytes;
-
- struct diskstats *next;
-} diskstats_t;
-
-static diskstats_t *disklist;
-/* KERNEL_LINUX */
+#define MODULE_NAME "disk"
-#elif defined(HAVE_LIBKSTAT)
-#define MAX_NUMDISK 256
-extern kstat_ctl_t *kc;
-static kstat_t *ksp[MAX_NUMDISK];
-static int numdisk = 0;
-#endif /* HAVE_LIBKSTAT */
+#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT)
+# define DISK_HAVE_READ 1
+#else
+# define DISK_HAVE_READ 0
+#endif
static char *disk_filename_template = "disk-%s.rrd";
static char *part_filename_template = "partition-%s.rrd";
};
static int part_ds_num = 4;
-void disk_init (void)
+#ifdef KERNEL_LINUX
+typedef struct diskstats
+{
+ char *name;
+
+ unsigned int read_sectors;
+ unsigned int write_sectors;
+
+ unsigned long long read_bytes;
+ unsigned long long write_bytes;
+
+ struct diskstats *next;
+} diskstats_t;
+
+static diskstats_t *disklist;
+/* #endif defined(KERNEL_LINUX) */
+
+#elif defined(HAVE_LIBKSTAT)
+#define MAX_NUMDISK 256
+extern kstat_ctl_t *kc;
+static kstat_t *ksp[MAX_NUMDISK];
+static int numdisk = 0;
+#endif /* HAVE_LIBKSTAT */
+
+static void disk_init (void)
{
#ifdef HAVE_LIBKSTAT
kstat_t *ksp_chain;
return;
}
-void disk_write (char *host, char *inst, char *val)
+static void disk_write (char *host, char *inst, char *val)
{
char file[512];
int status;
rrd_update_file (host, file, val, disk_ds_def, disk_ds_num);
}
-void partition_write (char *host, char *inst, char *val)
+static void partition_write (char *host, char *inst, char *val)
{
char file[512];
int status;
}
#define BUFSIZE 512
-void disk_submit (char *disk_name,
+static void disk_submit (char *disk_name,
unsigned long long read_count,
unsigned long long read_merged,
unsigned long long read_bytes,
plugin_submit (MODULE_NAME, disk_name, buf);
}
-void partition_submit (char *part_name,
+static void partition_submit (char *part_name,
unsigned long long read_count,
unsigned long long read_bytes,
unsigned long long write_count,
}
#undef BUFSIZE
-void disk_read (void)
+#if DISK_HAVE_READ
+static void disk_read (void)
{
#ifdef KERNEL_LINUX
FILE *fh;
kio.writes,kio.nwritten);
}
#endif /* defined(HAVE_LIBKSTAT) */
-}
+} /* static void disk_read (void) */
+#endif /* DISK_HAVE_READ */
void module_register (void)
{
plugin_register ("partition", NULL, NULL, partition_write);
- plugin_register (MODULE_NAME, disk_init, disk_read, disk_write);
+ plugin_register (MODULE_NAME, disk_init,
+#if DISK_HAVE_READ
+ disk_read,
+#else
+ NULL,
+#endif
+ disk_write);
}
#undef MODULE_NAME
-#endif /* COLLECT_DISK */
* Florian octo Forster <octo at verplant.org>
**/
-#include "hddtemp.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_HDDTEMP
#define MODULE_NAME "hddtemp"
-#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <string.h>
-#include <errno.h>
-#include <syslog.h>
-#include <stdlib.h>
-#include <string.h>
#include <libgen.h> /* for basename */
-#include "plugin.h"
-#include "common.h"
-
/* LOCALHOST_ADDR
The ip address 127.0.0.1, as a 32 bit. */
#define LOCALHOST_ADDR 0x7F000001
static hddname_t *first_hddname = NULL;
-/* hddtemp_query_daemon
- Connect to the hddtemp daemon and receive data.
-
- Parameters:
- buffer: the buffer where we put the received ascii string.
- buffer_size: size of the buffer
-
- Return value:
- >= 0 if ok, < 0 otherwise.
-
- Example of possible strings, as received from daemon:
-
- |/dev/hda|ST340014A|36|C|
- |/dev/hda|ST380011A|46|C||/dev/hdd|ST340016A|SLP|*|
-
- FIXME: we need to create a new socket each time. Is there another way? */
-
+/*
+ * NAME
+ * hddtemp_query_daemon
+ *
+ * DESCRIPTION
+ * Connect to the hddtemp daemon and receive data.
+ *
+ * ARGUMENTS:
+ * `buffer' The buffer where we put the received ascii string.
+ * `buffer_size' Size of the buffer
+ *
+ * RETURN VALUE:
+ * >= 0 if ok, < 0 otherwise.
+ *
+ * NOTES:
+ * Example of possible strings, as received from daemon:
+ * |/dev/hda|ST340014A|36|C|
+ * |/dev/hda|ST380011A|46|C||/dev/hdd|ST340016A|SLP|*|
+ *
+ * FIXME:
+ * we need to create a new socket each time. Is there another way?
+ */
static int hddtemp_query_daemon (char *buffer, int buffer_size)
{
int sock;
{
plugin_register (MODULE_NAME, hddtemp_init, hddtemp_read, hddtemp_write);
}
-
-#endif /* COLLECT_HDDTEMP */
* Florian octo Forster <octo at verplant.org>
**/
-#include "load.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_LOAD
#define MODULE_NAME "load"
-#include "plugin.h"
-#include "common.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 <sys/loadavg.h>
}
#undef BUFSIZE
+#if LOAD_HAVE_READ
void load_read (void)
{
#if defined(HAVE_GETLOADAVG)
load_submit (snum, mnum, lnum);
#endif /* HAVE_LIBSTATGRAB */
}
+#endif /* LOAD_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, load_init, load_read, load_write);
+ plugin_register (MODULE_NAME, load_init,
+#if LOAD_HAVE_READ
+ load_read,
+#else
+ NULL,
+#endif
+ load_write);
}
#undef MODULE_NAME
-#endif /* COLLECT_LOAD */
* Florian octo Forster <octo at verplant.org>
**/
-#include "memory.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_MEMORY
-#define MODULE_NAME "memory"
+#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT)
+# define MEMORY_HAVE_READ 1
+#else
+# define MEMORY_HAVE_READ 0
+#endif
-#include "plugin.h"
-#include "common.h"
+#define MODULE_NAME "memory"
static char *memory_file = "memory.rrd";
}
#undef BUFSIZE
+#if MEMORY_HAVE_READ
void memory_read (void)
{
#ifdef KERNEL_LINUX
memory_submit (ios->used, 0LL, ios->cache, ios->free);
#endif /* HAVE_LIBSTATGRAB */
}
+#endif /* MEMORY_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, memory_init, memory_read, memory_write);
+ plugin_register (MODULE_NAME, memory_init,
+#if MEMORY_HAVE_READ
+ memory_read,
+#else
+ NULL,
+#endif
+ memory_write);
}
#undef MODULE_NAME
-#endif /* COLLECT_MEMORY */
* Florian octo Forster <octo at verplant.org>
**/
-#include "nfs.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_NFS
#define MODULE_NAME "nfs"
-#include "plugin.h"
-#include "common.h"
+#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT)
+# define NFS_HAVE_READ 1
+#else
+# define NFS_HAVE_READ 0
+#endif
static char *nfs2_procedures_file = "nfs2_procedures-%s.rrd";
static char *nfs3_procedures_file = "nfs3_procedures-%s.rrd";
}
#endif
+#if NFS_HAVE_READ
void nfs_read (void)
{
#if defined(KERNEL_LINUX)
nfs2_read_kstat (nfs2_ksp_server, "server");
#endif /* defined(HAVE_LIBKSTAT) */
}
+#endif /* NFS_HAVE_READ */
void module_register (void)
{
- 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);
+ plugin_register (MODULE_NAME, nfs_init,
+#if NFS_HAVE_READ
+ nfs_read,
+#else
+ NULL,
+#endif
+ NULL);
+ plugin_register ("nfs2_procedures", NULL, NULL, nfs2_procedures_write);
+ plugin_register ("nfs3_procedures", NULL, NULL, nfs3_procedures_write);
}
#undef MODULE_NAME
-#endif /* COLLECT_LOAD */
* Florian octo Forster <octo at verplant.org>
**/
-#include "ping.h"
-
-#if COLLECT_PING
-#define MODULE_NAME "ping"
-
-#include "plugin.h"
+#include "collectd.h"
#include "common.h"
+#include "plugin.h"
#include "configfile.h"
+#define MODULE_NAME "ping"
+
#include <netinet/in.h>
#include "libping/ping.h"
+#define MAX_PINGHOSTS 32
+
extern char *pinghosts[MAX_PINGHOSTS];
extern int num_pinghosts;
static int pingerrors[MAX_PINGHOSTS];
}
#undef MODULE_NAME
-#endif /* COLLECT_PING */
* Florian octo Forster <octo at verplant.org>
**/
-#include "processes.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_PROCESSES
#define MODULE_NAME "processes"
-#include "common.h"
-#include "plugin.h"
+#ifdef KERNEL_LINUX
+# define PROCESSES_HAVE_READ 1
+#else
+# define PROCESSES_HAVE_READ 0
+#endif
static char *ps_file = "processes.rrd";
plugin_submit (MODULE_NAME, "-", buf);
}
+#if PROCESSES_HAVE_READ
void ps_read (void)
{
#ifdef KERNEL_LINUX
ps_submit (running, sleeping, zombies, stopped, paging, blocked);
#endif /* defined(KERNEL_LINUX) */
}
+#endif /* PROCESSES_HAVE_READ */
#undef BUFSIZE
void module_register (void)
{
- plugin_register (MODULE_NAME, ps_init, ps_read, ps_write);
+ plugin_register (MODULE_NAME, ps_init,
+#if PROCESSES_HAVE_READ
+ ps_read,
+#else
+ NULL,
+#endif
+ ps_write);
}
#undef MODULE_NAME
-#endif /* COLLECT_PROCESSES */
* Florian octo Forster <octo at verplant.org>
**/
-#include "sensors.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_SENSORS
#define MODULE_NAME "sensors"
-#include <sensors/sensors.h>
-
-#include "plugin.h"
-#include "common.h"
-
-typedef struct featurelist
-{
- const sensors_chip_name *chip;
- const sensors_feature_data *data;
- struct featurelist *next;
-} featurelist_t;
+#if defined(HAVE_SENSORS_SENSORS_H)
+# include <sensors/sensors.h>
+#else
+# undef HAVE_LIBSENSORS
+#endif
-featurelist_t *first_feature = NULL;
+#if defined(HAVE_LIBSENSORS)
+# define SENSORS_HAVE_READ 1
+#else
+# define SENSORS_HAVE_READ 0
+#endif
static char *filename_format = "sensors-%s.rrd";
};
static int ds_num = 1;
-void collectd_sensors_init (void)
+#ifdef HAVE_LIBSENSORS
+typedef struct featurelist
+{
+ const sensors_chip_name *chip;
+ const sensors_feature_data *data;
+ struct featurelist *next;
+} featurelist_t;
+
+featurelist_t *first_feature = NULL;
+#endif /* defined (HAVE_LIBSENSORS) */
+
+static void collectd_sensors_init (void)
{
+#ifdef HAVE_LIBSENSORS
FILE *fh;
featurelist_t *last_feature = NULL;
featurelist_t *new_feature;
if (first_feature == NULL)
sensors_cleanup ();
+#endif /* defined(HAVE_LIBSENSORS) */
+
+ return;
}
-void sensors_write (char *host, char *inst, char *val)
+#define BUFSIZE 512
+static void sensors_write (char *host, char *inst, char *val)
{
- char file[512];
+ char file[BUFSIZE];
int status;
- status = snprintf (file, 512, filename_format, inst);
+ status = snprintf (file, BUFSIZE, filename_format, inst);
if (status < 1)
return;
- else if (status >= 512)
+ else if (status >= BUFSIZE)
return;
rrd_update_file (host, file, val, ds_def, ds_num);
}
-#define BUFSIZE 512
-void sensors_submit (const char *feat_name, const char *chip_prefix, double value)
+static void sensors_submit (const char *feat_name, const char *chip_prefix, double value)
{
char buf[BUFSIZE];
char inst[BUFSIZE];
}
#undef BUFSIZE
-void sensors_read (void)
+#if SENSORS_HAVE_READ
+static void sensors_read (void)
{
featurelist_t *feature;
double value;
sensors_submit (feature->data->name, feature->chip->prefix, value);
}
}
+#endif /* SENSORS_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, collectd_sensors_init, sensors_read,
+ plugin_register (MODULE_NAME, collectd_sensors_init,
+#if SENSORS_HAVE_READ
+ sensors_read,
+#else
+ NULL,
+#endif
sensors_write);
}
#undef MODULE_NAME
-#endif /* COLLECT_SENSORS */