+2007-12-28, Version 4.2.3
+ * sensors plugin: Updated the plugin to build and work with version 3
+ of the libsensors library.
+
+2007-12-15, Version 4.2.2
+ * nginx plugin: Incorrect comparison of strings lead to a segfault
+ when using the plugin. Thanks to Saulius Grigaliunas for fixing
+ this.
+ * logfile plugin: The config option `Timestamp' was handled
+ incorrectly and basically always active. Thanks to Luke Heberling
+ for fixing this.
+
2007-11-08, Version 4.2.1
* tcpconns plugin: Don't complain about a missing file if IPv6 is not
enabled on the host.
to see how many connections your FTP server has to handle or how
many outgoing connections your mailserver has open.
+2007-12-27, Version 4.1.5
+ * rrdtool plugin: Fix a memory leak that only occured in very-low-
+ memory situations.
+ * sensors plugin: Updated the plugin to build and work with version 3
+ of the libsensors library.
+
2007-11-08, Version 4.1.4
* Build system: Improve detection of the rrd library, especially if
it's in a non-standard location.
perl: perl/Makefile
$(MAKE) -C perl
-perl/Makefile: perl/Makefile.PL perl/Collectd/Makefile.PL \
- $(top_builddir)/config.status
+perl/Makefile: .perl-directory-stamp perl/Makefile.PL \
+ perl/Collectd/Makefile.PL $(top_builddir)/config.status
cd perl && @PERL@ Makefile.PL PREFIX=$(prefix) @PERL_BINDINGS_OPTIONS@
+.perl-directory-stamp:
+ if test ! -d perl; then \
+ mkdir -p perl/Collectd; \
+ cp $(srcdir)/perl/{Collectd.pm,Makefile.PL} perl/; \
+ cp $(srcdir)/perl/Collectd/{Unixsock.pm,Makefile.PL} perl/Collectd/; \
+ fi
+ touch $@
+
.PHONY: perl
#
# Copyright 2006 Vincent Stehlé <vincent.stehle@free.fr>
#
+# Patch to configure the data directory and hostname by Eddy Petrisor
+# <eddy.petrisor@gmail.com>.
+#
# 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
use Getopt::Long qw(:config no_ignore_case bundling pass_through);
my $DIR = "/var/lib/collectd";
-my $HOST = "_UNDEFINED_";
+my $HOST = undef;
GetOptions (
- "host-is=s" => \$HOST,
+ "host=s" => \$HOST,
"data-dir=s" => \$DIR
);
my @COLORS = (0xff7777, 0x7777ff, 0x55ff55, 0xffcc77, 0xff77ff, 0x77ffff,
0xffff77, 0x55aaff);
my @tmp = `/bin/hostname`; chomp(@tmp);
-$HOST = $tmp[0] if ( $HOST =~ /_UNDEFINED_/ );
+$HOST = $tmp[0] if (! defined $HOST);
my $IMG_DIR = "${HOST}.dir";
my $HTML = "${HOST}.html";
if BUILD_PLUGIN_NGINX
pkglib_LTLIBRARIES += nginx.la
nginx_la_SOURCES = nginx.c
+nginx_la_CFLAGS = $(AM_CFLAGS)
+nginx_la_LIBADD =
nginx_la_LDFLAGS = -module -avoid-version
if BUILD_WITH_LIBCURL
-nginx_la_LDFLAGS += $(BUILD_WITH_LIBCURL_LIBS)
+nginx_la_CFLAGS += $(BUILD_WITH_LIBCURL_CFLAGS)
+nginx_la_LIBADD += $(BUILD_WITH_LIBCURL_LIBS)
endif
collectd_LDADD += "-dlopen" nginx.la
collectd_DEPENDENCIES += nginx.la
static char send_buffer_type[DATA_MAX_NAME_LEN];
static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
-static avl_tree_t *cache_tree = NULL;
+static c_avl_tree_t *cache_tree = NULL;
static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
static time_t cache_flush_last;
static int cache_flush_interval = 1800;
char *key;
time_t *value;
- avl_iterator_t *iter;
+ c_avl_iterator_t *iter;
time_t curtime = time (NULL);
- iter = avl_get_iterator (cache_tree);
- while (avl_iterator_next (iter, (void *) &key, (void *) &value) == 0)
+ iter = c_avl_get_iterator (cache_tree);
+ while (c_avl_iterator_next (iter, (void *) &key, (void *) &value) == 0)
{
if ((curtime - *value) <= cache_flush_interval)
continue;
if (tmp == NULL)
{
sfree (keys);
- avl_iterator_destroy (iter);
+ c_avl_iterator_destroy (iter);
ERROR ("network plugin: cache_flush: realloc"
" failed.");
return (-1);
keys = tmp;
keys[keys_num] = key;
keys_num++;
- } /* while (avl_iterator_next) */
- avl_iterator_destroy (iter);
+ } /* while (c_avl_iterator_next) */
+ c_avl_iterator_destroy (iter);
for (i = 0; i < keys_num; i++)
{
- if (avl_remove (cache_tree, keys[i], (void *) &key,
+ if (c_avl_remove (cache_tree, keys[i], (void *) &key,
(void *) &value) != 0)
{
- WARNING ("network plugin: cache_flush: avl_remove"
+ WARNING ("network plugin: cache_flush: c_avl_remove"
" (%s) failed.", keys[i]);
continue;
}
pthread_mutex_lock (&cache_lock);
- if (avl_get (cache_tree, key, (void *) &value) == 0)
+ if (c_avl_get (cache_tree, key, (void *) &value) == 0)
{
if (*value < vl->time)
{
if ((key_copy != NULL) && (value != NULL))
{
*value = vl->time;
- avl_insert (cache_tree, key_copy, value);
+ c_avl_insert (cache_tree, key_copy, value);
retval = 0;
}
else
void *key;
void *value;
- while (avl_pick (cache_tree, &key, &value) == 0)
+ while (c_avl_pick (cache_tree, &key, &value) == 0)
{
sfree (key);
sfree (value);
}
- avl_destroy (cache_tree);
+ c_avl_destroy (cache_tree);
cache_tree = NULL;
}
memset (&send_buffer_vl, '\0', sizeof (send_buffer_vl));
memset (send_buffer_type, '\0', sizeof (send_buffer_type));
- cache_tree = avl_create ((int (*) (const void *, const void *)) strcmp);
+ cache_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp);
cache_flush_last = time (NULL);
/* setup socket(s) and so on */
static int cache_timeout = 0;
static int cache_flush_timeout = 0;
static time_t cache_flush_last;
-static avl_tree_t *cache = NULL;
+static c_avl_tree_t *cache = NULL;
static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
static rrd_queue_t *queue_head = NULL;
* we make a copy of it's values */
pthread_mutex_lock (&cache_lock);
- avl_get (cache, queue_entry->filename, (void *) &cache_entry);
+ c_avl_get (cache, queue_entry->filename, (void *) &cache_entry);
values = cache_entry->values;
values_num = cache_entry->values_num;
} /* while (42) */
pthread_mutex_lock (&cache_lock);
- avl_destroy (cache);
+ c_avl_destroy (cache);
cache = NULL;
pthread_mutex_unlock (&cache_lock);
int keys_num = 0;
char *key;
- avl_iterator_t *iter;
+ c_avl_iterator_t *iter;
int i;
DEBUG ("rrdtool plugin: Flushing cache, timeout = %i", timeout);
now = time (NULL);
/* Build a list of entries to be flushed */
- iter = avl_get_iterator (cache);
- while (avl_iterator_next (iter, (void *) &key, (void *) &rc) == 0)
+ iter = c_avl_get_iterator (cache);
+ while (c_avl_iterator_next (iter, (void *) &key, (void *) &rc) == 0)
{
if (rc->flags == FLAG_QUEUED)
continue;
}
else /* ancient and no values -> waste of memory */
{
- keys = (char **) realloc ((void *) keys,
+ char **tmp = (char **) realloc ((void *) keys,
(keys_num + 1) * sizeof (char *));
- if (keys == NULL)
+ if (tmp == NULL)
{
char errbuf[1024];
ERROR ("rrdtool plugin: "
"realloc failed: %s",
sstrerror (errno, errbuf,
sizeof (errbuf)));
- avl_iterator_destroy (iter);
+ c_avl_iterator_destroy (iter);
+ sfree (keys);
return;
}
+ keys = tmp;
keys[keys_num] = key;
keys_num++;
}
- } /* while (avl_iterator_next) */
- avl_iterator_destroy (iter);
+ } /* while (c_avl_iterator_next) */
+ c_avl_iterator_destroy (iter);
for (i = 0; i < keys_num; i++)
{
- if (avl_remove (cache, keys[i], (void *) &key, (void *) &rc) != 0)
+ if (c_avl_remove (cache, keys[i], (void *) &key, (void *) &rc) != 0)
{
- DEBUG ("rrdtool plugin: avl_remove (%s) failed.", keys[i]);
+ DEBUG ("rrdtool plugin: c_avl_remove (%s) failed.", keys[i]);
continue;
}
keys[i] = NULL;
} /* for (i = 0..keys_num) */
- free (keys);
+ sfree (keys);
cache_flush_last = now;
} /* void rrd_cache_flush */
pthread_mutex_lock (&cache_lock);
- avl_get (cache, filename, (void *) &rc);
+ c_avl_get (cache, filename, (void *) &rc);
if (rc == NULL)
{
sstrerror (errno, errbuf, sizeof (errbuf));
- avl_remove (cache, filename, &cache_key, NULL);
+ c_avl_remove (cache, filename, &cache_key, NULL);
pthread_mutex_unlock (&cache_lock);
ERROR ("rrdtool plugin: realloc failed: %s", errbuf);
return (-1);
}
- avl_insert (cache, cache_key, rc);
+ c_avl_insert (cache, cache_key, rc);
}
DEBUG ("rrdtool plugin: rrd_cache_insert: file = %s; "
/* Set the cache up */
pthread_mutex_lock (&cache_lock);
- cache = avl_create ((int (*) (const void *, const void *)) strcmp);
+ cache = c_avl_create ((int (*) (const void *, const void *)) strcmp);
if (cache == NULL)
{
- ERROR ("rrdtool plugin: avl_create failed.");
+ ERROR ("rrdtool plugin: c_avl_create failed.");
return (-1);
}
# include <sensors/sensors.h>
#endif
-#define SENSOR_TYPE_VOLTAGE 0
-#define SENSOR_TYPE_FANSPEED 1
-#define SENSOR_TYPE_TEMPERATURE 2
-#define SENSOR_TYPE_UNKNOWN 3
+#if !defined(SENSORS_API_VERSION)
+# define SENSORS_API_VERSION 0x000
+#endif
-static char *sensor_to_type[] =
+/*
+ * The sensors library prior to version 3.0 (internal version 0x400) didn't
+ * report the type of values, only a name. The following lists are there to
+ * convert from the names to the type. They are not used with the new
+ * interface.
+ */
+#if SENSORS_API_VERSION < 0x400
+static char *sensor_type_name_map[] =
{
+# define SENSOR_TYPE_VOLTAGE 0
"voltage",
+# define SENSOR_TYPE_FANSPEED 1
"fanspeed",
+# define SENSOR_TYPE_TEMPERATURE 2
"temperature",
+# define SENSOR_TYPE_UNKNOWN 3
NULL
};
};
typedef struct sensors_labeltypes_s sensors_labeltypes_t;
-/*
- * finite list of known labels extracted from lm_sensors
- */
+/* finite list of known labels extracted from lm_sensors */
static sensors_labeltypes_t known_features[] =
{
{ "fan1", SENSOR_TYPE_FANSPEED },
};
static int known_features_num = STATIC_ARRAY_SIZE (known_features);
/* end new naming */
+#endif /* SENSORS_API_VERSION < 0x400 */
static const char *config_keys[] =
{
"Sensor",
- "IgnoreSelected",
- NULL
+ "IgnoreSelected"
};
-static int config_keys_num = 2;
-
-static ignorelist_t *sensor_list;
-
-#ifndef SENSORS_CONF_PATH
-# define SENSORS_CONF_PATH "/etc/sensors.conf"
-#endif
-
-static const char *conffile = SENSORS_CONF_PATH;
-/* SENSORS_CONF_PATH */
-
-/*
- * remember stat of the loaded config
- */
-static time_t sensors_config_mtime = 0;
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+#if SENSORS_API_VERSION < 0x400
typedef struct featurelist
{
const sensors_chip_name *chip;
struct featurelist *next;
} featurelist_t;
+# ifndef SENSORS_CONF_PATH
+# define SENSORS_CONF_PATH "/etc/sensors.conf"
+# endif
+/* #endif SENSORS_API_VERSION < 0x400 */
+
+#elif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
+typedef struct featurelist
+{
+ const sensors_chip_name *chip;
+ const sensors_feature *feature;
+ const sensors_subfeature *subfeature;
+ struct featurelist *next;
+} featurelist_t;
+
+# ifndef SENSORS_CONF_PATH
+# define SENSORS_CONF_PATH "/etc/sensors3.conf"
+# endif
+/* #endif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */
+
+#else /* if SENSORS_API_VERSION >= 0x500 */
+# error "This version of libsensors is not supported yet. Please report this " \
+ "as bug."
+#endif
+
+static const char *conffile = SENSORS_CONF_PATH;
featurelist_t *first_feature = NULL;
+static ignorelist_t *sensor_list;
+static time_t sensors_config_mtime = 0;
+
+#if SENSORS_API_VERSION < 0x400
+/* full chip name logic borrowed from lm_sensors */
+static int sensors_snprintf_chip_name (char *buf, size_t buf_size,
+ const sensors_chip_name *chip)
+{
+ int status = -1;
+
+ if (chip->bus == SENSORS_CHIP_NAME_BUS_ISA)
+ {
+ status = snprintf (buf, buf_size,
+ "%s-isa-%04x",
+ chip->prefix,
+ chip->addr);
+ }
+ else if (chip->bus == SENSORS_CHIP_NAME_BUS_DUMMY)
+ {
+ snprintf (buf, buf_size, "%s-%s-%04x",
+ chip->prefix,
+ chip->busname,
+ chip->addr);
+ }
+ else
+ {
+ snprintf (buf, buf_size, "%s-i2c-%d-%02x",
+ chip->prefix,
+ chip->bus,
+ chip->addr);
+ }
+
+ return (status);
+} /* int sensors_snprintf_chip_name */
+
+static int sensors_feature_name_to_type (const char *name)
+{
+ int i;
+
+ /* Yes, this is slow, but it's only ever done during initialization, so
+ * it's a one time cost.. */
+ for (i = 0; i < known_features_num; i++)
+ if (strcasecmp (known_features[i].label, name) == 0)
+ return (known_features[i].type);
+
+ return (SENSOR_TYPE_UNKNOWN);
+} /* int sensors_feature_name_to_type */
+#endif
static int sensors_config (const char *key, const char *value)
{
{
FILE *fh;
featurelist_t *last_feature = NULL;
- featurelist_t *new_feature = NULL;
const sensors_chip_name *chip;
int chip_num;
- const sensors_feature_data *data;
- int data_num0, data_num1;
-
struct stat statbuf;
int status;
sensors_config_mtime = statbuf.st_mtime;
+#if SENSORS_API_VERSION < 0x400
chip_num = 0;
while ((chip = sensors_get_detected_chips (&chip_num)) != NULL)
{
- data = NULL;
- data_num0 = data_num1 = 0;
+ int feature_num0 = 0;
+ int feature_num1 = 0;
- while ((data = sensors_get_all_features (*chip, &data_num0, &data_num1))
- != NULL)
+ while (42)
{
- int i;
+ const sensors_feature_data *feature;
+ int feature_type;
+ featurelist_t *fl;
+
+ feature = sensors_get_all_features (*chip,
+ &feature_num0, &feature_num1);
+
+ /* Check if all features have been read. */
+ if (feature == NULL)
+ break;
/* "master features" only */
- if (data->mapping != SENSORS_NO_MAPPING)
+ if (feature->mapping != SENSORS_NO_MAPPING)
+ continue;
+
+ /* skip ignored in sensors.conf */
+ if (sensors_get_ignored (*chip, feature->number) == 0)
+ break;
+
+ feature_type = sensors_feature_name_to_type (
+ feature->name);
+ if (feature_type == SENSOR_TYPE_UNKNOWN)
continue;
- /* Only known features */
- for (i = 0; i < known_features_num; i++)
+ fl = (featurelist_t *) malloc (sizeof (featurelist_t));
+ if (fl == NULL)
{
- if (strcmp (data->name, known_features[i].label) != 0)
- continue;
+ ERROR ("sensors plugin: malloc failed.");
+ continue;
+ }
+ memset (fl, '\0', sizeof (featurelist_t));
+
+ fl->chip = chip;
+ fl->data = feature;
+ fl->type = feature_type;
+
+ if (first_feature == NULL)
+ first_feature = fl;
+ else
+ last_feature->next = fl;
+ last_feature = fl;
+ } /* while sensors_get_all_features */
+ } /* while sensors_get_detected_chips */
+/* #endif SENSORS_API_VERSION < 0x400 */
+
+#elif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
+ chip_num = 0;
+ while ((chip = sensors_get_detected_chips (NULL, &chip_num)) != NULL)
+ {
+ const sensors_feature *feature;
+ int feature_num = 0;
- /* skip ignored in sensors.conf */
- if (sensors_get_ignored (*chip, data->number) == 0)
- break;
+ while ((feature = sensors_get_features (chip, &feature_num)) != NULL)
+ {
+ const sensors_subfeature *subfeature;
+ int subfeature_num = 0;
+
+ /* Only handle voltage, fanspeeds and temperatures */
+ if ((feature->type != SENSORS_FEATURE_IN)
+ && (feature->type != SENSORS_FEATURE_FAN)
+ && (feature->type != SENSORS_FEATURE_TEMP))
+ continue;
- DEBUG ("Adding feature: %s-%s-%s",
- chip->prefix,
- sensor_to_type[known_features[i].type],
- data->name);
+ while ((subfeature = sensors_get_all_subfeatures (chip,
+ feature, &subfeature_num)) != NULL)
+ {
+ featurelist_t *fl;
+
+ if ((subfeature->type != SENSORS_SUBFEATURE_IN_INPUT)
+ && (subfeature->type != SENSORS_SUBFEATURE_FAN_INPUT)
+ && (subfeature->type != SENSORS_SUBFEATURE_TEMP_INPUT))
+ continue;
- if ((new_feature = (featurelist_t *) malloc (sizeof (featurelist_t))) == NULL)
+ fl = (featurelist_t *) malloc (sizeof (featurelist_t));
+ if (fl == NULL)
{
- char errbuf[1024];
- ERROR ("sensors plugin: malloc: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
- break;
+ ERROR ("sensors plugin: malloc failed.");
+ continue;
}
+ memset (fl, '\0', sizeof (featurelist_t));
- new_feature->chip = chip;
- new_feature->data = data;
- new_feature->type = known_features[i].type;
- new_feature->next = NULL;
+ fl->chip = chip;
+ fl->feature = feature;
+ fl->subfeature = subfeature;
if (first_feature == NULL)
- {
- first_feature = new_feature;
- last_feature = new_feature;
- }
+ first_feature = fl;
else
- {
- last_feature->next = new_feature;
- last_feature = new_feature;
- }
-
- /* stop searching known features at first found */
- break;
- } /* for i */
- } /* while sensors_get_all_features */
- } /* while sensors_get_detected_chips */
+ last_feature->next = fl;
+ last_feature = fl;
+ } /* while (subfeature) */
+ } /* while (feature) */
+ } /* while (chip) */
+#endif /* (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */
if (first_feature == NULL)
{
status = snprintf (match_key, sizeof (match_key), "%s/%s-%s",
plugin_instance, type, type_instance);
- if ((status < 1) || (status >= sizeof (match_key)))
+ if (status < 1)
return;
match_key[sizeof (match_key) - 1] = '\0';
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "sensors");
- strcpy (vl.plugin_instance, plugin_instance);
- strcpy (vl.type_instance, type_instance);
+
+ strncpy (vl.host, hostname_g, sizeof (vl.host));
+ vl.host[sizeof (vl.host) - 1] = '\0';
+ strncpy (vl.plugin, "sensors", sizeof (vl.plugin));
+ vl.plugin[sizeof (vl.plugin) - 1] = '\0';
+ strncpy (vl.plugin_instance, plugin_instance,
+ sizeof (vl.plugin_instance));
+ vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0';
+ strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
plugin_dispatch_values (type, &vl);
} /* void sensors_submit */
static int sensors_read (void)
{
- featurelist_t *feature;
- double value;
-
- char plugin_instance[DATA_MAX_NAME_LEN];
- char type_instance[DATA_MAX_NAME_LEN];
+ featurelist_t *fl;
if (sensors_load_conf () != 0)
return (-1);
- for (feature = first_feature; feature != NULL; feature = feature->next)
+#if SENSORS_API_VERSION < 0x400
+ for (fl = first_feature; fl != NULL; fl = fl->next)
{
- if (sensors_get_feature (*feature->chip, feature->data->number, &value) < 0)
+ double value;
+ int status;
+ char plugin_instance[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ status = sensors_get_feature (*fl->chip,
+ fl->data->number, &value);
+ if (status < 0)
continue;
- /* full chip name logic borrowed from lm_sensors */
- if (feature->chip->bus == SENSORS_CHIP_NAME_BUS_ISA)
- {
- if (snprintf (plugin_instance, DATA_MAX_NAME_LEN, "%s-isa-%04x",
- feature->chip->prefix,
- feature->chip->addr)
- >= 512)
- continue;
- }
- else if (feature->chip->bus == SENSORS_CHIP_NAME_BUS_DUMMY)
- {
- if (snprintf (plugin_instance, 512, "%s-%s-%04x",
- feature->chip->prefix,
- feature->chip->busname,
- feature->chip->addr)
- >= 512)
- continue;
- }
- else
- {
- if (snprintf (plugin_instance, 512, "%s-i2c-%d-%02x",
- feature->chip->prefix,
- feature->chip->bus,
- feature->chip->addr)
- >= 512)
- continue;
- }
+ status = sensors_snprintf_chip_name (plugin_instance,
+ sizeof (plugin_instance), fl->chip);
+ if (status < 0)
+ continue;
+ plugin_instance[sizeof (plugin_instance) - 1] = '\0';
- strncpy (type_instance, feature->data->name, DATA_MAX_NAME_LEN);
+ strncpy (type_instance, fl->data->name,
+ sizeof (type_instance));
+ type_instance[sizeof (type_instance) - 1] = '\0';
sensors_submit (plugin_instance,
- sensor_to_type[feature->type],
+ sensor_type_name_map[fl->type],
type_instance,
value);
- } /* for feature = first_feature .. NULL */
+ } /* for fl = first_feature .. NULL */
+/* #endif SENSORS_API_VERSION < 0x400 */
+
+#elif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
+ for (fl = first_feature; fl != NULL; fl = fl->next)
+ {
+ double value;
+ int status;
+ char plugin_instance[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN];
+ const char *type;
+
+ status = sensors_get_value (fl->chip,
+ fl->subfeature->number, &value);
+ if (status < 0)
+ continue;
+
+ status = sensors_snprintf_chip_name (plugin_instance,
+ sizeof (plugin_instance), fl->chip);
+ if (status < 0)
+ continue;
+ plugin_instance[sizeof (plugin_instance) - 1] = '\0';
+
+ strncpy (type_instance, fl->feature->name,
+ sizeof (type_instance));
+ type_instance[sizeof (type_instance) - 1] = '\0';
+
+ if (fl->feature->type == SENSORS_FEATURE_IN)
+ type = "voltage";
+ else if (fl->feature->type
+ == SENSORS_FEATURE_FAN)
+ type = "fanspeed";
+ else if (fl->feature->type
+ == SENSORS_FEATURE_TEMP)
+ type = "input";
+ else
+ continue;
+
+ sensors_submit (plugin_instance, type, type_instance, value);
+ } /* for fl = first_feature .. NULL */
+#endif /* (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */
return (0);
} /* int sensors_read */
/*
* private data types
*/
-struct avl_node_s
+struct c_avl_node_s
{
void *key;
void *value;
int height;
- struct avl_node_s *left;
- struct avl_node_s *right;
- struct avl_node_s *parent;
+ struct c_avl_node_s *left;
+ struct c_avl_node_s *right;
+ struct c_avl_node_s *parent;
};
-typedef struct avl_node_s avl_node_t;
+typedef struct c_avl_node_s c_avl_node_t;
-struct avl_tree_s
+struct c_avl_tree_s
{
- avl_node_t *root;
+ c_avl_node_t *root;
int (*compare) (const void *, const void *);
};
-struct avl_iterator_s
+struct c_avl_iterator_s
{
- avl_tree_t *tree;
- avl_node_t *node;
+ c_avl_tree_t *tree;
+ c_avl_node_t *node;
};
/*
* private functions
*/
#if 0
-static void verify_tree (avl_node_t *n)
+static void verify_tree (c_avl_node_t *n)
{
if (n == NULL)
return;
# define verify_tree(n) /**/
#endif
-static void free_node (avl_node_t *n)
+static void free_node (c_avl_node_t *n)
{
if (n == NULL)
return;
free (n);
}
-static int calc_height (avl_node_t *n)
+static int calc_height (c_avl_node_t *n)
{
int height_left;
int height_right;
: height_right) + 1);
} /* int calc_height */
-static avl_node_t *search (avl_tree_t *t, const void *key)
+static c_avl_node_t *search (c_avl_tree_t *t, const void *key)
{
- avl_node_t *n;
+ c_avl_node_t *n;
int cmp;
n = t->root;
* / a\ /_b\ /_b\ /_c\
* /____\
*/
-static avl_node_t *rotate_right (avl_tree_t *t, avl_node_t *x)
+static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x)
{
- avl_node_t *p;
- avl_node_t *y;
- avl_node_t *b;
+ c_avl_node_t *p;
+ c_avl_node_t *y;
+ c_avl_node_t *b;
p = x->parent;
y = x->left;
* /_b\ / c\ /_a\ /_b\
* /____\
*/
-static avl_node_t *rotate_left (avl_tree_t *t, avl_node_t *x)
+static c_avl_node_t *rotate_left (c_avl_tree_t *t, c_avl_node_t *x)
{
- avl_node_t *p;
- avl_node_t *y;
- avl_node_t *b;
+ c_avl_node_t *p;
+ c_avl_node_t *y;
+ c_avl_node_t *b;
p = x->parent;
y = x->right;
return (y);
} /* void rotate_left */
-static avl_node_t *rotate_left_right (avl_tree_t *t, avl_node_t *x)
+static c_avl_node_t *rotate_left_right (c_avl_tree_t *t, c_avl_node_t *x)
{
rotate_left (t, x->left);
return (rotate_right (t, x));
} /* void rotate_left_right */
-static avl_node_t *rotate_right_left (avl_tree_t *t, avl_node_t *x)
+static c_avl_node_t *rotate_right_left (c_avl_tree_t *t, c_avl_node_t *x)
{
rotate_right (t, x->right);
return (rotate_left (t, x));
} /* void rotate_right_left */
-static void rebalance (avl_tree_t *t, avl_node_t *n)
+static void rebalance (c_avl_tree_t *t, c_avl_node_t *n)
{
int b_top;
int b_bottom;
} /* while (n != NULL) */
} /* void rebalance */
-static avl_node_t *avl_node_next (avl_tree_t *t, avl_node_t *n)
+static c_avl_node_t *c_avl_node_next (c_avl_tree_t *t, c_avl_node_t *n)
{
- avl_node_t *r; /* return node */
+ c_avl_node_t *r; /* return node */
if (n == NULL)
{
}
return (r);
-} /* avl_node_t *avl_node_next */
+} /* c_avl_node_t *c_avl_node_next */
-static avl_node_t *avl_node_prev (avl_tree_t *t, avl_node_t *n)
+static c_avl_node_t *c_avl_node_prev (c_avl_tree_t *t, c_avl_node_t *n)
{
- avl_node_t *r; /* return node */
+ c_avl_node_t *r; /* return node */
if (n == NULL)
{
}
return (r);
-} /* avl_node_t *avl_node_prev */
+} /* c_avl_node_t *c_avl_node_prev */
-static int _remove (avl_tree_t *t, avl_node_t *n)
+static int _remove (c_avl_tree_t *t, c_avl_node_t *n)
{
assert ((t != NULL) && (n != NULL));
if ((n->left != NULL) && (n->right != NULL))
{
- avl_node_t *r; /* replacement node */
+ c_avl_node_t *r; /* replacement node */
if (BALANCE (n) > 0) /* left subtree is higher */
{
assert (n->left != NULL);
- r = avl_node_prev (t, n);
+ r = c_avl_node_prev (t, n);
}
else /* right subtree is higher */
{
assert (n->right != NULL);
- r = avl_node_next (t, n);
+ r = c_avl_node_next (t, n);
}
assert ((r->left == NULL) || (r->right == NULL));
/*
* public functions
*/
-avl_tree_t *avl_create (int (*compare) (const void *, const void *))
+c_avl_tree_t *c_avl_create (int (*compare) (const void *, const void *))
{
- avl_tree_t *t;
+ c_avl_tree_t *t;
if (compare == NULL)
return (NULL);
- if ((t = (avl_tree_t *) malloc (sizeof (avl_tree_t))) == NULL)
+ if ((t = (c_avl_tree_t *) malloc (sizeof (c_avl_tree_t))) == NULL)
return (NULL);
t->root = NULL;
return (t);
}
-void avl_destroy (avl_tree_t *t)
+void c_avl_destroy (c_avl_tree_t *t)
{
free_node (t->root);
free (t);
}
-int avl_insert (avl_tree_t *t, void *key, void *value)
+int c_avl_insert (c_avl_tree_t *t, void *key, void *value)
{
- avl_node_t *new;
- avl_node_t *nptr;
+ c_avl_node_t *new;
+ c_avl_node_t *nptr;
int cmp;
- if ((new = (avl_node_t *) malloc (sizeof (avl_node_t))) == NULL)
+ if ((new = (c_avl_node_t *) malloc (sizeof (c_avl_node_t))) == NULL)
return (-1);
new->key = key;
verify_tree (t->root);
return (0);
-} /* int avl_insert */
+} /* int c_avl_insert */
-int avl_remove (avl_tree_t *t, const void *key, void **rkey, void **rvalue)
+int c_avl_remove (c_avl_tree_t *t, const void *key, void **rkey, void **rvalue)
{
- avl_node_t *n;
+ c_avl_node_t *n;
int status;
assert (t != NULL);
status = _remove (t, n);
verify_tree (t->root);
return (status);
-} /* void *avl_remove */
+} /* void *c_avl_remove */
-int avl_get (avl_tree_t *t, const void *key, void **value)
+int c_avl_get (c_avl_tree_t *t, const void *key, void **value)
{
- avl_node_t *n;
+ c_avl_node_t *n;
n = search (t, key);
if (n == NULL)
return (0);
}
-int avl_pick (avl_tree_t *t, void **key, void **value)
+int c_avl_pick (c_avl_tree_t *t, void **key, void **value)
{
- avl_node_t *n;
- avl_node_t *p;
+ c_avl_node_t *n;
+ c_avl_node_t *p;
if ((key == NULL) || (value == NULL))
return (-1);
rebalance (t, p);
return (0);
-} /* int avl_pick */
+} /* int c_avl_pick */
-avl_iterator_t *avl_get_iterator (avl_tree_t *t)
+c_avl_iterator_t *c_avl_get_iterator (c_avl_tree_t *t)
{
- avl_iterator_t *iter;
+ c_avl_iterator_t *iter;
if (t == NULL)
return (NULL);
- iter = (avl_iterator_t *) malloc (sizeof (avl_iterator_t));
+ iter = (c_avl_iterator_t *) malloc (sizeof (c_avl_iterator_t));
if (iter == NULL)
return (NULL);
- memset (iter, '\0', sizeof (avl_iterator_t));
+ memset (iter, '\0', sizeof (c_avl_iterator_t));
iter->tree = t;
return (iter);
-} /* avl_iterator_t *avl_get_iterator */
+} /* c_avl_iterator_t *c_avl_get_iterator */
-int avl_iterator_next (avl_iterator_t *iter, void **key, void **value)
+int c_avl_iterator_next (c_avl_iterator_t *iter, void **key, void **value)
{
- avl_node_t *n;
+ c_avl_node_t *n;
if ((iter == NULL) || (key == NULL) || (value == NULL))
return (-1);
}
else
{
- n = avl_node_next (iter->tree, iter->node);
+ n = c_avl_node_next (iter->tree, iter->node);
}
if (n == NULL)
*value = n->value;
return (0);
-} /* int avl_iterator_next */
+} /* int c_avl_iterator_next */
-int avl_iterator_prev (avl_iterator_t *iter, void **key, void **value)
+int c_avl_iterator_prev (c_avl_iterator_t *iter, void **key, void **value)
{
- avl_node_t *n;
+ c_avl_node_t *n;
if ((iter == NULL) || (key == NULL) || (value == NULL))
return (-1);
}
else
{
- n = avl_node_prev (iter->tree, iter->node);
+ n = c_avl_node_prev (iter->tree, iter->node);
}
if (n == NULL)
*value = n->value;
return (0);
-} /* int avl_iterator_prev */
+} /* int c_avl_iterator_prev */
-void avl_iterator_destroy (avl_iterator_t *iter)
+void c_avl_iterator_destroy (c_avl_iterator_t *iter)
{
free (iter);
}
#ifndef UTILS_AVLTREE_H
#define UTILS_AVLTREE_H 1
-struct avl_tree_s;
-typedef struct avl_tree_s avl_tree_t;
+struct c_avl_tree_s;
+typedef struct c_avl_tree_s c_avl_tree_t;
-struct avl_iterator_s;
-typedef struct avl_iterator_s avl_iterator_t;
+struct c_avl_iterator_s;
+typedef struct c_avl_iterator_s c_avl_iterator_t;
/*
* NAME
- * avl_create
+ * c_avl_create
*
* DESCRIPTION
* Allocates a new AVL-tree.
* function from the libc here.
*
* RETURN VALUE
- * A avl_tree_t-pointer upon success or NULL upon failure.
+ * A c_avl_tree_t-pointer upon success or NULL upon failure.
*/
-avl_tree_t *avl_create (int (*compare) (const void *, const void *));
+c_avl_tree_t *c_avl_create (int (*compare) (const void *, const void *));
/*
* NAME
- * avl_destroy
+ * c_avl_destroy
*
* DESCRIPTION
* Deallocates an AVL-tree. Stored value- and key-pointer are lost, but of
* course not freed.
*/
-void avl_destroy (avl_tree_t *t);
+void c_avl_destroy (c_avl_tree_t *t);
/*
* NAME
- * avl_insert
+ * c_avl_insert
*
* DESCRIPTION
* Stores the key-value-pair in the AVL-tree pointed to by `t'.
* Zero upon success, non-zero otherwise. It's less than zero if an error
* occurred or greater than zero if the key is already stored in the tree.
*/
-int avl_insert (avl_tree_t *t, void *key, void *value);
+int c_avl_insert (c_avl_tree_t *t, void *key, void *value);
/*
* NAME
- * avl_remove
+ * c_avl_remove
*
* DESCRIPTION
* Removes a key-value-pair from the tree t. The stored key and value may be
* RETURN VALUE
* Zero upon success or non-zero if the key isn't found in the tree.
*/
-int avl_remove (avl_tree_t *t, const void *key, void **rkey, void **rvalue);
+int c_avl_remove (c_avl_tree_t *t, const void *key, void **rkey, void **rvalue);
/*
* NAME
- * avl_get
+ * c_avl_get
*
* DESCRIPTION
* Retrieve the `value' belonging to `key'.
* RETURN VALUE
* Zero upon success or non-zero if the key isn't found in the tree.
*/
-int avl_get (avl_tree_t *t, const void *key, void **value);
+int c_avl_get (c_avl_tree_t *t, const void *key, void **value);
/*
* NAME
- * avl_pick
+ * c_avl_pick
*
* DESCRIPTION
* Remove a (pseudo-)random element from the tree and return it's `key' and
* Zero upon success or non-zero if the tree is empty or key or value is
* NULL.
*/
-int avl_pick (avl_tree_t *t, void **key, void **value);
+int c_avl_pick (c_avl_tree_t *t, void **key, void **value);
-avl_iterator_t *avl_get_iterator (avl_tree_t *t);
-int avl_iterator_next (avl_iterator_t *iter, void **key, void **value);
-int avl_iterator_prev (avl_iterator_t *iter, void **key, void **value);
-void avl_iterator_destroy (avl_iterator_t *iter);
+c_avl_iterator_t *c_avl_get_iterator (c_avl_tree_t *t);
+int c_avl_iterator_next (c_avl_iterator_t *iter, void **key, void **value);
+int c_avl_iterator_prev (c_avl_iterator_t *iter, void **key, void **value);
+void c_avl_iterator_destroy (c_avl_iterator_t *iter);
#endif /* UTILS_AVLTREE_H */
struct tabmntent *mntlist;
if(listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
+#if COLLECT_DEBUG
char errbuf[1024];
DEBUG("utils_mount: calling listmntent() failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
+#endif /* COLLECT_DEBUG */
}
for(p = mntlist; p; p = p->next) {
/* Get the number of mounted file systems */
if ((bufsize = CMD_STATFS (NULL, 0, FLAGS_STATFS)) < 1)
{
+#if COLLECT_DEBUG
char errbuf[1024];
DEBUG ("utils_mount: getv?fsstat failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
+#endif /* COLLECT_DEBUG */
return (NULL);
}
* manpage.. -octo */
if ((num = CMD_STATFS (buf, bufsize * sizeof (STRUCT_STATFS), FLAGS_STATFS)) < 1)
{
+#if COLLECT_DEBUG
char errbuf[1024];
DEBUG ("utils_mount: getv?fsstat failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
+#endif /* COLLECT_DEBUG */
free (buf);
return (NULL);
}
#!/bin/sh
-DEFAULT_VERSION="4.2.1.git"
+DEFAULT_VERSION="4.2.3.git"
VERSION="$( git describe 2> /dev/null | sed -e 's/^collectd-//' )"