Code

Added first version of ACPI support to the battery plugin
[collectd.git] / src / cpufreq.c
index 7a6227ba33c7ec24d32c83fb75718aedcfe21db7..9d74c57680b22f423659e3d4f27b43bb45a4f251 100644 (file)
  *   Peter Holik <peter at holik.at>
  **/
 
-#include "cpufreq.h"
-
-/*
- * Originally written by Peter Holik
- */
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
 
-#if COLLECT_CPUFREQ
 #define MODULE_NAME "cpufreq"
 
-#include "plugin.h"
-#include "common.h"
-
-static int num_cpu = 0;
+#if defined(KERNEL_LINUX)
+# define CPUFREQ_HAVE_READ 1
+#else
+# define CPUFREQ_HAVE_READ 0
+#endif
 
 static char *cpufreq_file = "cpufreq-%s.rrd";
 
@@ -43,12 +41,15 @@ static char *ds_def[] =
 };
 static int ds_num = 1;
 
-extern time_t curtime;
+#ifdef KERNEL_LINUX
+static int num_cpu = 0;
+#endif
 
 #define BUFSIZE 256
 
-void cpufreq_init (void)
+static void cpufreq_init (void)
 {
+#ifdef KERNEL_LINUX
         int status;
        char filename[BUFSIZE];
 
@@ -67,9 +68,12 @@ void cpufreq_init (void)
        }
 
        syslog (LOG_INFO, MODULE_NAME" found %d cpu(s)", num_cpu);
+#endif /* defined(KERNEL_LINUX) */
+
+       return;
 }
 
-void cpufreq_write (char *host, char *inst, char *val)
+static void cpufreq_write (char *host, char *inst, char *val)
 {
         int status;
         char file[BUFSIZE];
@@ -81,7 +85,8 @@ void cpufreq_write (char *host, char *inst, char *val)
        rrd_update_file (host, file, val, ds_def, ds_num);
 }
 
-void cpufreq_submit (int cpu_num, unsigned long long val)
+#if CPUFREQ_HAVE_READ
+static void cpufreq_submit (int cpu_num, unsigned long long val)
 {
        char buf[BUFSIZE];
        char cpu[16];
@@ -93,8 +98,9 @@ void cpufreq_submit (int cpu_num, unsigned long long val)
        plugin_submit (MODULE_NAME, cpu, buf);
 }
 
-void cpufreq_read (void)
+static void cpufreq_read (void)
 {
+#ifdef KERNEL_LINUX
         int status;
        unsigned long long val;
        int i = 0;
@@ -128,7 +134,13 @@ void cpufreq_read (void)
 
                cpufreq_submit (i, val);
        }
+#endif /* defined(KERNEL_LINUX) */
+
+       return;
 }
+#else
+#define cpufreq_read NULL
+#endif
 #undef BUFSIZE
 
 void module_register (void)
@@ -137,4 +149,3 @@ void module_register (void)
 }
 
 #undef MODULE_NAME
-#endif /* COLLECT_CPUFREQ */