Merge branch 'pr/1970'
authorFlorian Forster <octo@collectd.org>
Thu, 6 Oct 2016 20:41:24 +0000 (22:41 +0200)
committerFlorian Forster <octo@collectd.org>
Thu, 6 Oct 2016 20:41:24 +0000 (22:41 +0200)
CONTRIBUTING.md
README
contrib/redhat/collectd.spec
docs/BUILD.dpdkstat.md [new file with mode: 0644]
docs/BUILD.java.md [new file with mode: 0644]
src/collectd.conf.in
src/collectd.conf.pod
src/grpc.cc
src/memcached.c

index f247566..791446a 100644 (file)
@@ -35,7 +35,7 @@ the mailing list have a tendency to fall through the cracks.
     coding style of the code around your changes.
 *   *Documentation:* New config options need to be documented in two places: the
     manpage (`src/collectd.conf.pod`) and the example config
-    (`src/collectd.conf.in`).
+    (`src/collectd.conf.in`). New plugins need to be added to the `README` file.
 *   *Continuous integration:* Once your PR is created, our continuous
     integration environment will try to build it on a number of platforms. If
     this reports a failure, please investigate and fix the problem. We will at
diff --git a/README b/README
index 9b8e5d4..0989312 100644 (file)
--- a/README
+++ b/README
@@ -96,8 +96,9 @@ Features
       DNS traffic: Query types, response codes, opcodes and traffic/octets
       transferred.
 
-    - dpdk
+    - dpdkstat
       Collect DPDK interface statistics.
+      See docs/BUILD.dpdkstat.md for detailed build instructions.
 
     - drbd
       Collect individual drbd resource statistics.
@@ -131,9 +132,6 @@ Features
     - gps
       Monitor gps related data through gpsd.
 
-    - grpc
-      Send and receive values over the network using the gRPC framework.
-
     - hddtemp
       Hard disk temperatures using hddtempd.
 
@@ -176,7 +174,8 @@ Features
 
     - java
       Integrates a `Java Virtual Machine' (JVM) to execute plugins in Java
-      bytecode. See “Configuring with libjvm” below.
+      bytecode.
+      See docs/BUILD.java.md for detailed build instructions.
 
     - load
       System load average over the last 1, 5 and 15 minutes.
@@ -199,14 +198,14 @@ Features
       Queries very detailed usage statistics from wireless LAN adapters and
       interfaces that use the Atheros chipset and the MadWifi driver.
 
-    - mbmon
-      Motherboard sensors: temperature, fan speed and voltage information,
-      using mbmon(1).
-
     - md
       Linux software-RAID device information (number of active, failed, spare
       and missing disks).
 
+    - mbmon
+      Motherboard sensors: temperature, fan speed and voltage information,
+      using mbmon(1).
+
     - memcachec
       Query and parse data from a memcache daemon (memcached).
 
@@ -226,9 +225,6 @@ Features
       Reads values from Modbus/TCP enabled devices. Supports reading values
       from multiple "slaves" so gateway devices can be used.
 
-    - mqtt
-      Publishes and subscribes to MQTT topics.
-
     - multimeter
       Information provided by serial multimeters, such as the `Metex
       M-4650CR'.
@@ -407,7 +403,7 @@ Features
       CPU, memory, disk and network I/O statistics from virtual machines.
 
     - vmem
-      Virtual memory statistics, e. g. the number of page-ins/-outs or the
+      Virtual memory statistics, e.g. the number of page-ins/-outs or the
       number of pagefaults.
 
     - vserver
@@ -445,10 +441,16 @@ Features
       diskspace but is extremely portable and can be analysed with almost
       every program that can analyse anything. Even Microsoft's Excel..
 
+    - grpc
+      Send and receive values over the network using the gRPC framework.
+
     - lua
       It's possible to implement write plugins in Lua using the Lua
       plugin. See collectd-lua(5) for details.
 
+    - mqtt
+      Publishes and subscribes to MQTT topics.
+
     - network
       Send the data to a remote host to save the data somehow. This is useful
       for large setups where the data should be saved by a dedicated machine.
@@ -668,12 +670,22 @@ Prerequisites
 
   * Usual suspects: C compiler, linker, preprocessor, make, ...
 
+    collectd makes use of some common C99 features, e.g. compound literals and
+    mixed declarations, and therefore requires a C99 compatible compiler.
+
+    On Debian and Ubuntu, the "build-essential" package should pull in
+    everything that's necessary.
+
   * A POSIX-threads (pthread) implementation.
     Since gathering some statistics is slow (network connections, slow devices,
     etc) collectd is parallelized. The POSIX threads interface is being
     used and should be found in various implementations for hopefully all
     platforms.
 
+  * When building from the Git repository, flex (tokenizer) and bison (parser
+    generator) are required. Release tarballs include the generated files – you
+    don't need these packages in that case.
+
   * aerotools-ng (optional)
     Used by the `aquaero' plugin. Currently, the `libaquaero5' library, which
     is used by the `aerotools-ng' toolkit, is not compiled as a shared object
@@ -748,8 +760,8 @@ Prerequisites
 
   * libjvm (optional)
     Library that encapsulates the `Java Virtual Machine' (JVM). This library is
-    used by the `java' plugin to execute Java bytecode. See “Configuring with
-    libjvm” below.
+    used by the `java' plugin to execute Java bytecode.
+    See docs/BUILD.java.md for detailed build instructions.
     <http://openjdk.java.net/> (and others)
 
   * libldap (optional)
@@ -948,44 +960,6 @@ Configuring / Compiling / Installing
   prefixed to all installation directories. This might be useful when creating
   packages for collectd.
 
-Configuring with libjvm
------------------------
-
-  To determine the location of the required files of a Java installation is not
-  an easy task, because the locations vary with your kernel (Linux, SunOS, …)
-  and with your architecture (x86, SPARC, …) and there is no ‘java-config’
-  script we could use. Configuration of the JVM library is therefore a bit
-  tricky.
-
-  The easiest way to use the `--with-java=$JAVA_HOME' option, where
-  `$JAVA_HOME' is usually something like:
-    /usr/lib/jvm/java-1.5.0-sun-1.5.0.14
-
-  The configure script will then use find(1) to look for the following files:
-
-    - jni.h
-    - jni_md.h
-    - libjvm.so
-
-  If found, appropriate CPP-flags and LD-flags are set and the following
-  library checks succeed.
-
-  If this doesn't work for you, you have the possibility to specify CPP-flags,
-  C-flags, LD-flags and LIBS for the ‘Java’ plugin by hand, using the
-  following environment variables:
-
-    - JAVA_CPPFLAGS
-    - JAVA_CFLAGS
-    - JAVA_LDFLAGS
-    - JAVA_LIBS
-
-  For example (shortened for demonstration purposes):
-
-    ./configure JAVA_CPPFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
-
-  Adding "-ljvm" to JAVA_LIBS is done automatically, you don't have to
-  do that.
-
 Generating the configure script
 -------------------------------
 
@@ -1004,6 +978,7 @@ To generate the `configure` script, you'll need the following dependencies:
 
 The `build.sh' script takes no arguments.
 
+
 Crosscompiling
 --------------
 
@@ -1034,147 +1009,16 @@ Crosscompiling
     * `endianflip' (12345678 -> 87654321)
     * `intswap'    (12345678 -> 56781234)
 
-Configuring with DPDK
----------------------
-
-Note: DPDK 16.04 is the minimum version and currently supported version of DPDK
-required for the dpdkstat plugin. This is to allow the plugin to take advantage
-of functions added to detect if the DPDK primary process is alive.
-
-Note: For Ubuntu, GCC 4.9 is the minimum version required to build collectd
-with DPDK. Ubuntu 14.04, for example, has GCC 4.8 by default and will require
-an upgrade:
-  $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
-  $ sudo apt-get update
-  $ sudo apt-get install gcc-4.9
-Alternatively, if you know that the platform that you wish to run collectd
-on supports the SSSE3 instruction set, you can run make as follows:
-  $ make -j CFLAGS+='-mssse3'
-
-Build DPDK for use with collectd:
-  To compile DPDK for use with collectd dpdkstat start by:
-    - Clone DPDK:
-      $ git clone git://dpdk.org/dpdk
-    - Checkout the system requirements at
-      http://dpdk.org/doc/guides/linux_gsg/sys_reqs.html and make sure you have
-      the required tools and hugepage setup as specified there.
-      NOTE: It's recommended to use the 1GB hugepage setup for best performance,
-            please follow the instruction for "Reserving Hugepages for DPDK Use"
-            in the link above.
-      However if you plan on configuring 2MB hugepages on the fly please ensure
-      to add appropriate commands to reserve hugepages in a system startup script
-      if collectd is booted at system startup time. These commands include:
-          mkdir -p /mnt/huge
-          mount -t hugetlbfs nodev /mnt/huge
-          echo 64 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
-    - To configure the DPDK build for the combined shared library modify
-      config/common_base in your DPDK as follows
-        #
-        # Compile to share library
-        #
-        -CONFIG_RTE_BUILD_SHARED_LIB=n
-        +CONFIG_RTE_BUILD_SHARED_LIB=y
-    - Prepare the configuration for the appropriate target as specified at:
-      http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html.
-      For example:
-          $ make config T=x86_64-native-linuxapp-gcc
-    - Build the target:
-          $ make
-    - Install DPDK to /usr
-          $ sudo make install prefix=/usr
-      NOTE 1: You must run make install as the configuration of collectd with
-            DPDK expects DPDK to be installed somewhere.
-      NOTE 2: If you don't specify a prefix then DPDK will be installed in /usr/local/
-      NOTE 3: If you are not root then use sudo to make install DPDK to the appropriate
-            location.
-    - Check that the DPDK library has been installed in /usr/lib or /lib
-          $ ls /usr/lib | grep dpdk
-    - Bind the interfaces to use with dpdkstat to DPDK:
-      DPDK devices can be setup with either the VFIO (for DPDK 1.7+) or UIO modules.
-      Note: UIO requires inserting an out of tree driver igb_uio.ko that is available
-      in DPDK.
-      UIO Setup:
-      - Insert uio.ko:
-           $ sudo modprobe uio
-      - Insert igb_uio.ko:
-           $ sudo insmod $DPDK_BUILD/kmod/igb_uio.ko
-      - Bind network device to igb_uio:
-           $ sudo $DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1
-      VFIO Setup:
-      - VFIO needs to be supported in the kernel and the BIOS. More information can be found
-        @ http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html.
-      - Insert the `vfio-pci.ko' module: modprobe vfio-pci
-      - Set the correct permissions for the vfio device:
-           $ sudo /usr/bin/chmod a+x /dev/vfio
-           $ sudo /usr/bin/chmod 0666 /dev/vfio/*
-     - Bind the network device to vfio-pci:
-           $ sudo $DPDK_DIR/tools/dpdk_nic_bind.py --bind=vfio-pci eth1
-       NOTE: Please ensure to add appropriate commands to bind the network
-             interfaces to DPDK in a system startup script if collectd is
-             booted at system startup time.
-     - Run ldconfig to update the shared library cache.
-
-  Build static DPDK library for use with collectd:
-     - To configure DPDK to build the combined static library libdpdk.a
-       ensure that CONFIG_RTE_BUILD_SHARED_LIB is set to n in
-       config/common_base in your DPDK as follows:
-       #
-       # Compile to share library
-       #
-       CONFIG_RTE_BUILD_SHARED_LIB=n
-     - Prepare the configuration for the appropriate target as specified at:
-       http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html.
-       For example:
-          $ make config T=x86_64-native-linuxapp-gcc
-     - Build the target using -fPIC:
-          $ make EXTRA_CFLAGS=-fPIC -j
-     - Install DPDK to /usr
-          $ sudo make install prefix=/usr
-
-Configure collectd with DPDK:
-NOTE: The Address-Space Layout Randomization (ASLR) security feature in Linux should
-       be disabled, in order for the same hugepage memory mappings to be present in all
-       DPDK multi-process applications. Note that this has security implications.
-       To disable ASLR:
-               $ echo 0 > /proc/sys/kernel/randomize_va_space
-       To fully enable ASLR:
-               $ echo 2 > /proc/sys/kernel/randomize_va_space
-       See http://dpdk.org/doc/guides/prog_guide/multi_proc_support.html
-
-    - Generate the build script as specified below. (i.e. run `build.sh').
-    - Configure collectd with the DPDK shared library:
-       ./configure --with-libdpdk=/usr
-      NOTE: To configure collectd with the DPDK static library:
-       ./configure --with-libdpdk=/usr CFLAGS=" -lpthread -Wl,--whole-archive
-        -Wl,-ldpdk -Wl,-lm -Wl,-lrt -Wl,-lpcap -Wl,-ldl -Wl,--no-whole-archive"
-
-       Libraries:
-       ...
-       libdpdk  . . . . . . . . yes
-
-       Modules:
-       ...
-       dpdkstat . . . . . . .yes
-
-
-    - Make sure that dpdk and dpdkstat are enabled in the configuration log:
-
-    - Build collectd:
-          $ make -j && make -j install.
-      NOTE: As mentioned above, if you are building on Ubuntu 14.04 with GCC <= 4.8.X,
-        you need to use:
-          $  make -j CFLAGS+='-mssse3' && make -j install
-
-Usage of dpdkstat:
-    - The same PCI device configuration should be passed to the primary process
-      as the secondary process uses the same port indexes as the primary.
-      NOTE: A blacklist/whitelist of NICs isn't supported yet.
 
 Contact
 -------
 
-  For questions, bug reports, development information and basically all other
-  concerns please send an email to collectd's mailing list at
+  Please use GitHub to report bugs and submit pull requests:
+  <https://github.com/collectd/collectd/>.
+  See CONTRIBUTING.md for details.
+
+  For questions, development information and basically all other concerns please
+  send an email to collectd's mailing list at
   <list at collectd.org>.
 
   For live discussion and more personal contact visit us in IRC, we're in
@@ -1188,5 +1032,3 @@ Author
   Sebastian tokkee Harl <sh at tokkee.org>,
   and many contributors (see `AUTHORS').
 
-  Please use GitHub reporting bugs and submitting pull requests.
-  See CONTRIBUTING.md for details.
index 73e69c7..07a0bab 100644 (file)
 %define with_barometer 0%{!?_without_barometer:0}
 # plugin grpc disabled, requires protobuf-compiler >= 3.0
 %define with_grpc 0%{!?_without_grpc:0}
+# plugin dpdkstat disabled, requires libdpdk
+%define with_dpdkstat 0%{!?_without_dpdkstat:0}
 # plugin lpar disabled, requires AIX
 %define with_lpar 0%{!?_without_lpar:0}
 # plugin mic disabled, requires Mic
@@ -1069,6 +1071,12 @@ Collectd utilities
 %define _with_drbd --disable-drbd
 %endif
 
+%if %{with_dpdkstat}
+%define _with_dpdkstat --enable-dpdkstat
+%else
+%define _with_dpdkstat --disable-dpdkstat
+%endif
+
 %if %{with_email}
 %define _with_email --enable-email
 %else
@@ -1758,6 +1766,7 @@ Collectd utilities
        %{?_with_disk} \
        %{?_with_dns} \
        %{?_with_drbd} \
+       %{?_with_dpdkstat} \
        %{?_with_email} \
        %{?_with_entropy} \
        %{?_with_ethstat} \
@@ -2035,6 +2044,9 @@ fi
 %if %{with_drbd}
 %{_libdir}/%{name}/drbd.so
 %endif
+%if %{with_dpdkstat}
+%{_libdir}/%{name}/dpdkstat.so
+%endif
 %if %{with_ethstat}
 %{_libdir}/%{name}/ethstat.so
 %endif
@@ -2526,6 +2538,7 @@ fi
 * Tue Aug 23 2016 Marc Fournier <marc.fournier@camptocamp.com> - 5.7.0-1
 - New PRE-RELEASE version
 - New plugins enabled by default: hugepages
+- New plugins disabled by default: dpdkstat
 
 * Sun Aug 14 2016 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.6.0-1
 - New PRE-RELEASE version
diff --git a/docs/BUILD.dpdkstat.md b/docs/BUILD.dpdkstat.md
new file mode 100644 (file)
index 0000000..b502edd
--- /dev/null
@@ -0,0 +1,230 @@
+# The dpdkstat plugin
+
+**Data Plane Development Kit** (DPDK) is a set of drivers and libraries for fast
+packet processing.
+
+## Summary
+
+The *dpdkstat plugin* has the following requirements:
+
+ * DPDK 16.04 or later
+ * GCC 4.9 or later
+
+You can also build with GCC 4.8 (e.g. Ubuntu 14.04) if you specify the SSSE3
+instruction set manually:
+
+    make -j CFLAGS+='-mssse3'
+
+## Building DPDK
+
+ *  Setup the build environment:
+
+    Ensure that you have GCC 4.9 or later. Ubuntu 14.04, for example, has GCC
+    4.8 by default and requires an upgrade:
+
+        add-apt-repository ppa:ubuntu-toolchain-r/test
+        apt-get update
+        apt-get install gcc-4.9
+
+    If you know that the platform that you wish to run collectd on supports the
+    SSSE3 instruction set, GCC 4.8 also works if you enable SSSE3 manually:
+
+        make -j CFLAGS+='-mssse3'
+
+ *  Clone DPDK:
+
+        git clone git://dpdk.org/dpdk
+
+ *  Checkout the [DPDK system
+    requirements](http://dpdk.org/doc/guides/linux_gsg/sys_reqs.html) and make
+    sure you have the required tools and hugepage setup as specified there.
+
+    **Note:** It's recommended to use the 1GB hugepage setup for best
+    performance, please follow the instruction for "Reserving Hugepages for DPDK
+    Use" in the link above.
+
+    However if you plan on configuring 2MB hugepages on the fly please ensure to
+    add appropriate commands to reserve hugepages in a system startup script if
+    collectd is booted at system startup time. These commands include:
+
+        mkdir -p /mnt/huge
+        mount -t hugetlbfs nodev /mnt/huge
+        echo 64 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
+
+ *  To configure the DPDK build for the combined shared library modify
+    `config/common_base` in your DPDK as follows
+
+        #
+        # Compile to share library
+        #
+        -CONFIG_RTE_BUILD_SHARED_LIB=n
+        +CONFIG_RTE_BUILD_SHARED_LIB=y
+
+ *  Prepare the configuration for the appropriate target as specified at:
+    http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html.
+
+    For example:
+
+        make config T=x86_64-native-linuxapp-gcc
+
+ *  Build the target:
+
+        make
+
+ *  Install DPDK to `/usr`
+
+        sudo make install prefix=/usr
+
+    **Note 1:** You must run make install as the configuration of collectd with
+    DPDK expects DPDK to be installed somewhere.
+
+    **Note 2:** If you don't specify a prefix then DPDK will be installed in
+    `/usr/local/`.
+
+    **Note 3:** If you are not root then use sudo to make install DPDK to the
+    appropriate location.
+
+ *  Check that the DPDK library has been installed in `/usr/lib` or `/lib`:
+
+        ls /usr/lib | grep dpdk
+
+ *  Bind the interfaces to use with dpdkstat to DPDK:
+
+    DPDK devices can be setup with either the VFIO (for DPDK 1.7+) or UIO
+    modules.
+
+    **Note:** UIO requires inserting an out of tree driver `igb_uio.ko` that is
+    available in DPDK.
+
+    **UIO Setup:**
+
+     *  Insert `uio.ko`:
+
+            sudo modprobe uio
+
+     *  Insert `igb_uio.ko`:
+
+            sudo insmod $DPDK_BUILD/kmod/igb_uio.ko
+
+     *  Bind network device to `igb_uio`:
+
+            sudo $DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1
+
+    **VFIO Setup:**
+
+     *  VFIO needs to be supported in the kernel and the BIOS. More information
+        can be found at: http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html.
+     *  Insert the `vfio-pci.ko` module:
+
+            modprobe vfio-pci
+
+     *  Set the correct permissions for the VFIO device:
+
+            sudo /usr/bin/chmod a+x /dev/vfio
+            sudo /usr/bin/chmod 0666 /dev/vfio/*
+
+     *  Bind the network device to `vfio-pci`:
+
+            sudo $DPDK_DIR/tools/dpdk_nic_bind.py --bind=vfio-pci eth1
+
+        **Note:** Please ensure to add appropriate commands to bind the network
+        interfaces to DPDK in a system startup script if collectd is booted at
+        system startup time.
+
+     *  Run `ldconfig` to update the shared library cache.
+
+### Static library
+
+To build static DPDK library for use with collectd:
+
+ *  To configure DPDK to build the combined static library `libdpdk.a` ensure
+    that `CONFIG_RTE_BUILD_SHARED_LIB` is set to “n” in `config/common_base` in
+    your DPDK as follows:
+
+        #
+        # Compile to share library
+        #
+        CONFIG_RTE_BUILD_SHARED_LIB=n
+
+ *  Prepare the configuration for the appropriate target as specified at:
+    http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html.
+
+    For example:
+
+        make config T=x86_64-native-linuxapp-gcc
+
+ *  Build the target using `-fPIC`:
+
+        make EXTRA_CFLAGS=-fPIC -j
+
+ *  Install DPDK to `/usr`:
+
+        sudo make install prefix=/usr
+
+## Build collectd with DPDK
+
+**Note:** DPDK 16.04 is the minimum version and currently supported version of
+DPDK required for the dpdkstat plugin. This is to allow the plugin to take
+advantage of functions added to detect if the DPDK primary process is alive.
+
+
+**Note:** The *Address-Space Layout Randomization* (ASLR) security feature in
+Linux should be disabled, in order for the same hugepage memory mappings to be
+present in all DPDK multi-process applications. Note that this has security
+implications.
+
+ *  To disable ASLR:
+
+        echo 0 > /proc/sys/kernel/randomize_va_space
+
+ *  To fully enable ASLR:
+
+        echo 2 > /proc/sys/kernel/randomize_va_space
+
+See also: http://dpdk.org/doc/guides/prog_guide/multi_proc_support.html
+
+ *  Generate the build script as specified below. (i.e. run `build.sh`).
+ *  Configure collectd with the DPDK shared library:
+
+        ./configure --with-libdpdk=/usr
+
+### Build with the static DPDK library
+
+To configure collectd with the DPDK static library:
+
+ *  Run *configure* with the following CFLAGS:
+
+        ./configure --with-libdpdk=/usr CFLAGS=" -lpthread -Wl,--whole-archive -Wl,-ldpdk -Wl,-lm -Wl,-lrt -Wl,-lpcap -Wl,-ldl -Wl,--no-whole-archive"
+
+ *  Make sure that dpdk and dpdkstat are enabled in the *configure* output.
+
+    Expected output:
+
+        Libraries:
+        ...
+        libdpdk  . . . . . . . . yes
+        
+        Modules:
+        ...
+        dpdkstat . . . . . . .yes
+
+ *  Build collectd:
+
+        make -j && make -j install.
+
+    **Note:** As mentioned above, if you are building on Ubuntu 14.04 with
+    GCC <= 4.8.X, you need to use:
+
+        make -j CFLAGS+='-mssse3' && make -j install
+
+## Caveats
+
+ *  The same PCI device configuration should be passed to the primary process as
+    the secondary process uses the same port indexes as the primary.
+ *  A blacklist / whitelist of NICs isn't supported yet.
+
+## License
+
+The *dpdkstat plugin* is copyright (c) 2016 *Intel Corporation* and licensed
+under the *MIT license*. Full licensing terms can be found in the file
+`COPYING`.
diff --git a/docs/BUILD.java.md b/docs/BUILD.java.md
new file mode 100644 (file)
index 0000000..2f4c0c2
--- /dev/null
@@ -0,0 +1,50 @@
+# Building with Java
+
+This file gives some background and hints how the *java plugin* needs to be
+configured.
+
+## Dependencies
+
+The *java plugin* requires a version of Java with *Java Native Interface* (JNI)
+**1.2** or later.
+
+## Configure and flags
+
+To determine the location of the required files of a Java installation is not an
+easy task, because the locations vary with your kernel (Linux, SunOS, …) and
+with your architecture (x86, SPARC, …) and there is no `java-config` script we
+could use. Configuration of the JVM library is therefore a bit tricky.
+
+The easiest way to use the `--with-java="${JAVA_HOME}"` option, where
+`JAVA_HOME` is usually something like:
+
+    /usr/lib/jvm/java-1.5.0-sun-1.5.0.14
+
+The configure script will then use *find(1)* to look for the following files:
+
+ *  `jni.h`
+ *  `jni_md.h`
+ *  `libjvm.so`
+
+If found, appropriate CPP-flags and LD-flags are set and the following library
+checks succeed.
+
+If this doesn't work for you, you have the possibility to specify CPP-flags,
+C-flags, LD-flags and LIBS for the *java plugin* by hand, using the following
+environment variables:
+
+ *  `JAVA_CPPFLAGS`
+ *  `JAVA_CFLAGS`
+ *  `JAVA_LDFLAGS`
+ *  `JAVA_LIBS`
+
+For example (shortened for demonstration purposes):
+
+    ./configure JAVA_CPPFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
+
+Adding `-ljvm` to JAVA_LIBS is done automatically, you don't have to do that.
+
+## License
+
+The *java plugin* is licensed under the *GNU General Public License, version 2*.
+Full licensing terms can be found in the file `COPYING`.
index f81d771..ae29951 100644 (file)
 
 #<Plugin memcached>
 #      <Instance "local">
-#              Host "127.0.0.1"
+#              #Host "memcache.example.com"
+#              Address "127.0.0.1"
 #              Port "11211"
 #      </Instance>
 #</Plugin>
index 36a6d00..9f9dd93 100644 (file)
@@ -3395,11 +3395,12 @@ interpreted. For a description of match blocks, please see L<"Plugin tail">.
 
 The B<memcached plugin> connects to a memcached server and queries statistics
 about cache utilization, memory and bandwidth used.
-L<http://www.danga.com/memcached/>
+L<http://memcached.org/>
 
  <Plugin "memcached">
    <Instance "name">
-     Host "memcache.example.com"
+     #Host "memcache.example.com"
+     Address "127.0.0.1"
      Port 11211
    </Instance>
  </Plugin>
@@ -3412,16 +3413,25 @@ following options are allowed:
 
 =item B<Host> I<Hostname>
 
-Hostname to connect to. Defaults to B<127.0.0.1>.
+Sets the B<host> field of dispatched values. Defaults to the global hostname
+setting.
+For backwards compatibility, values are also dispatched with the global
+hostname when B<Host> is set to B<127.0.0.1> or B<localhost> and B<Address> is
+not set.
+
+=item B<Address> I<Address>
+
+Hostname or IP to connect to. For backwards compatibility, defaults to the
+value of B<Host> or B<127.0.0.1> if B<Host> is unset.
 
 =item B<Port> I<Port>
 
-TCP-Port to connect to. Defaults to B<11211>.
+TCP port to connect to. Defaults to B<11211>.
 
 =item B<Socket> I<Path>
 
 Connect to I<memcached> using the UNIX domain socket at I<Path>. If this
-setting is given, the B<Host> and B<Port> settings are ignored.
+setting is given, the B<Address> and B<Port> settings are ignored.
 
 =back
 
index 15e2593..0ae80bb 100644 (file)
@@ -291,7 +291,7 @@ public:
                PutValuesRequest req;
 
                while (reader->Read(&req)) {
-                       value_list_t vl = VALUE_LIST_INIT;
+                       value_list_t vl = {0};
                        auto status = unmarshal_value_list(req.value_list(), &vl);
                        if (!status.ok())
                                return status;
index bd83b46..765a0fd 100644 (file)
 struct memcached_s
 {
   char *name;
-  char *socket;
   char *host;
-  char *port;
+  char *socket;
+  char *connhost;
+  char *connport;
 };
 typedef struct memcached_s memcached_t;
 
@@ -59,9 +60,10 @@ static void memcached_free (void *arg)
     return;
 
   sfree (st->name);
-  sfree (st->socket);
   sfree (st->host);
-  sfree (st->port);
+  sfree (st->socket);
+  sfree (st->connhost);
+  sfree (st->connport);
   sfree (st);
 }
 
@@ -98,29 +100,23 @@ static int memcached_connect_unix (memcached_t *st)
 
 static int memcached_connect_inet (memcached_t *st)
 {
-  const char *host;
-  const char *port;
-
   struct addrinfo *ai_list;
   int status;
   int fd = -1;
 
-  host = (st->host != NULL) ? st->host : MEMCACHED_DEF_HOST;
-  port = (st->port != NULL) ? st->port : MEMCACHED_DEF_PORT;
-
   struct addrinfo ai_hints = {
     .ai_family = AF_UNSPEC,
     .ai_flags = AI_ADDRCONFIG,
     .ai_socktype = SOCK_STREAM
   };
 
-  status = getaddrinfo (host, port, &ai_hints, &ai_list);
+  status = getaddrinfo (st->connhost, st->connport, &ai_hints, &ai_list);
   if (status != 0)
   {
     char errbuf[1024];
     ERROR ("memcached plugin: memcached_connect_inet: "
         "getaddrinfo(%s,%s) failed: %s",
-        host, port,
+        st->connhost, st->connport,
         (status == EAI_SYSTEM)
         ? sstrerror (errno, errbuf, sizeof (errbuf))
         : gai_strerror (status));
@@ -239,22 +235,10 @@ static int memcached_query_daemon (char *buffer, size_t buffer_size, memcached_t
 
 static void memcached_init_vl (value_list_t *vl, memcached_t const *st)
 {
-  char const *host = st->host;
-
-  /* Keep default hostname, if:
-   * - Legacy mode is used.
-   * - "Socket" option is given (doc: "Host option is ignored").
-   * - "Host" option is not provided.
-   * - "Host" option is set to "localhost" or "127.0.0.1". */
-  if ((strcmp (st->name, "__legacy__") != 0)
-      && (st->socket == NULL)
-      && (st->host != NULL)
-      && (strcmp ("127.0.0.1", st->host) != 0)
-      && (strcmp ("localhost", st->host) != 0))
-    sstrncpy (vl->host, host, sizeof (vl->host));
-
   sstrncpy (vl->plugin, "memcached", sizeof (vl->plugin));
-  if (strcmp (st->name, "__legacy__") != 0)
+  if (st->host != NULL)
+    sstrncpy (vl->host, st->host, sizeof (vl->host));
+  if (st->name != NULL)
     sstrncpy (vl->plugin_instance, st->name, sizeof (vl->plugin_instance));
 }
 
@@ -544,8 +528,49 @@ static int memcached_add_read_callback (memcached_t *st)
   char callback_name[3*DATA_MAX_NAME_LEN];
   int status;
 
-  assert (st->name != NULL);
-  ssnprintf (callback_name, sizeof (callback_name), "memcached/%s", st->name);
+  ssnprintf (callback_name, sizeof (callback_name), "memcached/%s",
+      (st->name != NULL) ? st->name : "__legacy__");
+
+  /* If no <Address> used then:
+   * - Connect to the destination specified by <Host>, if present.
+   *   If not, use the default address.
+   * - Use the default hostname (set st->host to NULL), if
+   *    - Legacy mode is used (no configuration options at all), or
+   *    - "Host" option is not provided, or
+   *    - "Host" option is set to "localhost" or "127.0.0.1".
+   *
+   * If <Address> used then host may be set to "localhost" or "127.0.0.1"
+   * explicitly.
+   */
+  if (st->connhost == NULL)
+  {
+    if (st->host)
+    {
+      st->connhost = strdup(st->host);
+      if (st->connhost == NULL)
+        return (ENOMEM);
+
+      if ((strcmp ("127.0.0.1", st->host) == 0)
+          || (strcmp ("localhost", st->host) == 0))
+        sfree(st->host);
+    }
+    else
+    {
+      st->connhost = strdup(MEMCACHED_DEF_HOST);
+      if (st->connhost == NULL)
+        return (ENOMEM);
+    }
+  }
+
+  if (st->connport == NULL)
+  {
+      st->connport = strdup(MEMCACHED_DEF_PORT);
+      if (st->connport == NULL)
+        return (ENOMEM);
+  }
+
+  assert (st->connhost != NULL);
+  assert (st->connport != NULL);
 
   status = plugin_register_complex_read (/* group = */ "memcached",
       /* name      = */ callback_name,
@@ -563,6 +588,7 @@ static int memcached_add_read_callback (memcached_t *st)
  * <Plugin memcached>
  *   <Instance "instance_name">
  *     Host foo.zomg.com
+ *     Address 1.2.3.4
  *     Port "1234"
  *   </Instance>
  * </Plugin>
@@ -579,24 +605,23 @@ static int config_add_instance(oconfig_item_t *ci)
   if (st == NULL)
   {
     ERROR ("memcached plugin: calloc failed.");
-    return (-1);
+    return (ENOMEM);
   }
 
   st->name = NULL;
-  st->socket = NULL;
   st->host = NULL;
-  st->port = NULL;
+  st->socket = NULL;
+  st->connhost = NULL;
+  st->connport = NULL;
 
-  if (strcasecmp (ci->key, "Plugin") == 0) /* default instance */
-    st->name = sstrdup ("__legacy__");
-  else /* <Instance /> block */
+  if (strcasecmp (ci->key, "Instance") == 0)
     status = cf_util_get_string (ci, &st->name);
+
   if (status != 0)
   {
     sfree (st);
     return (status);
   }
-  assert (st->name != NULL);
 
   for (int i = 0; i < ci->children_num; i++)
   {
@@ -606,8 +631,10 @@ static int config_add_instance(oconfig_item_t *ci)
       status = cf_util_get_string (child, &st->socket);
     else if (strcasecmp ("Host", child->key) == 0)
       status = cf_util_get_string (child, &st->host);
+    else if (strcasecmp ("Address", child->key) == 0)
+      status = cf_util_get_string (child, &st->connhost);
     else if (strcasecmp ("Port", child->key) == 0)
-      status = cf_util_get_service (child, &st->port);
+      status = cf_util_get_service (child, &st->connport);
     else
     {
       WARNING ("memcached plugin: Option `%s' not allowed here.",
@@ -674,10 +701,11 @@ static int memcached_init (void)
   st = calloc (1, sizeof (*st));
   if (st == NULL)
     return (ENOMEM);
-  st->name = sstrdup ("__legacy__");
-  st->socket = NULL;
+  st->name = NULL;
   st->host = NULL;
-  st->port = NULL;
+  st->socket = NULL;
+  st->connhost = NULL;
+  st->connport = NULL;
 
   status = memcached_add_read_callback (st);
   if (status == 0)