author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 7 Feb 2011 07:42:05 +0000 (08:42 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 7 Feb 2011 07:42:05 +0000 (08:42 +0100) |
configure.in | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/common.c | patch | blob | history | |
src/configfile.c | patch | blob | history | |
src/configfile.h | patch | blob | history | |
src/mysql.c | patch | blob | history | |
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history | |
src/teamspeak2.c | patch | blob | history | |
src/varnish.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 8be7965585f276ac20aa4ee174b6d2cf0a95c889..8db24ca4e82e8b590068cc64d8b68afb76f9ff77 100644 (file)
--- a/configure.in
+++ b/configure.in
then
plugin_cpu="yes"
plugin_memory="yes"
- plugin_swap="yes"
plugin_uptime="yes"
+ if test "x$ac_system" = "xDarwin"
+ then
+ plugin_swap="yes"
+ fi
fi
if test "x$have_sysctlbyname" = "xyes"
then
plugin_swap="yes"
fi
-if test "x$have_swapctl" = "xyes"
+if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
then
plugin_swap="yes"
fi
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index f1101fcb7db3a0d8d4c3104a28de3ed9ae074e57..94cf2a9356ba2cfbc88f1e551c469c237e66d20a 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#<Plugin hddtemp>
# Host "127.0.0.1"
# Port "7634"
-#
-# #----------------------------------------------------------------#
-# # `TranslateDevicename' enables backwards compatibility behavior #
-# # and is enabled by default. Setting this option to `false' is #
-# # highly recommended. #
-# #----------------------------------------------------------------#
-# TranslateDevicename false
#</Plugin>
#<Plugin interface>
diff --git a/src/common.c b/src/common.c
index 142d7979adf1fc2c02e6a54d9a4bdc8483598c4e..6fdb441c95af1ed952267d674e8d7f240f289dc5 100644 (file)
--- a/src/common.c
+++ b/src/common.c
# include <math.h>
#endif
-/* for ntohl and htonl */
-#if HAVE_ARPA_INET_H
-# include <arpa/inet.h>
-#endif
-
/* for getaddrinfo */
#include <sys/types.h>
#include <sys/socket.h>
# include <netinet/in.h>
#endif
+/* for ntohl and htonl */
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
#ifdef HAVE_LIBKSTAT
extern kstat_ctl_t *kc;
#endif
diff --git a/src/configfile.c b/src/configfile.c
index 33a7c200dbb3fc95d57e1b731c4e2397a2cbcd61..7c8347b15b20a1aa8d73011a1255105f5937035e 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
/**
* collectd - src/configfile.c
- * Copyright (C) 2005-2010 Florian octo Forster
+ * Copyright (C) 2005-2011 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
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
* Sebastian tokkee Harl <sh at tokkee.org>
**/
return (0);
} /* }}} int cf_util_get_flag */
-/* Assures that the config option is a string. The string is then converted to
- * a port number using `service_name_to_port_number' and returned. Returns the
- * port number in the range [1-65535] or less than zero upon failure. */
+/* Assures that the config option is a string or a number if the correct range
+ * of 1-65535. The string is then converted to a port number using
+ * `service_name_to_port_number' and returned.
+ * Returns the port number in the range [1-65535] or less than zero upon
+ * failure. */
int cf_util_get_port_number (const oconfig_item_t *ci) /* {{{ */
{
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ int tmp;
+
+ if ((ci->values_num != 1)
+ || ((ci->values[0].type != OCONFIG_TYPE_STRING)
+ && (ci->values[0].type != OCONFIG_TYPE_NUMBER)))
{
- ERROR ("cf_util_get_port_number: The %s option requires "
+ ERROR ("cf_util_get_port_number: The \"%s\" option requires "
"exactly one string argument.", ci->key);
return (-1);
}
- return (service_name_to_port_number (ci->values[0].value.string));
+ if (ci->values[0].type == OCONFIG_TYPE_STRING)
+ return (service_name_to_port_number (ci->values[0].value.string));
+
+ assert (ci->values[0].type == OCONFIG_TYPE_NUMBER);
+ tmp = (int) (ci->values[0].value.number + 0.5);
+ if ((tmp < 1) || (tmp > 65535))
+ {
+ ERROR ("cf_util_get_port_number: The \"%s\" option requires "
+ "a service name or a port number. The number "
+ "you specified, %i, is not in the valid "
+ "range of 1-65535.",
+ ci->key, tmp);
+ return (-1);
+ }
+
+ return (tmp);
} /* }}} int cf_util_get_port_number */
int cf_util_get_cdtime (const oconfig_item_t *ci, cdtime_t *ret_value) /* {{{ */
diff --git a/src/configfile.h b/src/configfile.h
index 65b1efcdd5a07d9a0d7fe7d50228470475bdb524..e63a0ea047533257bde40be867bc0394060a884f 100644 (file)
--- a/src/configfile.h
+++ b/src/configfile.h
#define CONFIGFILE_H
/**
* collectd - src/configfile.h
- * Copyright (C) 2005-2010 Florian octo Forster
+ * Copyright (C) 2005-2011 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
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
**/
#include "collectd.h"
int cf_util_get_flag (const oconfig_item_t *ci,
unsigned int *ret_value, unsigned int flag);
-/* Assures that the config option is a string. The string is then converted to
- * a port number using `service_name_to_port_number' and returned. Returns the
- * port number in the range [1-65535] or less than zero upon failure. */
+/* Assures that the config option is a string or a number if the correct range
+ * of 1-65535. The string is then converted to a port number using
+ * `service_name_to_port_number' and returned.
+ * Returns the port number in the range [1-65535] or less than zero upon
+ * failure. */
int cf_util_get_port_number (const oconfig_item_t *ci);
int cf_util_get_cdtime (const oconfig_item_t *ci, cdtime_t *ret_value);
diff --git a/src/mysql.c b/src/mysql.c
index f4ad01c685c48e0e6b123c0f49563558bf228081..cae6760b1d1f50f3d8cfe06413712112367722d0 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
/**
* collectd - src/mysql.c
- * Copyright (C) 2006-2009 Florian octo Forster
+ * Copyright (C) 2006-2010 Florian octo Forster
* Copyright (C) 2008 Mirko Buffoni
* Copyright (C) 2009 Doug MacEachern
* Copyright (C) 2009 Sebastian tokkee Harl
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
* Mirko Buffoni <briareos at eswat.org>
* Doug MacEachern <dougm at hyperic.com>
* Sebastian tokkee Harl <sh at tokkee.org>
diff --git a/src/plugin.c b/src/plugin.c
index 0f360c0f3eb5a0f952440483da19ec9ead4fd3fd..9ecee5cf26f5fd1b2d421d0d69a3f6476a0815b0 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
/**
* collectd - src/plugin.c
- * Copyright (C) 2005-2010 Florian octo Forster
+ * Copyright (C) 2005-2011 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
}
}
+ le = llist_search (read_list, rf->rf_name);
+ if (le != NULL)
+ {
+ pthread_mutex_unlock (&read_lock);
+ WARNING ("The read function \"%s\" is already registered. "
+ "Check for duplicate \"LoadPlugin\" lines "
+ "in your configuration!",
+ rf->rf_name);
+ return (EINVAL);
+ }
+
le = llentry_create (rf->rf_name, rf);
if (le == NULL)
{
int (*callback) (void))
{
read_func_t *rf;
+ int status;
- rf = (read_func_t *) malloc (sizeof (read_func_t));
+ rf = malloc (sizeof (*rf));
if (rf == NULL)
{
- char errbuf[1024];
- ERROR ("plugin_register_read: malloc failed: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
- return (-1);
+ ERROR ("plugin_register_read: malloc failed.");
+ return (ENOMEM);
}
memset (rf, 0, sizeof (read_func_t));
rf->rf_interval.tv_nsec = 0;
rf->rf_effective_interval = rf->rf_interval;
- return (plugin_insert_read (rf));
+ status = plugin_insert_read (rf);
+ if (status != 0)
+ sfree (rf);
+
+ return (status);
} /* int plugin_register_read */
int plugin_register_complex_read (const char *group, const char *name,
user_data_t *user_data)
{
read_func_t *rf;
+ int status;
- rf = (read_func_t *) malloc (sizeof (read_func_t));
+ rf = malloc (sizeof (*rf));
if (rf == NULL)
{
ERROR ("plugin_register_complex_read: malloc failed.");
- return (-1);
+ return (ENOMEM);
}
memset (rf, 0, sizeof (read_func_t));
rf->rf_udata = *user_data;
}
- return (plugin_insert_read (rf));
+ status = plugin_insert_read (rf);
+ if (status != 0)
+ sfree (rf);
+
+ return (status);
} /* int plugin_register_complex_read */
int plugin_register_write (const char *name,
diff --git a/src/plugin.h b/src/plugin.h
index 937eebed4e1cb24da6e18d3971566cbe3a8c18ff..4d5201b68d3bd0b532630a0cef3ed211c72a2fed 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
plugin_init_cb callback);
int plugin_register_read (const char *name,
int (*callback) (void));
+/* "user_data" will be freed automatically, unless
+ * "plugin_register_complex_read" returns an error (non-zero). */
int plugin_register_complex_read (const char *group, const char *name,
plugin_read_cb callback,
const struct timespec *interval,
diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index 7528406cc61a131e9fa276dcdacb1fe3345f23fc..a78e700f03a67962132bb9be8dd372dcb68144d5 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
#include "common.h"
#include "plugin.h"
-#include <arpa/inet.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
diff --git a/src/varnish.c b/src/varnish.c
index 6bf2db733e9028969f623d54aa1fd87bb23771f9..859df21766a18cdc0e2497e24b4bd9929a20eed0 100644 (file)
--- a/src/varnish.c
+++ b/src/varnish.c
@@ -307,9 +307,9 @@ static void varnish_monitor (const user_config_t *conf, struct varnish_stats *VS
/* outstanding allocations */
varnish_submit_gauge (conf->instance, "sm", "requests", "outstanding", VSL_stats->sm_nobj);
/* bytes allocated */
- varnish_submit_gauge (conf->instance, "sm", "bytes", "allocated", VSL_stats->sm_balloc);
+ varnish_submit_gauge (conf->instance, "sm", "total_bytes", "allocated", VSL_stats->sm_balloc);
/* bytes free */
- varnish_submit_gauge (conf->instance, "sm", "bytes", "free", VSL_stats->sm_bfree);
+ varnish_submit_gauge (conf->instance, "sm", "total_bytes", "free", VSL_stats->sm_bfree);
}
if (conf->collect_sma)
@@ -321,9 +321,9 @@ static void varnish_monitor (const user_config_t *conf, struct varnish_stats *VS
/* SMA outstanding bytes */
varnish_submit_gauge (conf->instance, "sma", "bytes", "outstanding", VSL_stats->sma_nbytes);
/* SMA bytes allocated */
- varnish_submit_gauge (conf->instance, "sma", "bytes", "allocated", VSL_stats->sma_balloc);
+ varnish_submit_gauge (conf->instance, "sma", "total_bytes", "allocated", VSL_stats->sma_balloc);
/* SMA bytes free */
- varnish_submit_gauge (conf->instance, "sma", "bytes", "free" , VSL_stats->sma_bfree);
+ varnish_submit_gauge (conf->instance, "sma", "total_bytes", "free" , VSL_stats->sma_bfree);
}
if (conf->collect_sms)
@@ -335,9 +335,9 @@ static void varnish_monitor (const user_config_t *conf, struct varnish_stats *VS
/* SMS outstanding bytes */
varnish_submit_gauge (conf->instance, "sms", "bytes", "outstanding", VSL_stats->sms_nbytes);
/* SMS bytes allocated */
- varnish_submit_gauge (conf->instance, "sms", "bytes", "allocated", VSL_stats->sms_balloc);
+ varnish_submit_gauge (conf->instance, "sms", "total_bytes", "allocated", VSL_stats->sms_balloc);
/* SMS bytes freed */
- varnish_submit_gauge (conf->instance, "sms", "bytes", "free", VSL_stats->sms_bfree);
+ varnish_submit_gauge (conf->instance, "sms", "total_bytes", "free", VSL_stats->sms_bfree);
}
if (conf->collect_totals)