1 /**
2 * collectd - src/xmms.c
3 * Copyright (C) 2007 Florian octo Forster
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * Authors:
19 * Florian octo Forster <octo at verplant.org>
20 **/
22 #include "collectd.h"
23 #include "plugin.h"
24 #include "common.h"
26 #include <xmms/xmmsctrl.h>
28 static gint xmms_session;
30 static void cxmms_submit (const char *type, gauge_t value)
31 {
32 value_t values[1];
33 value_list_t vl = VALUE_LIST_INIT;
35 values[0].gauge = value;
37 vl.values = values;
38 vl.values_len = 1;
39 sstrncpy (vl.host, hostname_g, sizeof (vl.host));
40 sstrncpy (vl.plugin, "xmms", sizeof (vl.plugin));
41 sstrncpy (vl.type, type, sizeof (vl.type));
43 plugin_dispatch_values (&vl);
44 } /* void cxmms_submit */
46 int cxmms_read (void)
47 {
48 gint rate;
49 gint freq;
50 gint nch;
52 if (!xmms_remote_is_running (xmms_session))
53 return (0);
55 xmms_remote_get_info (xmms_session, &rate, &freq, &nch);
57 if ((freq == 0) || (nch == 0))
58 return (-1);
60 cxmms_submit ("bitrate", rate);
61 cxmms_submit ("frequency", freq);
63 return (0);
64 } /* int read */
66 void module_register (void)
67 {
68 plugin_register_read ("xmms", cxmms_read);
69 } /* void module_register */
71 /*
72 * vim: shiftwidth=2:softtabstop=2:textwidth=78
73 */