solaris-fixes branch: Applied the swap-patch by Christophe Kalt.
[collectd.git] / src / nfs.c
index 3321630..d0f33c5 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
@@ -1,6 +1,6 @@
 /**
  * collectd - src/nfs.c
- * Copyright (C) 2005  Jason Pepas
+ * Copyright (C) 2005,2006  Jason Pepas
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  *   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) */
+#if KERNEL_LINUX
+# 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";
@@ -79,57 +84,57 @@ Number      Procedures  Procedures
 
 static char *nfs2_procedures_ds_def[] =
 {
-       "DS:null:COUNTER:25:0:U",
-       "DS:getattr:COUNTER:25:0:U",
-       "DS:setattr:COUNTER:25:0:U",
-       "DS:root:COUNTER:25:0:U",
-       "DS:lookup:COUNTER:25:0:U",
-       "DS:readlink:COUNTER:25:0:U",
-       "DS:read:COUNTER:25:0:U",
-       "DS:wrcache:COUNTER:25:0:U",
-       "DS:write:COUNTER:25:0:U",
-       "DS:create:COUNTER:25:0:U",
-       "DS:remove:COUNTER:25:0:U",
-       "DS:rename:COUNTER:25:0:U",
-       "DS:link:COUNTER:25:0:U",
-       "DS:symlink:COUNTER:25:0:U",
-       "DS:mkdir:COUNTER:25:0:U",
-       "DS:rmdir:COUNTER:25:0:U",
-       "DS:readdir:COUNTER:25:0:U",
-       "DS:fsstat:COUNTER:25:0:U",
+       "DS:null:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:getattr:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:setattr:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:root:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:lookup:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:readlink:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:read:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wrcache:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:write:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:create:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:remove:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rename:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:link:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:symlink:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:mkdir:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rmdir:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:readdir:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:fsstat:COUNTER:"COLLECTD_HEARTBEAT":0:U",
        NULL
 };
 static int nfs2_procedures_ds_num = 18;
 
 static char *nfs3_procedures_ds_def[] =
 {
-       "DS:null:COUNTER:25:0:U",
-       "DS:getattr:COUNTER:25:0:U",
-       "DS:setattr:COUNTER:25:0:U",
-       "DS:lookup:COUNTER:25:0:U",
-       "DS:access:COUNTER:25:0:U",
-       "DS:readlink:COUNTER:25:0:U",
-       "DS:read:COUNTER:25:0:U",
-       "DS:write:COUNTER:25:0:U",
-       "DS:create:COUNTER:25:0:U",
-       "DS:mkdir:COUNTER:25:0:U",
-       "DS:symlink:COUNTER:25:0:U",
-       "DS:mknod:COUNTER:25:0:U",
-       "DS:remove:COUNTER:25:0:U",
-       "DS:rmdir:COUNTER:25:0:U",
-       "DS:rename:COUNTER:25:0:U",
-       "DS:link:COUNTER:25:0:U",
-       "DS:readdir:COUNTER:25:0:U",
-       "DS:readdirplus:COUNTER:25:0:U",
-       "DS:fsstat:COUNTER:25:0:U",
-       "DS:fsinfo:COUNTER:25:0:U",
-       "DS:pathconf:COUNTER:25:0:U",
-       "DS:commit:COUNTER:25:0:U",
+       "DS:null:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:getattr:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:setattr:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:lookup:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:access:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:readlink:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:read:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:write:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:create:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:mkdir:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:symlink:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:mknod:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:remove:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rmdir:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rename:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:link:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:readdir:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:readdirplus:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:fsstat:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:fsinfo:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:pathconf:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:commit:COUNTER:"COLLECTD_HEARTBEAT":0:U",
        NULL
 };
 static int nfs3_procedures_ds_num = 22;
 
-#ifdef HAVE_LIBKSTAT
+#if HAVE_LIBKSTAT && 0
 extern kstat_ctl_t *kc;
 static kstat_t *nfs2_ksp_client;
 static kstat_t *nfs2_ksp_server;
@@ -141,9 +146,9 @@ static kstat_t *nfs4_ksp_server;
 
 /* Possibly TODO: NFSv4 statistics */
 
-void nfs_init (void)
+static void nfs_init (void)
 {
-#ifdef HAVE_LIBKSTAT
+#if HAVE_LIBKSTAT && 0
        kstat_t *ksp_chain;
 
        nfs2_ksp_client = NULL;
@@ -180,7 +185,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 +196,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 +207,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 +233,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 +257,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)
+#if KERNEL_LINUX
+static void nfs_read_stats_file (FILE *fh, char *inst)
 {
        char buffer[BUFSIZE];
 
@@ -323,8 +330,8 @@ void nfs_read_stats_file (FILE *fh, char *inst)
 #endif /* defined(KERNEL_LINUX) */
 #undef BUFSIZE
 
-#ifdef HAVE_LIBKSTAT
-void nfs2_read_kstat (kstat_t *ksp, char *inst)
+#if HAVE_LIBKSTAT && 0
+static void nfs2_read_kstat (kstat_t *ksp, char *inst)
 {
        unsigned long long values[18];
 
@@ -351,9 +358,10 @@ 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)
+#if KERNEL_LINUX
        FILE *fh;
 
        if ((fh = fopen ("/proc/net/rpc/nfs", "r")) != NULL)
@@ -370,20 +378,22 @@ void nfs_read (void)
 
 /* #endif defined(KERNEL_LINUX) */
 
-#elif defined(HAVE_LIBKSTAT)
+#elif HAVE_LIBKSTAT && 0
        if (nfs2_ksp_client != NULL)
                nfs2_read_kstat (nfs2_ksp_client, "client");
        if (nfs2_ksp_server != NULL)
                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 */