Code

mbmon plugin: Correct the `type's being passed to the dispatch function.
[collectd.git] / src / sensors.c
index 14d8abd1eb1fd2eee36a111a4f8ac2ff0ce4762f..862605a832ffcb7d8216f402fd0aeba44691ad5f 100644 (file)
@@ -1,11 +1,10 @@
 /**
  * collectd - src/sensors.c
- * Copyright (C) 2005,2006  Florian octo Forster
+ * Copyright (C) 2005-2007  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.
+ * Free Software Foundation; only version 2 of the License is applicable.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,8 +28,6 @@
  *   - config IgnoreSelected option
  **/
 
-
-
 #include "collectd.h"
 #include "common.h"
 #include "plugin.h"
 #include "utils_ignorelist.h"
 #include "utils_debug.h"
 
-/*
- * This weird macro cascade forces the glibc to define `NAN'. I don't know
- * another way to solve this, so more intelligent solutions are welcome. -octo
- */
-#ifndef __USE_ISOC99
-# define DISABLE__USE_ISOC99 1
-# define __USE_ISOC99 1
-#endif
-#include <math.h>
-#ifdef DISABLE__USE_ISOC99
-# undef DISABLE__USE_ISOC99
-# undef __USE_ISOC99
-#endif
-
 #if defined(HAVE_SENSORS_SENSORS_H)
 # include <sensors/sensors.h>
 #else
 # define SENSORS_HAVE_READ 0
 #endif
 
-static data_source_t data_source[1] =
+static data_source_t data_source_fanspeed[1] =
 {
-       {"value", DS_TYPE_GAUGE, NAN, NAN}
+       {"value", DS_TYPE_GAUGE, 0, NAN}
 };
+
 static data_set_t fanspeed_ds =
 {
-       "fanspeed", 1, data_source
+       "fanspeed", 1, data_source_fanspeed
+};
+
+static data_source_t data_source_temperature[1] =
+{
+       {"value", DS_TYPE_GAUGE, -273.15, NAN}
 };
 
 static data_set_t temperature_ds =
 {
-       "temperature", 1, data_source
+       "temperature", 1, data_source_temperature
+};
+
+static data_source_t data_source_voltage[1] =
+{
+       {"voltage", DS_TYPE_GAUGE, NAN, NAN}
 };
 
 static data_set_t voltage_ds =
 {
-       "voltage", 1, data_source
+       "voltage", 1, data_source_voltage
 };
 
 #if SENSORS_HAVE_READ
@@ -326,7 +320,7 @@ static void sensors_load_conf (void)
 
                                DBG ("Adding feature: %s-%s-%s",
                                                chip->prefix,
-                                               sensor_type_prefix[known_features[i].type],
+                                               sensor_to_type[known_features[i].type],
                                                data->name);
 
                                if ((new_feature = (featurelist_t *) malloc (sizeof (featurelist_t))) == NULL)
@@ -402,7 +396,6 @@ static int sensors_read (void)
 {
        featurelist_t *feature;
        double value;
-       char chip_fullprefix[512];
 
        char plugin_instance[DATA_MAX_NAME_LEN];
        char type_instance[DATA_MAX_NAME_LEN];
@@ -445,10 +438,12 @@ static int sensors_read (void)
                strncpy (type_instance, feature->data->name, DATA_MAX_NAME_LEN);
 
                sensors_submit (plugin_instance,
-                               sensor_to_type[feature->type]
+                               sensor_to_type[feature->type],
                                type_instance,
                                value);
        } /* for feature = first_feature .. NULL */
+
+       return (0);
 } /* int sensors_read */
 #endif /* SENSORS_HAVE_READ */