solaris-fixes branch: Applied the swap-patch by Christophe Kalt.
[collectd.git] / src / tape.c
index 3697c63..b13cdbd 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/tape.c
- * Copyright (C) 2005  Scott Garrett
+ * Copyright (C) 2005,2006  Scott Garrett
  *
  * 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
  *   Scott Garrett <sgarrett at technomancer.com>
  **/
 
-#include "tape.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
 
-#if COLLECT_TAPE
 #define MODULE_NAME "tape"
 
-#include "plugin.h"
-#include "common.h"
-
 #if defined(HAVE_LIBKSTAT)
-#define MAX_NUMTAPE 256
-extern kstat_ctl_t *kc;
-static kstat_t *ksp[MAX_NUMTAPE];
-static int numtape = 0;
-#endif /* HAVE_LIBKSTAT */
+# define TAPE_HAVE_READ 1
+#else
+# define TAPE_HAVE_READ 0
+#endif
 
 static char *tape_filename_template = "tape-%s.rrd";
 
 /* 104857600 == 100 MB */
 static char *tape_ds_def[] =
 {
-       "DS:rcount:COUNTER:25:0:U",
-       "DS:rmerged:COUNTER:25:0:U",
-       "DS:rbytes:COUNTER:25:0:U",
-       "DS:rtime:COUNTER:25:0:U",
-       "DS:wcount:COUNTER:25:0:U",
-       "DS:wmerged:COUNTER:25:0:U",
-       "DS:wbytes:COUNTER:25:0:U",
-       "DS:wtime:COUNTER:25:0:U",
+       "DS:rcount:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rmerged:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rbytes:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rtime:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wcount:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wmerged:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wbytes:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wtime:COUNTER:"COLLECTD_HEARTBEAT":0:U",
        NULL
 };
 static int tape_ds_num = 8;
 
-void tape_init (void)
+#if defined(HAVE_LIBKSTAT)
+#define MAX_NUMTAPE 256
+extern kstat_ctl_t *kc;
+static kstat_t *ksp[MAX_NUMTAPE];
+static int numtape = 0;
+#endif /* HAVE_LIBKSTAT */
+
+static void tape_init (void)
 {
 #ifdef HAVE_LIBKSTAT
        kstat_t *ksp_chain;
@@ -77,7 +81,7 @@ void tape_init (void)
        return;
 }
 
-void tape_write (char *host, char *inst, char *val)
+static void tape_write (char *host, char *inst, char *val)
 {
        char file[512];
        int status;
@@ -92,8 +96,9 @@ void tape_write (char *host, char *inst, char *val)
 }
 
 
+#if TAPE_HAVE_READ
 #define BUFSIZE 512
-void tape_submit (char *tape_name,
+static void tape_submit (char *tape_name,
                unsigned long long read_count,
                unsigned long long read_merged,
                unsigned long long read_bytes,
@@ -118,7 +123,7 @@ void tape_submit (char *tape_name,
 
 #undef BUFSIZE
 
-void tape_read (void)
+static void tape_read (void)
 {
 
 #if defined(HAVE_LIBKSTAT)
@@ -140,6 +145,9 @@ void tape_read (void)
        }
 #endif /* defined(HAVE_LIBKSTAT) */
 }
+#else
+# define tape_read NULL
+#endif /* TAPE_HAVE_READ */
 
 void module_register (void)
 {
@@ -147,4 +155,3 @@ void module_register (void)
 }
 
 #undef MODULE_NAME
-#endif /* COLLECT_TAPE */