summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ced8c21)
raw | patch | inline | side by side (parent: ced8c21)
author | Paul Sadauskas <psadauskas@gmail.com> | |
Sat, 20 Jun 2009 20:50:36 +0000 (14:50 -0600) | ||
committer | Florian Forster <sifnfors@informatik.stud.uni-erlangen.de> | |
Mon, 6 Jul 2009 14:39:31 +0000 (16:39 +0200) |
* Separate Host and Port in config, report Host as hostname, and Port as
plugin instance.
* Submit before closing connection.
* Else-case in config, in case of invalid config params.
* Flounder around at using pkg-config in configure.in
* Remove forward declarations.
* Include plugin in config summary.
plugin instance.
* Submit before closing connection.
* Else-case in config, in case of invalid config params.
* Flounder around at using pkg-config in configure.in
* Remove forward declarations.
* Include plugin in config summary.
configure.in | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/tokyotyrant.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index e9aca547689bf5bd6be9eef83a412c5f115d45c2..ec84d5b149967dbd4efbe71768d9aa20888df459 100644 (file)
--- a/configure.in
+++ b/configure.in
AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
# --with-libtokyotyrant {{{
+with_libtokyotyrant_cflags=""
with_libtokyotyrant_libs=""
AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
[
@@ -1113,8 +1114,8 @@ AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>
if test "x$with_libtokyotyrant" = "xyes"
then
- #with_libtokyotyrant_libs="-ltokyotyrant"
- with_libtokyotyrant_libs="-ltokyotyrant -ltokyocabinet"
+ with_libtokyotyrant_cflags="`$PKG_CONFIG --cflags tokyotyrant`"
+ with_libtokyotyrant_libs="`$PKG_CONFIG --libs tokyotyrant`"
BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
tcpconns . . . . . . $enable_tcpconns
teamspeak2 . . . . . $enable_teamspeak2
ted . . . . . . . . . $enable_ted
+ tokyotyrant . . . . . $enable_tokyotyrant
thermal . . . . . . . $enable_thermal
unixsock . . . . . . $enable_unixsock
uptime . . . . . . . $enable_uptime
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 704918e260a47650d553968fb97d6048737bb4c5..54afd0f2b086a5a307d9b5cedce1c5e69124964d 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#</Plugin>
#<Plugin tokyotyrant>
-# Host "localhost:1978"
+# Host "localhost"
+# Port 1978
#</Plugin>
#<Plugin unixsock>
diff --git a/src/tokyotyrant.c b/src/tokyotyrant.c
index 5260619d295d1b979057fb8c02db89ceb9c1c290..73a065e14330811102f669b31831edf0a52a9224 100644 (file)
--- a/src/tokyotyrant.c
+++ b/src/tokyotyrant.c
static const char *config_keys[] =
{
- "Host"
+ "Host",
+ "Port"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static char *host = NULL;
-static int tt_config (const char *key, const char *value);
-static int tt_read (void);
-static void tt_submit(gauge_t rnum, const char *type);
-
-void module_register (void)
-{
- plugin_register_config("tokyotyrant", tt_config, config_keys, config_keys_num);
- plugin_register_read("tokyotyrant", tt_read);
-}
+/* int is for opening connection, string is for plugin_instance */
+static char *port_str = NULL;
+static int port;
static int tt_config (const char *key, const char *value)
{
-
- if (strcasecmp ("Host", key) == 0)
- {
- if (host != NULL)
- free (host);
- host = strdup(value);
- }
- return (0);
+ if (strcasecmp ("Host", key) == 0)
+ {
+ if (host != NULL)
+ free (host);
+ host = strdup(value);
+ }
+ else if (strcasecmp ("Port", key) == 0)
+ {
+ if (port_str != NULL)
+ free (port_str);
+ port_str = strdup(value);
+
+ port = atoi(value);
+
+ if ((port < 0) || (port > 65535))
+ {
+ ERROR ("tokyotyrant plugin: error: Port %s out of range", value);
+ return (-1);
+ }
+ }
+ else
+ {
+ ERROR ("tokyotyrant plugin: error: unrecognized configuration key %s", key);
+ return (-1);
+ }
+
+ return (0);
}
static void printerr(TCRDB *rdb)
{
- int ecode = tcrdbecode(rdb);
- ERROR ("tokyotyrant plugin: error: %d, %s", ecode, tcrdberrmsg(ecode));
-}
-
-static int tt_read (void) {
- gauge_t rnum, size;
-
- TCRDB *rdb = tcrdbnew();
-
- if (!tcrdbopen2(rdb, host))
- {
- printerr (rdb);
- tcrdbdel (rdb);
- return (1);
- }
-
- rnum = tcrdbrnum(rdb);
- size = tcrdbsize(rdb);
-
- if (!tcrdbclose(rdb))
- {
- printerr (rdb);
- tcrdbdel (rdb);
- return (1);
- }
- tt_submit (rnum, "records");
- tt_submit (size, "file_size");
-
- return (0);
+ int ecode = tcrdbecode(rdb);
+ ERROR ("tokyotyrant plugin: error: %d, %s",
+ ecode, tcrdberrmsg(ecode));
}
static void tt_submit (gauge_t val, const char* type)
{
- value_t values[1];
- value_list_t vl = VALUE_LIST_INIT;
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = val;
+ values[0].gauge = val;
- vl.values = values;
- vl.values_len = STATIC_ARRAY_SIZE (values);
+ vl.values = values;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
- sstrncpy (vl.plugin, "tokyotyrant", sizeof (vl.plugin));
- sstrncpy (vl.plugin_instance, host, sizeof (vl.plugin_instance));
- sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.host, host, sizeof (vl.host));
+ sstrncpy (vl.plugin, "tokyotyrant", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, port_str,
+ sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (&vl);
+ plugin_dispatch_values (&vl);
}
+
+static int tt_read (void) {
+ gauge_t rnum, size;
+
+ TCRDB *rdb = tcrdbnew();
+
+ if (!tcrdbopen(rdb, host, port))
+ {
+ printerr (rdb);
+ tcrdbdel (rdb);
+ return (1);
+ }
+
+ rnum = tcrdbrnum(rdb);
+ size = tcrdbsize(rdb);
+ tt_submit (rnum, "records");
+ tt_submit (size, "file_size");
+
+ if (!tcrdbclose(rdb))
+ {
+ printerr (rdb);
+ tcrdbdel (rdb);
+ return (1);
+ }
+
+ return (0);
+}
+
+void module_register (void)
+{
+ plugin_register_config("tokyotyrant", tt_config,
+ config_keys, config_keys_num);
+ plugin_register_read("tokyotyrant", tt_read);
+}
+
+/* vim: set sw=8 ts=8 tw=78 : */