From: Florian Forster Date: Thu, 14 Jun 2007 16:16:17 +0000 (+0200) Subject: xmms plugin: Added a plugin to graph bitrate and frequencies or files played by XMMS. X-Git-Tag: collectd-4.1.0~51 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=558a6a1c9ad4917d29ad3a3a70cad40983500c22;p=collectd.git xmms plugin: Added a plugin to graph bitrate and frequencies or files played by XMMS. Of course, this is not the most useful plugin ever.. ;) --- diff --git a/configure.in b/configure.in index 0b8299dd..ff5bcd58 100644 --- a/configure.in +++ b/configure.in @@ -1273,6 +1273,74 @@ then 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 # @@ -1384,6 +1452,7 @@ AC_COLLECTD([unixsock], [disable], [module], [UNIX socket plugin]) 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) @@ -1413,6 +1482,7 @@ Configuration: libsensors . . . . $with_lm_sensors libstatgrab . . . . $with_libstatgrab libupsclient . . . $with_libupsclient + libxmms . . . . . . $with_libxmms Features: daemon mode . . . . $enable_daemon @@ -1459,5 +1529,6 @@ Configuration: users . . . . . . . $enable_users vserver . . . . . . $enable_vserver wireless . . . . . $enable_wireless + xmms . . . . . . . $enable_xmms EOF diff --git a/src/Makefile.am b/src/Makefile.am index 6642aa0f..31b11ab3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -561,6 +561,20 @@ collectd_LDADD += "-dlopen" wireless.la 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 68b966b8..e1932059 100644 --- a/src/types.db +++ b/src/types.db @@ -2,6 +2,7 @@ apache_bytes count:COUNTER:0:134217728 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 new file mode 100644 index 00000000..238a8ee3 --- /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 + **/ + +#include "collectd.h" +#include "plugin.h" +#include "common.h" + +#include + +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 + */