#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>
#endif /* HAVE_LIBKSTAT */
# include <sys/dkstat.h>
# 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
};
static int ds_num = 5;
-void cpu_init (void)
+static void cpu_init (void)
{
#ifdef HAVE_LIBKSTAT
kstat_t *ksp_chain;
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;
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
#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[] =
plugin_submit (MODULE_NAME, cpu, buf);
}
+#if CPUFREQ_HAVE_READ
static void cpufreq_read (void)
{
#ifdef KERNEL_LINUX
return;
}
+#else
+#define cpufreq_read NULL
+#endif
#undef BUFSIZE
void module_register (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
{
plugin_register (MODULE_NAME, hddtemp_init, hddtemp_read, hddtemp_write);
}
+
+#undef MODULE_NAME
};
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];
#undef BUFSIZE
#if LOAD_HAVE_READ
-void load_read (void)
+static void load_read (void)
{
#if defined(HAVE_GETLOADAVG)
double load[3];
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
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.. */
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];
#undef BUFSIZE
#if MEMORY_HAVE_READ
-void memory_read (void)
+static void memory_read (void)
{
#ifdef KERNEL_LINUX
FILE *fh;
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
/* Possibly TODO: NFSv4 statistics */
-void nfs_init (void)
+static void nfs_init (void)
{
#ifdef HAVE_LIBKSTAT
kstat_t *ksp_chain;
}
#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];
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];
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;
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;
}
#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];
#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];
#endif
#if NFS_HAVE_READ
-void nfs_read (void)
+static void nfs_read (void)
{
#if defined(KERNEL_LINUX)
FILE *fh;
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);
}
};
static int config_keys_num = 1;
-void ping_init (void)
+static void ping_init (void)
{
int i;
return;
}
-int ping_config (char *key, char *value)
+static int ping_config (char *key, char *value)
{
if (strcasecmp (key, "host"))
{
}
}
-void ping_write (char *host, char *inst, char *val)
+static void ping_write (char *host, char *inst, char *val)
{
char file[512];
int status;
}
#define BUFSIZE 256
-void ping_submit (int ping_time, char *host)
+static void ping_submit (int ping_time, char *host)
{
char buf[BUFSIZE];
}
#undef BUFSIZE
-void ping_read (void)
+static void ping_read (void)
{
int ping;
int i;
};
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,
}
#if PROCESSES_HAVE_READ
-void ps_read (void)
+static void ps_read (void)
{
#ifdef KERNEL_LINUX
unsigned int running, sleeping, zombies, stopped, paging, blocked;
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
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
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
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.. */
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)
}
#if SWAP_HAVE_READ
-static void module_read (void)
+static void swap_read (void)
{
#ifdef KERNEL_LINUX
FILE *fh;
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)
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
#undef BUFSIZE
#if TAPE_HAVE_READ
-void tape_read (void)
+static void tape_read (void)
{
#if defined(HAVE_LIBKSTAT)
static int numif = 0;
#endif /* HAVE_LIBKSTAT */
-void traffic_init (void)
+static void traffic_init (void)
{
#ifdef HAVE_LIBKSTAT
kstat_t *ksp_chain;
#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;
}
#define BUFSIZE 512
-void traffic_submit (char *device,
+static void traffic_submit (char *device,
unsigned long long incoming,
unsigned long long outgoing)
{
#undef BUFSIZE
#if TRAFFIC_HAVE_READ
-void traffic_read (void)
+static void traffic_read (void)
{
#ifdef KERNEL_LINUX
FILE *fh;