3 @@ -704,6 +704,9 @@ AC_CHECK_HEADERS(net/pfvar.h,
5 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
7 +# For the iwinfo plugin
8 +AC_CHECK_LIB(iwinfo, iwinfo_backend, [with_iwinfo="yes"], [with_iwinfo="no (libiwinfo not found)"], [])
10 # For the turbostat plugin
11 have_asm_msrindex_h="no"
12 AC_CHECK_HEADERS(asm/msr-index.h, [have_asm_msrindex_h="yes"])
13 @@ -5310,6 +5313,7 @@ plugin_interface="no"
19 plugin_log_logstash="no"
21 @@ -5713,6 +5717,7 @@ AC_PLUGIN([ipmi], [$plugin_ipmi],
22 AC_PLUGIN([iptables], [$with_libiptc], [IPTables rule counters])
23 AC_PLUGIN([ipvs], [$plugin_ipvs], [IPVS connection statistics])
24 AC_PLUGIN([irq], [$plugin_irq], [IRQ statistics])
25 +AC_PLUGIN([iwinfo], [$with_iwinfo], [Common iwinfo wireless statistics])
26 AC_PLUGIN([java], [$with_java], [Embed the Java Virtual Machine])
27 AC_PLUGIN([load], [$plugin_load], [System load])
28 AC_PLUGIN([logfile], [yes], [File logging plugin])
29 @@ -6042,6 +6047,7 @@ Configuration:
30 oracle . . . . . . . $with_oracle
31 protobuf-c . . . . . $have_protoc_c
32 python . . . . . . . $with_python
33 + iwinfo . . . . . . . $with_iwinfo
36 daemon mode . . . . . $enable_daemon
37 @@ -6091,6 +6097,7 @@ Configuration:
38 iptables . . . . . . $enable_iptables
39 ipvs . . . . . . . . $enable_ipvs
40 irq . . . . . . . . . $enable_irq
41 + iwinfo . . . . . . . $enable_iwinfo
42 java . . . . . . . . $enable_java
43 load . . . . . . . . $enable_load
44 logfile . . . . . . . $enable_logfile
45 --- a/src/collectd.conf.in
46 +++ b/src/collectd.conf.in
48 #@BUILD_PLUGIN_IPTABLES_TRUE@LoadPlugin iptables
49 #@BUILD_PLUGIN_IPVS_TRUE@LoadPlugin ipvs
50 #@BUILD_PLUGIN_IRQ_TRUE@LoadPlugin irq
51 +#@BUILD_PLUGIN_IWINFO_TRUE@LoadPlugin iwinfo
52 #@BUILD_PLUGIN_JAVA_TRUE@LoadPlugin java
53 @BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load
54 #@BUILD_PLUGIN_LPAR_TRUE@LoadPlugin lpar
66 # JVMArg "-verbose:jni"
67 # JVMArg "-Djava.class.path=@prefix@/share/collectd/java/collectd-api.jar"
68 --- a/src/collectd.conf.pod
69 +++ b/src/collectd.conf.pod
70 @@ -2606,6 +2606,27 @@ and all other interrupts are collected.
74 +=head2 Plugin C<iwinfo>
78 +=item B<Interface> I<Interface>
80 +Select this interface. By default all detected wireless interfaces will be
81 +collected. For a more detailed description see B<IgnoreSelected> below.
83 +=item B<IgnoreSelected> I<true>|I<false>
85 +If no configuration if given, the B<iwinfo>-plugin will collect data from all
86 +detected wireless interfaces. You can use the B<Interface>-option to pick the
87 +interfaces you're interested in. Sometimes, however, it's easier/preferred to
88 +collect all interfaces I<except> a few ones. This option enables you to do
89 +that: By setting B<IgnoreSelected> to I<true> the effect of B<Interface> is
90 +inverted: All selected interfaces are ignored and all other interfaces are
97 The I<Java> plugin makes it possible to write extensions for collectd in Java.
102 + * collectd - src/iwinfo.c
103 + * Copyright (C) 2011 Jo-Philipp Wich
105 + * This program is free software; you can redistribute it and/or modify it
106 + * under the terms of the GNU General Public License as published by the
107 + * Free Software Foundation; only version 2 of the License is applicable.
109 + * This program is distributed in the hope that it will be useful, but
110 + * WITHOUT ANY WARRANTY; without even the implied warranty of
111 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
112 + * General Public License for more details.
114 + * You should have received a copy of the GNU General Public License along
115 + * with this program; if not, write to the Free Software Foundation, Inc.,
116 + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
119 +#include "collectd.h"
122 +#include "utils_ignorelist.h"
127 +#define PROCNETDEV "/proc/net/dev"
129 +static const char *config_keys[] = {
133 +static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
135 +static ignorelist_t *ignorelist = NULL;
137 +static int iwinfo_config(const char *key, const char *value)
139 + if (ignorelist == NULL)
140 + ignorelist = ignorelist_create(1);
142 + if (ignorelist == NULL)
145 + if (strcasecmp(key, "Interface") == 0)
146 + ignorelist_add(ignorelist, value);
147 + else if (strcasecmp(key, "IgnoreSelected") == 0)
148 + ignorelist_set_invert(ignorelist, IS_TRUE(value) ? 0 : 1);
155 +static void iwinfo_submit(const char *ifname, const char *type, int value)
158 + value_list_t vl = VALUE_LIST_INIT;
160 + values[0].gauge = value;
162 + vl.values = values;
165 + sstrncpy(vl.host, hostname_g, sizeof(vl.host));
166 + sstrncpy(vl.plugin, "iwinfo", sizeof(vl.plugin));
167 + sstrncpy(vl.plugin_instance, ifname, sizeof(vl.plugin_instance));
168 + sstrncpy(vl.type, type, sizeof(vl.type));
169 + /*sstrncpy(vl.type_instance, "", sizeof(vl.type_instance));*/
171 + plugin_dispatch_values(&vl);
174 +static void iwinfo_process(const char *ifname)
177 + char buf[IWINFO_BUFSIZE];
178 + const struct iwinfo_ops *iw = iwinfo_backend(ifname);
180 + /* does appear to be a wifi iface */
183 + if (iw->bitrate(ifname, &val))
185 + iwinfo_submit(ifname, "bitrate", val * 1000);
187 + if (iw->signal(ifname, &val))
189 + iwinfo_submit(ifname, "signal_power", val);
191 + if (iw->noise(ifname, &val))
193 + iwinfo_submit(ifname, "signal_noise", val);
195 + if (iw->quality(ifname, &val))
197 + iwinfo_submit(ifname, "signal_quality", val);
199 + if (iw->assoclist(ifname, buf, &val))
201 + iwinfo_submit(ifname, "stations",
202 + val / sizeof(struct iwinfo_assoclist_entry));
208 +static int iwinfo_read(void)
214 + f = fopen(PROCNETDEV, "r");
218 + WARNING("iwinfo: Unable to open " PROCNETDEV ": %s",
219 + sstrerror(errno, err, sizeof(err)));
223 + while (fgets(line, sizeof(line), f))
225 + if (!strchr(line, ':'))
228 + if (!sscanf(line, " %127[^:]", ifname))
231 + if (ignorelist_match(ignorelist, ifname))
234 + if (strstr(ifname, "mon.") || strstr(ifname, ".sta") ||
235 + strstr(ifname, "tmp.") || strstr(ifname, "wifi"))
238 + iwinfo_process(ifname);
246 +void module_register(void)
248 + plugin_register_config("iwinfo", iwinfo_config, config_keys, config_keys_num);
249 + plugin_register_read("iwinfo", iwinfo_read);
251 --- a/src/Makefile.am
252 +++ b/src/Makefile.am
253 @@ -457,6 +457,13 @@ irq_la_SOURCES = irq.c
254 irq_la_LDFLAGS = $(PLUGIN_LDFLAGS)
257 +if BUILD_PLUGIN_IWINFO
258 +pkglib_LTLIBRARIES += iwinfo.la
259 +iwinfo_la_SOURCES = iwinfo.c
260 +iwinfo_la_LDFLAGS = -module -avoid-version
261 +iwinfo_la_LIBADD = -liwinfo
265 pkglib_LTLIBRARIES += java.la
266 java_la_SOURCES = java.c
269 @@ -228,6 +228,7 @@ voltage value:GAUGE:U:U
270 vs_memory value:GAUGE:0:9223372036854775807
271 vs_processes value:GAUGE:0:65535
272 vs_threads value:GAUGE:0:65535
273 +stations value:GAUGE:0:256