summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c02ba63)
raw | patch | inline | side by side (parent: c02ba63)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 14 Jun 2007 16:16:17 +0000 (18:16 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 14 Jun 2007 16:20:25 +0000 (18:20 +0200) |
Of course, this is not the most useful plugin ever.. ;)
configure.in | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/types.db | patch | blob | history | |
src/xmms.c | [new file with mode: 0644] | patch | blob |
diff --git a/configure.in b/configure.in
index 0b8299dd7f72d69094057364cd8d399cbc0016f1..ff5bcd586fc8592fefe2667c4f36fc16ba1234fb 100644 (file)
--- a/configure.in
+++ b/configure.in
fi
AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
+### BEGIN of check for libxmms ###
+with_xmms_config="xmms-config"
+with_xmms_prefix=0
+with_xmms_cflags=""
+with_xmms_libs=""
+AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
+[
+ if test "x$withval" != "xno" -a "x$withval" != "xyes"
+ then
+ if test -x "$withval/bin/xmms-config"
+ then
+ with_xmms_config="$withval/bin/xmms-config"
+ with_xmms_prefix=1
+ fi
+ fi
+ if test "x$withval" = "xno"
+ then
+ with_libxmms="no"
+ else
+ with_libxmms="yes"
+ fi
+],
+[
+ with_libxmms="yes"
+])
+if test "x$with_libxmms" = "xyes"
+then
+ with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
+ xmms_config_status=$?
+
+ if test $xmms_config_status -ne 0
+ then
+ with_libxmms="no"
+ fi
+fi
+if test "x$with_libxmms" = "xyes"
+then
+ with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
+ xmms_config_status=$?
+
+ if test $xmms_config_status -ne 0
+ then
+ with_libxmms="no"
+ fi
+fi
+if test "x$with_libxmms" = "xyes"
+then
+ AC_CHECK_LIB(xmms, xmms_remote_get_info,
+ [
+ BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
+ BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
+ AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
+ AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
+ ],
+ [
+ with_libxmms="no"
+ ],
+ [$with_xmms_libs])
+fi
+with_libxmms_numeric=0
+if test "x$with_libxmms" = "xyes"
+then
+ with_libxmms_numeric=1
+fi
+AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
+AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
+### END of check for libxmms ###
+
# Check for enabled/disabled features
#
AC_COLLECTD([users], [disable], [module], [user count statistics])
AC_COLLECTD([vserver], [disable], [module], [vserver statistics])
AC_COLLECTD([wireless], [disable], [module], [wireless link statistics])
+AC_COLLECTD([xmms], [disable], [module], [wireless link statistics])
AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile)
libsensors . . . . $with_lm_sensors
libstatgrab . . . . $with_libstatgrab
libupsclient . . . $with_libupsclient
+ libxmms . . . . . . $with_libxmms
Features:
daemon mode . . . . $enable_daemon
users . . . . . . . $enable_users
vserver . . . . . . $enable_vserver
wireless . . . . . $enable_wireless
+ xmms . . . . . . . $enable_xmms
EOF
diff --git a/src/Makefile.am b/src/Makefile.am
index 6642aa0f1979f6ade72436d06e8dce2df8f165b8..31b11ab388c8e8926f92af7e47b55ae94034ff0d 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
collectd_DEPENDENCIES += wireless.la
endif
+if BUILD_MODULE_XMMS
+pkglib_LTLIBRARIES += xmms.la
+xmms_la_SOURCES = xmms.c
+xmms_la_CFLAGS =
+xmms_la_LDFLAGS = -module -avoid-version
+if BUILD_WITH_LIBXMMS
+xmms_la_CFLAGS += $(BUILD_WITH_LIBXMMS_CFLAGS)
+xmms_la_LDFLAGS += $(BUILD_WITH_LIBXMMS_LIBS)
+endif
+collectd_LDADD += "-dlopen" xmms.la
+collectd_DEPENDENCIES += xmms.la
+endif
+
+
dist_man_MANS = collectd.1 collectd-nagios.1 collectd.conf.5 \
collectd-email.5 collectd-exec.5 collectd-perl.5 \
collectd-snmp.5 collectd-unixsock.5
diff --git a/src/types.db b/src/types.db
index 68b966b83bcb2291115a9d58e9da24189530fffa..e1932059945fa516025283ec18024763ff123023 100644 (file)
--- a/src/types.db
+++ b/src/types.db
apache_connections count:GAUGE:0:65535
apache_requests count:COUNTER:0:134217728
apache_scoreboard count:GAUGE:0:65535
+bitrate value:GAUGE:0:4294967295
charge value:GAUGE:0:U
counter value:COUNTER:U:U
cpu value:COUNTER:0:4294967295
diff --git a/src/xmms.c b/src/xmms.c
--- /dev/null
+++ b/src/xmms.c
@@ -0,0 +1,73 @@
+/**
+ * collectd - src/xmms.c
+ * Copyright (C) 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; 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors:
+ * Florian octo Forster <octo at verplant.org>
+ **/
+
+#include "collectd.h"
+#include "plugin.h"
+#include "common.h"
+
+#include <xmms/xmmsctrl.h>
+
+static gint xmms_session;
+
+static void cxmms_submit (const char *type, gauge_t value)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].gauge = value;
+
+ vl.values = values;
+ vl.values_len = 1;
+ vl.time = time (NULL);
+ strcpy (vl.host, hostname_g);
+ strcpy (vl.plugin, "xmms");
+
+ plugin_dispatch_values (type, &vl);
+} /* void cxmms_submit */
+
+int cxmms_read (void)
+{
+ gint rate;
+ gint freq;
+ gint nch;
+
+ if (!xmms_remote_is_running (xmms_session))
+ return (0);
+
+ xmms_remote_get_info (xmms_session, &rate, &freq, &nch);
+
+ if ((freq == 0) || (nch == 0))
+ return (0);
+
+ cxmms_submit ("bitrate", rate);
+ cxmms_submit ("frequency", freq);
+
+ return (0);
+} /* int read */
+
+void module_register (void)
+{
+ plugin_register_read ("xmms", cxmms_read);
+} /* void module_register */
+
+/*
+ * vim: shiftwidth=2:softtabstop=2:textwidth=78
+ */