Fixes syntax and compile errors in src/apache.c
[collectd.git] / src / nfs.c
index 3321630..1592c91 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
  *   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";
@@ -141,7 +145,7 @@ static kstat_t *nfs4_ksp_server;
 
 /* Possibly TODO: NFSv4 statistics */
 
-void nfs_init (void)
+static void nfs_init (void)
 {
 #ifdef HAVE_LIBKSTAT
        kstat_t *ksp_chain;
@@ -180,7 +184,7 @@ void nfs_init (void)
 }
 
 #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];
 
@@ -191,7 +195,7 @@ void nfs2_procedures_write (char *host, char *inst, char *val)
                        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];
 
@@ -202,7 +206,8 @@ void nfs3_procedures_write (char *host, char *inst, char *val)
                        nfs3_procedures_ds_num);
 }
 
-void nfs2_procedures_submit (unsigned long long *val, char *inst)
+#if NFS_HAVE_READ
+static void nfs2_procedures_submit (unsigned long long *val, char *inst)
 {
        char buf[BUFSIZE];
        int retval = 0;
@@ -227,7 +232,7 @@ void nfs2_procedures_submit (unsigned long long *val, char *inst)
        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;
@@ -251,9 +256,10 @@ void nfs3_procedures_submit (unsigned long long *val, char *inst)
 
        plugin_submit("nfs3_procedures", inst, buf);
 }
+#endif /* NFS_HAVE_READ */
 
 #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];
 
@@ -324,7 +330,7 @@ void nfs_read_stats_file (FILE *fh, char *inst)
 #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];
 
@@ -351,7 +357,8 @@ void nfs2_read_kstat (kstat_t *ksp, char *inst)
 }
 #endif
 
-void nfs_read (void)
+#if NFS_HAVE_READ
+static void nfs_read (void)
 {
 #if defined(KERNEL_LINUX)
        FILE *fh;
@@ -377,13 +384,15 @@ void nfs_read (void)
                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, 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, nfs_read, 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 */