solaris-fixes branch: Applied the swap-patch by Christophe Kalt.
[collectd.git] / src / load.c
index 2a14edd..4d43dd4 100644 (file)
@@ -1,10 +1,36 @@
-#include "load.h"
+/**
+ * collectd - src/load.c
+ * Copyright (C) 2005,2006  Florian octo Forster
+ *
+ * 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ * Authors:
+ *   Florian octo Forster <octo at verplant.org>
+ **/
+
+#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>
@@ -22,27 +48,26 @@ static char *load_file = "load.rrd";
 
 static char *ds_def[] =
 {
-       "DS:shortterm:GAUGE:25:0:100",
-       "DS:midterm:GAUGE:25:0:100",
-       "DS:longterm:GAUGE:25:0:100",
+       "DS:shortterm:GAUGE:"COLLECTD_HEARTBEAT":0:100",
+       "DS:midterm:GAUGE:"COLLECTD_HEARTBEAT":0:100",
+       "DS:longterm:GAUGE:"COLLECTD_HEARTBEAT":0:100",
        NULL
 };
 static int ds_num = 3;
 
-extern time_t curtime;
-
-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);
 }
 
+#if LOAD_HAVE_READ
 #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];
 
@@ -54,7 +79,7 @@ void load_submit (double snum, double mnum, double lnum)
 }
 #undef BUFSIZE
 
-void load_read (void)
+static void load_read (void)
 {
 #if defined(HAVE_GETLOADAVG)
        double load[3];
@@ -114,6 +139,9 @@ void load_read (void)
        load_submit (snum, mnum, lnum);
 #endif /* HAVE_LIBSTATGRAB */
 }
+#else
+# define load_read NULL
+#endif /* LOAD_HAVE_READ */
 
 void module_register (void)
 {
@@ -121,4 +149,3 @@ void module_register (void)
 }
 
 #undef MODULE_NAME
-#endif /* COLLECT_LOAD */