[packages] collectd: add iwinfo plugin, similar to wireless but compatible to madwifi and mac80211 drivers
git-svn-id: svn://svn.openwrt.org/openwrt/packages@29404 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
5ec8b71aa9
commit
9824569a5f
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=collectd
|
||||
PKG_VERSION:=4.10.2
|
||||
PKG_RELEASE:=3
|
||||
PKG_RELEASE:=4
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=http://collectd.org/files/
|
||||
@ -80,6 +80,7 @@ COLLECTD_PLUGINS_SELECTED:= \
|
||||
interface \
|
||||
iptables \
|
||||
irq \
|
||||
iwinfo \
|
||||
load \
|
||||
logfile \
|
||||
madwifi \
|
||||
@ -140,6 +141,8 @@ define Package/collectd/description
|
||||
and provides mechanismns to store the values in a variety of ways.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib
|
||||
|
||||
ifneq ($(CONFIG_avr32),)
|
||||
TARGET_CFLAGS += -fsigned-char
|
||||
endif
|
||||
@ -270,6 +273,7 @@ $(eval $(call BuildPlugin,fscache,file-system based caching framework input,fsca
|
||||
$(eval $(call BuildPlugin,interface,network interfaces input,interface,))
|
||||
$(eval $(call BuildPlugin,iptables,iptables status input,iptables,+PACKAGE_collectd-mod-iptables:iptables))
|
||||
$(eval $(call BuildPlugin,irq,interrupt usage input,irq,))
|
||||
$(eval $(call BuildPlugin,iwinfo,libiwinfo wireless statistics,iwinfo,+PACKAGE_collectd-mod-iwinfo:libiwinfo))
|
||||
$(eval $(call BuildPlugin,load,system load input,load,))
|
||||
$(eval $(call BuildPlugin,logfile,log files output,logfile,))
|
||||
$(eval $(call BuildPlugin,madwifi,MadWifi status input,madwifi,))
|
||||
|
274
utils/collectd/patches/900-add-iwinfo-plugin.patch
Normal file
274
utils/collectd/patches/900-add-iwinfo-plugin.patch
Normal file
@ -0,0 +1,274 @@
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -471,6 +471,9 @@ AC_CHECK_HEADERS(netinet/if_ether.h, [],
|
||||
have_termios_h="no"
|
||||
AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
|
||||
|
||||
+# For the iwinfo plugin
|
||||
+AC_CHECK_LIB(iwinfo, iwinfo_backend, [with_iwinfo="yes"], [with_iwinfo="no (libiwinfo not found)"], [])
|
||||
+
|
||||
#
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
#
|
||||
@@ -3985,6 +3988,7 @@ plugin_interface="no"
|
||||
plugin_ipmi="no"
|
||||
plugin_ipvs="no"
|
||||
plugin_irq="no"
|
||||
+plugin_iwinfo="no"
|
||||
plugin_libvirt="no"
|
||||
plugin_load="no"
|
||||
plugin_memory="no"
|
||||
@@ -4292,6 +4296,7 @@ AC_PLUGIN([ipmi], [$plugin_ipmi],
|
||||
AC_PLUGIN([iptables], [$with_libiptc], [IPTables rule counters])
|
||||
AC_PLUGIN([ipvs], [$plugin_ipvs], [IPVS connection statistics])
|
||||
AC_PLUGIN([irq], [$plugin_irq], [IRQ statistics])
|
||||
+AC_PLUGIN([iwinfo], [$with_iwinfo], [Common iwinfo wireless statistics])
|
||||
AC_PLUGIN([java], [$with_java], [Embed the Java Virtual Machine])
|
||||
AC_PLUGIN([libvirt], [$plugin_libvirt], [Virtual machine statistics])
|
||||
AC_PLUGIN([load], [$plugin_load], [System load])
|
||||
@@ -4570,6 +4575,7 @@ Configuration:
|
||||
protobuf-c . . . . . $have_protoc_c
|
||||
oracle . . . . . . . $with_oracle
|
||||
python . . . . . . . $with_python
|
||||
+ iwinfo . . . . . . . $with_iwinfo
|
||||
|
||||
Features:
|
||||
daemon mode . . . . . $enable_daemon
|
||||
@@ -4609,6 +4615,7 @@ Configuration:
|
||||
iptables . . . . . . $enable_iptables
|
||||
ipvs . . . . . . . . $enable_ipvs
|
||||
irq . . . . . . . . . $enable_irq
|
||||
+ iwinfo . . . . . . . $enable_iwinfo
|
||||
java . . . . . . . . $enable_java
|
||||
libvirt . . . . . . . $enable_libvirt
|
||||
load . . . . . . . . $enable_load
|
||||
--- a/src/collectd.conf.in
|
||||
+++ b/src/collectd.conf.in
|
||||
@@ -82,6 +82,7 @@ FQDNLookup true
|
||||
#@BUILD_PLUGIN_IPMI_TRUE@LoadPlugin ipmi
|
||||
#@BUILD_PLUGIN_IPVS_TRUE@LoadPlugin ipvs
|
||||
#@BUILD_PLUGIN_IRQ_TRUE@LoadPlugin irq
|
||||
+#@BUILD_PLUGIN_IWINFO_TRUE@LoadPlugin iwinfo
|
||||
#@BUILD_PLUGIN_JAVA_TRUE@LoadPlugin java
|
||||
#@BUILD_PLUGIN_LIBVIRT_TRUE@LoadPlugin libvirt
|
||||
@BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load
|
||||
@@ -372,6 +373,12 @@ FQDNLookup true
|
||||
# IgnoreSelected true
|
||||
#</Plugin>
|
||||
|
||||
+#<Plugin iwinfo>
|
||||
+# Interface "ath0"
|
||||
+# Interface "ra0"
|
||||
+# Interface "wlan0"
|
||||
+#</Plugin>
|
||||
+
|
||||
#<Plugin "java">
|
||||
# JVMArg "-verbose:jni"
|
||||
# JVMArg "-Djava.class.path=@prefix@/share/collectd/java/collectd-api.jar"
|
||||
--- a/src/collectd.conf.pod
|
||||
+++ b/src/collectd.conf.pod
|
||||
@@ -1468,6 +1468,27 @@ and all other interrupts are collected.
|
||||
|
||||
=back
|
||||
|
||||
+=head2 Plugin C<iwinfo>
|
||||
+
|
||||
+=over 4
|
||||
+
|
||||
+=item B<Interface> I<Interface>
|
||||
+
|
||||
+Select this interface. By default all detected wireless interfaces will be
|
||||
+collected. For a more detailed description see B<IgnoreSelected> below.
|
||||
+
|
||||
+=item B<IgnoreSelected> I<true>|I<false>
|
||||
+
|
||||
+If no configuration if given, the B<iwinfo>-plugin will collect data from all
|
||||
+detected wireless interfaces. You can use the B<Interface>-option to pick the
|
||||
+interfaces you're interested in. Sometimes, however, it's easier/preferred to
|
||||
+collect all interfaces I<except> a few ones. This option enables you to do
|
||||
+that: By setting B<IgnoreSelected> to I<true> the effect of B<Interface> is
|
||||
+inverted: All selected interfaces are ignored and all other interfaces are
|
||||
+collected.
|
||||
+
|
||||
+=back
|
||||
+
|
||||
=head2 Plugin C<java>
|
||||
|
||||
The I<Java> plugin makes it possible to write extensions for collectd in Java.
|
||||
--- /dev/null
|
||||
+++ b/src/iwinfo.c
|
||||
@@ -0,0 +1,149 @@
|
||||
+/**
|
||||
+ * collectd - src/iwinfo.c
|
||||
+ * Copyright (C) 2011 Jo-Philipp Wich
|
||||
+ *
|
||||
+ * 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
|
||||
+ **/
|
||||
+
|
||||
+#include "collectd.h"
|
||||
+#include "common.h"
|
||||
+#include "plugin.h"
|
||||
+#include "utils_ignorelist.h"
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+#include <iwinfo.h>
|
||||
+
|
||||
+#define PROCNETDEV "/proc/net/dev"
|
||||
+
|
||||
+static const char *config_keys[] = {
|
||||
+ "Interface",
|
||||
+ "IgnoreSelected"
|
||||
+};
|
||||
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
|
||||
+
|
||||
+static ignorelist_t *ignorelist = NULL;
|
||||
+
|
||||
+static int iwinfo_config(const char *key, const char *value)
|
||||
+{
|
||||
+ if (ignorelist == NULL)
|
||||
+ ignorelist = ignorelist_create(1);
|
||||
+
|
||||
+ if (ignorelist == NULL)
|
||||
+ return 1;
|
||||
+
|
||||
+ if (strcasecmp(key, "Interface") == 0)
|
||||
+ ignorelist_add(ignorelist, value);
|
||||
+ else if (strcasecmp(key, "IgnoreSelected") == 0)
|
||||
+ ignorelist_set_invert(ignorelist, IS_TRUE(value) ? 0 : 1);
|
||||
+ else
|
||||
+ return -1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void iwinfo_submit(const char *ifname, const char *type, int value)
|
||||
+{
|
||||
+ value_t values[1];
|
||||
+ value_list_t vl = VALUE_LIST_INIT;
|
||||
+
|
||||
+ values[0].gauge = value;
|
||||
+
|
||||
+ vl.values = values;
|
||||
+ vl.values_len = 1;
|
||||
+
|
||||
+ sstrncpy(vl.host, hostname_g, sizeof(vl.host));
|
||||
+ sstrncpy(vl.plugin, "iwinfo", sizeof(vl.plugin));
|
||||
+ sstrncpy(vl.plugin_instance, ifname, sizeof(vl.plugin_instance));
|
||||
+ sstrncpy(vl.type, type, sizeof(vl.type));
|
||||
+ /*sstrncpy(vl.type_instance, "", sizeof(vl.type_instance));*/
|
||||
+
|
||||
+ plugin_dispatch_values(&vl);
|
||||
+}
|
||||
+
|
||||
+static void iwinfo_process(const char *ifname)
|
||||
+{
|
||||
+ int val;
|
||||
+ char buf[IWINFO_BUFSIZE];
|
||||
+ const struct iwinfo_ops *iw = iwinfo_backend(ifname);
|
||||
+
|
||||
+ /* does appear to be a wifi iface */
|
||||
+ if (iw)
|
||||
+ {
|
||||
+ if (iw->bitrate(ifname, &val))
|
||||
+ val = 0;
|
||||
+ iwinfo_submit(ifname, "bitrate", val * 1000);
|
||||
+
|
||||
+ if (iw->signal(ifname, &val))
|
||||
+ val = 0;
|
||||
+ iwinfo_submit(ifname, "signal_power", val);
|
||||
+
|
||||
+ if (iw->noise(ifname, &val))
|
||||
+ val = 0;
|
||||
+ iwinfo_submit(ifname, "signal_noise", val);
|
||||
+
|
||||
+ if (iw->quality(ifname, &val))
|
||||
+ val = 0;
|
||||
+ iwinfo_submit(ifname, "signal_quality", val);
|
||||
+
|
||||
+ if (iw->assoclist(ifname, buf, &val))
|
||||
+ val = 0;
|
||||
+ iwinfo_submit(ifname, "stations", val);
|
||||
+ }
|
||||
+
|
||||
+ iwinfo_finish();
|
||||
+}
|
||||
+
|
||||
+static int iwinfo_read(void)
|
||||
+{
|
||||
+ char line[1024];
|
||||
+ char ifname[128];
|
||||
+ FILE *f;
|
||||
+
|
||||
+ f = fopen(PROCNETDEV, "r");
|
||||
+ if (f == NULL)
|
||||
+ {
|
||||
+ char err[1024];
|
||||
+ WARNING("iwinfo: Unable to open " PROCNETDEV ": %s",
|
||||
+ sstrerror(errno, err, sizeof(err)));
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ while (fgets(line, sizeof(line), f))
|
||||
+ {
|
||||
+ if (!strchr(line, ':'))
|
||||
+ continue;
|
||||
+
|
||||
+ if (!sscanf(line, " %127[^:]", ifname))
|
||||
+ continue;
|
||||
+
|
||||
+ if (ignorelist_match(ignorelist, ifname))
|
||||
+ continue;
|
||||
+
|
||||
+ if (strstr(ifname, "mon.") || strstr(ifname, ".sta") ||
|
||||
+ strstr(ifname, "wmaster") || strstr(ifname, "wifi"))
|
||||
+ continue;
|
||||
+
|
||||
+ iwinfo_process(ifname);
|
||||
+ }
|
||||
+
|
||||
+ fclose(f);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void module_register(void)
|
||||
+{
|
||||
+ plugin_register_config("iwinfo", iwinfo_config, config_keys, config_keys_num);
|
||||
+ plugin_register_read("iwinfo", iwinfo_read);
|
||||
+}
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -452,6 +452,15 @@ collectd_LDADD += "-dlopen" irq.la
|
||||
collectd_DEPENDENCIES += irq.la
|
||||
endif
|
||||
|
||||
+if BUILD_PLUGIN_IWINFO
|
||||
+pkglib_LTLIBRARIES += iwinfo.la
|
||||
+iwinfo_la_SOURCES = iwinfo.c
|
||||
+iwinfo_la_LDFLAGS = -module -avoid-version
|
||||
+iwinfo_la_LIBADD = -liwinfo
|
||||
+collectd_LDADD += "-dlopen" iwinfo.la
|
||||
+collectd_DEPENDENCIES += iwinfo.la
|
||||
+endif
|
||||
+
|
||||
if BUILD_PLUGIN_JAVA
|
||||
pkglib_LTLIBRARIES += java.la
|
||||
java_la_SOURCES = java.c
|
||||
--- a/src/types.db
|
||||
+++ b/src/types.db
|
||||
@@ -171,3 +171,4 @@ voltage value:GAUGE:U:U
|
||||
vs_memory value:GAUGE:0:9223372036854775807
|
||||
vs_processes value:GAUGE:0:65535
|
||||
vs_threads value:GAUGE:0:65535
|
||||
+stations value:GAUGE:0:256
|
Loading…
x
Reference in New Issue
Block a user