Merge remote-tracking branch 'github/pr/1749'
authorFlorian Forster <octo@collectd.org>
Fri, 14 Oct 2016 20:51:04 +0000 (22:51 +0200)
committerFlorian Forster <octo@collectd.org>
Fri, 14 Oct 2016 20:51:04 +0000 (22:51 +0200)
123 files changed:
CONTRIBUTING.md
ChangeLog
README
configure.ac
contrib/SpamAssassin/Collectd.pm
contrib/examples/myplugin.c
contrib/redhat/collectd.spec
docs/BUILD.dpdkstat.md [new file with mode: 0644]
docs/BUILD.java.md [new file with mode: 0644]
src/Makefile.am
src/apache.c
src/apcups.c
src/apple_sensors.c
src/aquaero.c
src/ascent.c
src/barometer.c
src/battery.c
src/battery_statefs.c
src/bind.c
src/ceph.c
src/cgroups.c
src/chrony.c
src/collectd-snmp.pod
src/collectd.conf.in
src/collectd.conf.pod
src/conntrack.c
src/contextswitch.c
src/cpu.c
src/cpufreq.c
src/cpusleep.c
src/curl.c
src/daemon/collectd.c
src/daemon/common.c
src/daemon/plugin.c
src/daemon/plugin.h
src/daemon/utils_cache.h
src/daemon/utils_tail_match.c
src/df.c
src/disk.c
src/dns.c
src/dpdkstat.c
src/drbd.c
src/email.c
src/entropy.c
src/ethstat.c
src/exec.c
src/fhcount.c
src/filecount.c
src/fscache.c
src/gps.c
src/grpc.cc
src/hddtemp.c
src/hugepages.c
src/intel_rdt.c [new file with mode: 0644]
src/interface.c
src/ipc.c
src/ipmi.c
src/iptables.c
src/ipvs.c
src/irq.c
src/load.c
src/lpar.c
src/lua.c
src/lvm.c
src/madwifi.c
src/mbmon.c
src/md.c
src/memcachec.c
src/memcached.c
src/memory.c
src/mic.c
src/multimeter.c
src/netapp.c
src/netlink.c
src/network.c
src/nfs.c
src/nginx.c
src/ntpd.c
src/numa.c
src/olsrd.c
src/onewire.c
src/openldap.c
src/openvpn.c
src/pf.c
src/pinba.c
src/ping.c
src/postgresql_default.conf
src/powerdns.c
src/processes.c
src/protocols.c
src/redis.c
src/rrdcached.c
src/sensors.c
src/serial.c
src/sigrok.c
src/smart.c
src/statsd.c
src/swap.c
src/table.c
src/tail_csv.c
src/tape.c
src/tcpconns.c
src/teamspeak2.c
src/ted.c
src/thermal.c
src/turbostat.c
src/types.db
src/uptime.c
src/users.c
src/utils_vl_lookup_test.c
src/varnish.c
src/vmem.c
src/vserver.c
src/wireless.c
src/write_graphite.c
src/write_http.c
src/write_redis.c
src/xencpu.c
src/xmms.c
src/zfs_arc.c
src/zone.c
src/zookeeper.c
version-gen.sh

index eeb174b..791446a 100644 (file)
@@ -2,7 +2,7 @@
 
 Thanks for taking the time to contribute to the [collectd
 project](https://collectd.org/)! This document tries to give some guidance to
-make the process of contributing to *collectd* as pleasant and possible.
+make the process of contributing to *collectd* as pleasant as possible.
 
 ## Bug reports
 
@@ -19,7 +19,7 @@ following questions:
     [stack trace](https://collectd.org/wiki/index.php/Core_file).
 
 Please monitor your issue for a couple of days and reply to questions. To keep
-the project manageable have to do some housekeeping, meaning we will close
+the project manageable, we have to do some housekeeping; meaning we will close
 issues that have become stale.
 
 ## Code contributions
@@ -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
index 5155954..ff7ce70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2016-10-07, Version 5.6.1
+       * Build system: Unnecessary linking of the Write Graphite plugin with
+         libyajl has been removed. Thanks to Marc Fournier.
+         Debian#839771, #1976
+       * collectd: A bug in the "FlushInterval" option that caused a
+         segmentation fault in the Write HTTP plugin has been fixed. Thanks to
+         Florian Forster. #1954
+       * Apache plugin: A syntax error has been fixed. Thanks to Florian
+         Forster.
+       * cURL-JSON plugin: A segmentation fault that occurred when handling
+         JSON with unexpected structure has been fixed. Thanks to Florian
+         Forster. #1896
+       * PostgreSQL plugin: Handling of "NULL" values in the "query_plans" and
+         "query_plans_by_table" queries has been fixed. Thanks to Bernd
+         Zeimetz. #1905
+       * RRDCacheD plugin: Reconnection behavior has been added. Thanks to
+         Sebastian Harl. Debian#657877
+       * VServer plugin: Use of a deprecated API ("readdir_r()") has been
+         fixed. Thanks to Sebastian Harl.
+       * Write Graphite plugin: Make default values configurable at compile
+         time again. Thanks to Florian Forster. #1953
+       * Write HTTP plugin: A bug has been fixed that lead to flush callbacks
+         being registered twice. Thanks to Florian Forster. #1955
+
 2016-09-11, Version 5.6.0
        * Build system: An option to to avoid building the DF plugin against XFS
          has been added. Thanks to Ruben Kerkhof. #1878
diff --git a/README b/README
index bb72ac2..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.
 
@@ -142,6 +140,15 @@ Features
       hugepages can be found here:
       https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt.
 
+    - intel_rdt
+      The intel_rdt plugin collects information provided by monitoring features
+      of Intel Resource Director Technology (Intel(R) RDT) like Cache Monitoring
+      Technology (CMT), Memory Bandwidth Monitoring (MBM). These features
+      provide information about utilization of shared resources like last level
+      cache occupancy, local memory bandwidth usage, remote memory bandwidth
+      usage, instructions per clock.
+      <https://01.org/packet-processing/cache-monitoring-technology-memory-bandwidth-monitoring-cache-allocation-technology-code-and-data>
+
     - interface
       Interface traffic: Number of octets, packets and errors for each
       interface.
@@ -167,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.
@@ -190,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).
 
@@ -217,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'.
@@ -398,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
@@ -436,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.
@@ -659,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
@@ -739,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)
@@ -814,6 +835,11 @@ Prerequisites
     The PostgreSQL C client library used by the `postgresql' plugin.
     <http://www.postgresql.org/>
 
+  * libpqos (optional)
+    The PQoS library for Intel(R) Resource Director Technology used by the
+    `intel_rdt' plugin.
+    <https://github.com/01org/intel-cmt-cat>
+
   * libprotobuf, protoc 3.0+ (optional)
     Used by the `grpc' plugin to generate service stubs and code to handle
     network packets of collectd's protobuf-based network protocol.
@@ -934,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
 -------------------------------
 
@@ -990,6 +978,7 @@ To generate the `configure` script, you'll need the following dependencies:
 
 The `build.sh' script takes no arguments.
 
+
 Crosscompiling
 --------------
 
@@ -1020,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
@@ -1174,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 31c842a..07f9392 100644 (file)
@@ -4098,6 +4098,55 @@ fi
 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
 # }}}
 
+# --with-libpqos {{{
+with_libpqos_cppflags=""
+with_libpqos_ldflags=""
+AC_ARG_WITH(libpqos, [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               with_libpqos_cppflags="-I$withval/include"
+               with_libpqos_ldflags="-L$withval/lib"
+               with_libpqos="yes"
+       else
+               with_libpqos="$withval"
+       fi
+],
+[
+       with_libpqos="yes"
+])
+if test "x$with_libpqos" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
+
+       AC_CHECK_HEADERS(pqos.h, [with_libpqos="yes"], [with_libpqos="no (pqos.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libpqos" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
+       LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
+
+       AC_CHECK_LIB(pqos, pqos_init, [with_libpqos="yes"], [with_libpqos="no (Can't find libpqos)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libpqos" = "xyes"
+then
+       BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
+       BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
+       BUILD_WITH_LIBPQOS_LIBS="-lpqos"
+       AC_SUBST(BUILD_WITH_LIBPQOS_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBPQOS_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBPQOS_LIBS)
+fi
+# }}}
+
 # --with-libprotobuf {{{
 with_libprotobuf_cppflags=""
 with_libprotobuf_ldflags=""
@@ -5786,6 +5835,7 @@ plugin_fscache="no"
 plugin_gps="no"
 plugin_grpc="no"
 plugin_hugepages="no"
+plugin_intel_rdt="no"
 plugin_interface="no"
 plugin_ipmi="no"
 plugin_ipvs="no"
@@ -6243,6 +6293,7 @@ AC_PLUGIN([gps],                 [$plugin_gps],             [GPS plugin])
 AC_PLUGIN([grpc],                [$plugin_grpc],            [gRPC plugin])
 AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
 AC_PLUGIN([hugepages],           [$plugin_hugepages],       [Hugepages statistics])
+AC_PLUGIN([intel_rdt],           [$with_libpqos],           [Intel RDT monitor plugin])
 AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
 AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
 AC_PLUGIN([ipmi],                [$plugin_ipmi],            [IPMI sensor statistics])
@@ -6604,6 +6655,7 @@ AC_MSG_RESULT([    libpcap . . . . . . . $with_libpcap])
 AC_MSG_RESULT([    libperfstat . . . . . $with_perfstat])
 AC_MSG_RESULT([    libperl . . . . . . . $with_libperl])
 AC_MSG_RESULT([    libpq . . . . . . . . $with_libpq])
+AC_MSG_RESULT([    libpqos . . . . . . . $with_libpqos])
 AC_MSG_RESULT([    libprotobuf . . . . . $with_libprotobuf])
 AC_MSG_RESULT([    libprotobuf-c . . . . $with_libprotobuf_c])
 AC_MSG_RESULT([    libpython . . . . . . $with_libpython])
@@ -6676,6 +6728,7 @@ AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
 AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
 AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
 AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
+AC_MSG_RESULT([    intel_rdt. . . . .  . $enable_intel_rdt])
 AC_MSG_RESULT([    interface . . . . . . $enable_interface])
 AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
 AC_MSG_RESULT([    ipmi  . . . . . . . . $enable_ipmi])
index 1edcfc6..b53cf95 100644 (file)
@@ -152,8 +152,8 @@ sub check_end {
                #try at least $self->{main}->{conf}->{collectd_retries} to get a
                #connection
                for (my $i = 0; $i < $self->{main}->{conf}->{collectd_retries} ; ++$i) {
-                       last if $sock = new IO::Socket::UNIX
-                               ($self->{main}->{conf}->{collectd_socket});
+                       my ($socket_path) = $self->{main}->{conf}->{collectd_socket} =~ /(.*)/; # Untaint path, which can contain any characters.
+                       last if $sock = new IO::Socket::UNIX $socket_path;
                        #sleep a random value between 0 and 50 microsecs to try for a new
                        #thread
                        usleep(int(rand(50))); 
index 71fb5f8..adeae8c 100644 (file)
@@ -101,7 +101,6 @@ static int my_submit (gauge_t value)
         * have the same timestamp. */
        /* vl.time = cdtime(); */
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "myplugin", sizeof (vl.plugin));
 
        /* it is strongly recommended to use a type defined in the types.db file
index 73e69c7..eaf6f31 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 intel_rdt disabled, requires intel-cmt-cat
+%define with_intel_rdt 0%{!?_without_intel_rdt:0}
 # plugin mic disabled, requires Mic
 %define with_mic 0%{!?_without_mic:0}
 # plugin netapp disabled, requires libnetapp
 Summary:       Statistics collection and monitoring daemon
 Name:          collectd
 Version:       5.7.0
-Release:       2%{?dist}
+Release:       1%{?dist}
 URL:           https://collectd.org
 Source:                https://collectd.org/files/%{name}-%{version}.tar.bz2
 License:       GPLv2
@@ -452,6 +456,17 @@ The HDDTemp plugin collects the temperature of hard disks. The temperatures are
 provided via SMART and queried by the external hddtemp daemon.
 %endif
 
+%if %{with_intel_rdt}
+%package intel_rdt
+Summary:       Intel RDT plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+BuildRequires: intel-cmt-cat
+%description intel_rdt
+The intel_rdt plugin collects information provided by monitoring features of
+Intel Resource Director Technology (Intel(R) RDT).
+%endif
+
 %if %{with_ipmi}
 %package ipmi
 Summary:       IPMI plugin for collectd
@@ -1069,6 +1084,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
@@ -1141,6 +1162,12 @@ Collectd utilities
 %define _with_hugepages --disable-hugepages
 %endif
 
+%if %{with_intel_rdt}
+%define _with_intel_rdt --enable-intel_rdt
+%else
+%define _with_intel_rdt --disable-intel_rdt
+%endif
+
 %if %{with_interface}
 %define _with_interface --enable-interface
 %else
@@ -1758,6 +1785,7 @@ Collectd utilities
        %{?_with_disk} \
        %{?_with_dns} \
        %{?_with_drbd} \
+       %{?_with_dpdkstat} \
        %{?_with_email} \
        %{?_with_entropy} \
        %{?_with_ethstat} \
@@ -1770,6 +1798,7 @@ Collectd utilities
        %{?_with_grpc} \
        %{?_with_hddtemp} \
        %{?_with_hugepages} \
+       %{?_with_intel_rdt} \
        %{?_with_interface} \
        %{?_with_ipc} \
        %{?_with_ipmi} \
@@ -2035,6 +2064,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
@@ -2315,6 +2347,11 @@ fi
 %{_libdir}/%{name}/hddtemp.so
 %endif
 
+%if %{with_intel_rdt}
+%files intel_rdt
+%{_libdir}/%{name}/intel_rdt.so
+%endif
+
 %if %{with_ipmi}
 %files ipmi
 %{_libdir}/%{name}/ipmi.so
@@ -2523,12 +2560,16 @@ fi
 %doc contrib/
 
 %changelog
-* Tue Aug 23 2016 Marc Fournier <marc.fournier@camptocamp.com> - 5.7.0-1
+* Mon Oct 10 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, intel_rdt
+
+* Mon Oct 10 2016 Victor Demonchy <v.demonchy@criteo.com> - 5.6.1-1
+- New upstream version
 
 * Sun Aug 14 2016 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.6.0-1
-- New PRE-RELEASE version
+- New upstream version
 - New plugins enabled by default: chrony, cpusleep, gps, lua, mqtt, notify_nagios
 - New plugins disabled by default: grpc, xencpu, zone
 
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 0829c02..7254bd9 100644 (file)
@@ -979,6 +979,14 @@ protocols_la_SOURCES = protocols.c
 protocols_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 endif
 
+if BUILD_PLUGIN_INTEL_RDT
+pkglib_LTLIBRARIES += intel_rdt.la
+intel_rdt_la_SOURCES = intel_rdt.c
+intel_rdt_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBPQOS_LDFLAGS)
+intel_rdt_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBPQOS_CPPFLAGS)
+intel_rdt_la_LIBADD = $(BUILD_WITH_LIBPQOS_LIBS)
+endif
+
 if BUILD_PLUGIN_REDIS
 pkglib_LTLIBRARIES += redis.la
 redis_la_SOURCES = redis.c
@@ -1283,7 +1291,6 @@ pkglib_LTLIBRARIES += write_graphite.la
 write_graphite_la_SOURCES = write_graphite.c \
                         utils_format_graphite.c utils_format_graphite.h
 write_graphite_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-write_graphite_la_LIBADD = libformat_json.la
 endif
 
 if BUILD_PLUGIN_WRITE_HTTP
index 578b8de..7ccdb60 100644 (file)
@@ -394,8 +394,8 @@ static void submit_value (const char *type, const char *type_instance,
        vl.values = &value;
        vl.values_len = 1;
 
-       sstrncpy (vl.host, (st->host != NULL) ? st->host : hostname_g,
-                       sizeof (vl.host));
+       if (st->host != NULL)
+               sstrncpy (vl.host, st->host, sizeof (vl.host));
 
        sstrncpy (vl.plugin, "apache", sizeof (vl.plugin));
        if (st->name != NULL)
index 821bd65..937f2a0 100644 (file)
@@ -420,9 +420,7 @@ static void apc_submit_generic (const char *type, const char *type_inst, double
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "apcups", sizeof (vl.plugin));
-       sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
index 06ca7a8..17c822f 100644 (file)
@@ -87,9 +87,7 @@ static void as_submit (const char *type, const char *type_instance,
 
        vl.values = &(value_t) { .gauge = val };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "apple_sensors", sizeof (vl.plugin));
-       sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
index 08271f8..8872409 100644 (file)
@@ -69,7 +69,6 @@ static void aquaero_submit (const char *type, const char *type_instance,
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "aquaero", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index 16568e6..b14be3c 100644 (file)
@@ -130,7 +130,6 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
 
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin));
 
   if (plugin_instance != NULL)
index 998932d..53c55b8 100644 (file)
@@ -1600,7 +1600,6 @@ static int MPL115_collectd_barometer_read (void)
 
     norm_pressure = abs_to_mean_sea_level_pressure(pressure);
 
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "barometer", sizeof (vl.plugin));
     sstrncpy (vl.plugin_instance, "mpl115", sizeof (vl.plugin_instance));
 
@@ -1663,7 +1662,6 @@ static int MPL3115_collectd_barometer_read (void)
 
     norm_pressure = abs_to_mean_sea_level_pressure(pressure);
 
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "barometer", sizeof (vl.plugin));
     sstrncpy (vl.plugin_instance, "mpl3115", sizeof (vl.plugin_instance));
 
@@ -1726,7 +1724,6 @@ static int BMP085_collectd_barometer_read (void)
 
     norm_pressure = abs_to_mean_sea_level_pressure(pressure);
 
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "barometer", sizeof (vl.plugin));
     sstrncpy (vl.plugin_instance, "bmp085", sizeof (vl.plugin_instance));
 
index ebf41de..a909b75 100644 (file)
@@ -82,7 +82,6 @@ static void battery_submit2 (char const *plugin_instance, /* {{{ */
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "battery", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index 03729fd..a0ff187 100644 (file)
@@ -58,7 +58,6 @@ static void battery_submit(const char *type, gauge_t value,
 
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, "battery", sizeof(vl.plugin));
   /* statefs supports 1 battery at present */
   sstrncpy(vl.plugin_instance, "0", sizeof(vl.plugin_instance));
index 09de4a3..2b7ad75 100644 (file)
@@ -125,47 +125,47 @@ static char   bind_curl_error[CURL_ERROR_SIZE];
 static const translation_info_t nsstats_translation_table[] = /* {{{ */
 {
   /* Requests */
-  { "Requestv4",       "dns_request",  "IPv4"        },
-  { "Requestv6",       "dns_request",  "IPv6"        },
-  { "ReqEdns0",        "dns_request",  "EDNS0"       },
-  { "ReqBadEDNSVer",   "dns_request",  "BadEDNSVer"  },
-  { "ReqTSIG",         "dns_request",  "TSIG"        },
-  { "ReqSIG0",         "dns_request",  "SIG0"        },
-  { "ReqBadSIG",       "dns_request",  "BadSIG"      },
-  { "ReqTCP",          "dns_request",  "TCP"         },
+  { "Requestv4",       "dns_request",  "IPv4"          },
+  { "Requestv6",       "dns_request",  "IPv6"          },
+  { "ReqEdns0",        "dns_request",  "EDNS0"         },
+  { "ReqBadEDNSVer",   "dns_request",  "BadEDNSVer"    },
+  { "ReqTSIG",         "dns_request",  "TSIG"          },
+  { "ReqSIG0",         "dns_request",  "SIG0"          },
+  { "ReqBadSIG",       "dns_request",  "BadSIG"        },
+  { "ReqTCP",          "dns_request",  "TCP"           },
   /* Rejects */
-  { "AuthQryRej",      "dns_reject",   "authorative" },
-  { "RecQryRej",       "dns_reject",   "recursive"   },
-  { "XfrRej",          "dns_reject",   "transfer"    },
-  { "UpdateRej",       "dns_reject",   "update"      },
+  { "AuthQryRej",      "dns_reject",   "authoritative" },
+  { "RecQryRej",       "dns_reject",   "recursive"     },
+  { "XfrRej",          "dns_reject",   "transfer"      },
+  { "UpdateRej",       "dns_reject",   "update"        },
   /* Responses */
-  { "Response",        "dns_response", "normal"      },
-  { "TruncatedResp",   "dns_response", "truncated"   },
-  { "RespEDNS0",       "dns_response", "EDNS0"       },
-  { "RespTSIG",        "dns_response", "TSIG"        },
-  { "RespSIG0",        "dns_response", "SIG0"        },
+  { "Response",        "dns_response", "normal"        },
+  { "TruncatedResp",   "dns_response", "truncated"     },
+  { "RespEDNS0",       "dns_response", "EDNS0"         },
+  { "RespTSIG",        "dns_response", "TSIG"          },
+  { "RespSIG0",        "dns_response", "SIG0"          },
   /* Queries */
-  { "QryAuthAns",      "dns_query",    "authorative" },
-  { "QryNoauthAns",    "dns_query",    "nonauth"     },
-  { "QryReferral",     "dns_query",    "referral"    },
-  { "QryRecursion",    "dns_query",    "recursion"   },
-  { "QryDuplicate",    "dns_query",    "dupliate"    },
-  { "QryDropped",      "dns_query",    "dropped"     },
-  { "QryFailure",      "dns_query",    "failure"     },
+  { "QryAuthAns",      "dns_query",    "authoritative" },
+  { "QryNoauthAns",    "dns_query",    "nonauth"       },
+  { "QryReferral",     "dns_query",    "referral"      },
+  { "QryRecursion",    "dns_query",    "recursion"     },
+  { "QryDuplicate",    "dns_query",    "duplicate"     },
+  { "QryDropped",      "dns_query",    "dropped"       },
+  { "QryFailure",      "dns_query",    "failure"       },
   /* Response codes */
-  { "QrySuccess",      "dns_rcode",    "tx-NOERROR"  },
-  { "QryNxrrset",      "dns_rcode",    "tx-NXRRSET"  },
-  { "QrySERVFAIL",     "dns_rcode",    "tx-SERVFAIL" },
-  { "QryFORMERR",      "dns_rcode",    "tx-FORMERR"  },
-  { "QryNXDOMAIN",     "dns_rcode",    "tx-NXDOMAIN" }
+  { "QrySuccess",      "dns_rcode",    "tx-NOERROR"    },
+  { "QryNxrrset",      "dns_rcode",    "tx-NXRRSET"    },
+  { "QrySERVFAIL",     "dns_rcode",    "tx-SERVFAIL"   },
+  { "QryFORMERR",      "dns_rcode",    "tx-FORMERR"    },
+  { "QryNXDOMAIN",     "dns_rcode",    "tx-NXDOMAIN"   }
 #if 0
-  { "XfrReqDone",      "type", "type_instance"       },
-  { "UpdateReqFwd",    "type", "type_instance"       },
-  { "UpdateRespFwd",   "type", "type_instance"       },
-  { "UpdateFwdFail",   "type", "type_instance"       },
-  { "UpdateDone",      "type", "type_instance"       },
-  { "UpdateFail",      "type", "type_instance"       },
-  { "UpdateBadPrereq", "type", "type_instance"       },
+  { "XfrReqDone",      "type",         "type_instance" },
+  { "UpdateReqFwd",    "type",         "type_instance" },
+  { "UpdateRespFwd",   "type",         "type_instance" },
+  { "UpdateFwdFail",   "type",         "type_instance" },
+  { "UpdateDone",      "type",         "type_instance" },
+  { "UpdateFail",      "type",         "type_instance" },
+  { "UpdateBadPrereq", "type",         "type_instance" },
 #endif
 };
 static int nsstats_translation_table_length =
@@ -253,7 +253,6 @@ static void submit (time_t ts, const char *plugin_instance, /* {{{ */
   vl.values_len = 1;
   if (config_parse_time)
     vl.time = TIME_T_TO_CDTIME_T (ts);
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, "bind", sizeof(vl.plugin));
   if (plugin_instance) {
     sstrncpy(vl.plugin_instance, plugin_instance,
index 64d8785..7c5c8a5 100644 (file)
@@ -1162,7 +1162,6 @@ cconn_process_data(struct cconn *io, yajl_struct *yajl, yajl_handle hand)
     }
 
     vtmp->vlist = (value_list_t)VALUE_LIST_INIT;
-    sstrncpy(vtmp->vlist.host, hostname_g, sizeof(vtmp->vlist.host));
     sstrncpy(vtmp->vlist.plugin, "ceph", sizeof(vtmp->vlist.plugin));
     sstrncpy(vtmp->vlist.plugin_instance, io->d->name, sizeof(vtmp->vlist.plugin_instance));
 
index f7c7e0d..2584eff 100644 (file)
@@ -46,7 +46,6 @@ static void cgroups_submit_one (char const *plugin_instance,
 
        vl.values = &value;
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "cgroups", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
index 353ede7..77ba8cc 100644 (file)
@@ -683,9 +683,6 @@ chrony_push_data(const char *p_type, const char *p_type_inst, double p_value)
   vl.values_len = 1;
 
   /* XXX: Shall g_chrony_host/g_chrony_port be reflected in the plugin's output? */
-  /* hostname_g is set in daemon/collectd.c (from config, via gethostname or by resolving localhost) */
-  /* defined as: char hostname_g[DATA_MAX_NAME_LEN]; (never NULL) */
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, PLUGIN_NAME_SHORT, sizeof(vl.plugin));
   if (g_chrony_plugin_instance != NULL)
   {
index 65a9b7c..c246f1d 100644 (file)
@@ -204,9 +204,9 @@ This value is not applied to counter-values.
 
 =item B<Ignore> I<Value> [, I<Value> ...]
 
-The ignore values allows to ignore Instances based on their name and the patterns
-specified by the various values you've entered. The match is a glob-type shell
-matching.
+The ignore values allows one to ignore Instances based on their name and the
+patterns specified by the various values you've entered. The match is a
+glob-type shell matching.
 
 =item B<InvertMatch> I<true|false(default)>
 
index 0495067..ae29951 100644 (file)
 #@BUILD_PLUGIN_GRPC_TRUE@LoadPlugin grpc
 #@BUILD_PLUGIN_HDDTEMP_TRUE@LoadPlugin hddtemp
 #@BUILD_PLUGIN_HUGEPAGES_TRUE@LoadPlugin hugepages
+#@BUILD_PLUGIN_INTEL_RDT_TRUE@LoadPlugin intel_rdt
 @BUILD_PLUGIN_INTERFACE_TRUE@@BUILD_PLUGIN_INTERFACE_TRUE@LoadPlugin interface
 #@BUILD_PLUGIN_IPC_TRUE@LoadPlugin ipc
 #@BUILD_PLUGIN_IPMI_TRUE@LoadPlugin ipmi
 #    ValuesPercentage false
 #</Plugin>
 
+#<Plugin "intel_rdt">
+#  Cores "0-2"
+#</Plugin>
+
 #<Plugin interface>
 #      Interface "eth0"
 #      IgnoreSelected false
 
 #<Plugin memcached>
 #      <Instance "local">
-#              Host "127.0.0.1"
+#              #Host "memcache.example.com"
+#              Address "127.0.0.1"
 #              Port "11211"
 #      </Instance>
 #</Plugin>
index 00cd781..1310c50 100644 (file)
@@ -960,7 +960,7 @@ support the SM Bus command subset).
 
 The reduction or normalization to mean sea level pressure requires (depending
 on selected method/approximation) also altitude and reference to temperature
-sensor(s).  When multiple temperature sensors are configured the minumum of
+sensor(s).  When multiple temperature sensors are configured the minimum of
 their values is always used (expecting that the warmer ones are affected by
 e.g. direct sun light at that moment).
 
@@ -1072,7 +1072,7 @@ The altitude (in meters) of the location where you meassure the pressure.
 
 Temperature sensor(s) which should be used as a reference when normalizing the
 pressure using C<Normalization> method 2.
-When specified more sensors a minumum is found and used each time.  The
+When specified more sensors a minimum is found and used each time.  The
 temperature reading directly from this pressure sensor/plugin is typically not
 suitable as the pressure sensor will be probably inside while we want outside
 temperature.  The collectd reference name is something like
@@ -2229,7 +2229,7 @@ is passed to them, so invalid settings here may go unnoticed. This is not the
 plugin's fault, it will report errors if it gets them from the libraryE<nbsp>/
 the driver. If a driver complains about an option, the plugin will dump a
 complete list of all options understood by that driver to the log. There is no
-way to programatically find out if an option expects a string or a numeric
+way to programmatically find out if an option expects a string or a numeric
 argument, so you will have to refer to the appropriate DBD's documentation to
 find this out. Sorry.
 
@@ -2928,6 +2928,60 @@ Defaults to B<false>.
 
 =back
 
+=head2 Plugin C<intel_rdt>
+
+The I<intel_rdt> plugin collects information provided by monitoring features of
+Intel Resource Director Technology (Intel(R) RDT) like Cache Monitoring
+Technology (CMT), Memory Bandwidth Monitoring (MBM). These features provide
+information about utilization of shared resources. CMT monitors last level cache
+occupancy (LLC). MBM supports two types of events reporting local and remote
+memory bandwidth. Local memory bandwidth (MBL) reports the bandwidth of
+accessing memory associated with the local socket. Remote memory bandwidth (MBR)
+reports the bandwidth of accessing the remote socket. Also this technology
+allows to monitor instructions per clock (IPC).
+Monitor events are hardware dependant. Monitoring capabilities are detected on
+plugin initialization and only supported events are monitored.
+
+B<Synopsis:>
+
+  <Plugin "intel_rdt">
+    Cores "0-2" "3,4,6" "8-10,15"
+  </Plugin>
+
+B<Options:>
+
+=over 4
+
+=item B<Interval> I<seconds>
+
+The interval within which to retrieve statistics on monitored events in seconds.
+For milliseconds divide the time by 1000 for example if the desired interval
+is 50ms, set interval to 0.05. Due to limited capacity of counters it is not
+recommended to set interval higher than 1 sec.
+
+=item B<Cores> I<cores groups>
+
+All events are reported on a per core basis. Monitoring of the events can be
+configured for group of cores (aggregated statistics). This field defines groups
+of cores on which to monitor supported events. The field is represented as list
+of strings with core group values. Each string represents a list of cores in a
+group. Allowed formats are:
+    0,1,2,3
+    0-10,20-18
+    1,3,5-8,10,0x10-12
+
+If an empty string is provided as value for this field default cores
+configuration is applied - a separate group is created for each core.
+
+=back
+
+B<Note:> By default global interval is used to retrieve statistics on monitored
+events. To configure a plugin specific interval use B<Interval> option of the
+intel_rdt <LoadPlugin> block. For milliseconds divide the time by 1000 for
+example if the desired interval is 50ms, set interval to 0.05.
+Due to limited capacity of counters it is not recommended to set interval higher
+than 1 sec.
+
 =head2 Plugin C<interface>
 
 =over 4
@@ -3341,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>
@@ -3358,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
 
@@ -5894,7 +5958,7 @@ transaction fails or if the database server crashes.
 
 Specify the plugin instance name that should be used instead of the database
 name (which is the default, if this option has not been specified). This
-allows to query multiple databases of the same name on the same host (e.g.
+allows one to query multiple databases of the same name on the same host (e.g.
 when running multiple database server versions in parallel).
 The plugin instance name can also be set from the query result using
 the B<PluginInstanceFrom> option in B<Query> block.
@@ -5957,7 +6021,7 @@ Use SSL only.
 
 Specify the plugin instance name that should be used instead of the database
 name (which is the default, if this option has not been specified). This
-allows to query multiple databases of the same name on the same host (e.g.
+allows one to query multiple databases of the same name on the same host (e.g.
 when running multiple database server versions in parallel).
 
 =item B<KRBSrvName> I<kerberos_service_name>
@@ -6157,11 +6221,11 @@ below this limit.
 
 =item B<ProcessMatch> I<name> I<regex>
 
-Similar to the B<Process> option this allows to select more detailed
+Similar to the B<Process> option this allows one to select more detailed
 statistics of processes matching the specified I<regex> (see L<regex(7)> for
 details). The statistics of all matching processes are summed up and
 dispatched to the daemon using the specified I<name> as an identifier. This
-allows to "group" several processes together. I<name> must not contain
+allows one to "group" several processes together. I<name> must not contain
 slashes.
 
 =item B<CollectContextSwitch> I<Boolean>
@@ -6376,8 +6440,8 @@ C<collectd> anymore, it does not need to be flushed when C<collectd> is to be
 restarted. This results in much shorter (if any) gaps in graphs, especially
 under heavy load. Also, the C<rrdtool> command line utility is aware of the
 daemon so that it can flush values to disk automatically when needed. This
-allows to integrate automated flushing of values into graphing solutions much
-more easily.
+allows one to integrate automated flushing of values into graphing solutions
+much more easily.
 
 There are disadvantages, though: The daemon may reside on a different host, so
 it may not be possible for C<collectd> to create the appropriate RRD files
@@ -8211,7 +8275,7 @@ forwarded to the kafka producer library B<librdkafka>.
 
 =item B<Key> I<String>
 
-Use the specified string as a partioning key for the topic. Kafka breaks
+Use the specified string as a partitioning key for the topic. Kafka breaks
 topic into partitions and guarantees that for a given topology, the same
 consumer will be used for a specific key. The special (case insensitive)
 string B<Random> can be used to specify that an arbitrary partition should
index 4a72b2f..26f6278 100644 (file)
@@ -61,7 +61,6 @@ static void conntrack_submit (const char *type, const char *type_instance,
 
        vl.values = &conntrack;
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "conntrack", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        if (type_instance != NULL)
index 3bd6d9f..834fbd7 100644 (file)
@@ -53,7 +53,6 @@ static void cs_submit (derive_t context_switches)
 
        vl.values = &(value_t) { .derive = context_switches };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "contextswitch", sizeof (vl.plugin));
        sstrncpy (vl.type, "contextswitch", sizeof (vl.type));
 
index fbd0714..36c4972 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -162,6 +162,12 @@ static int maxcpu;
 /* #endif  HAVE_LIBSTATGRAB */
 
 #elif defined(HAVE_PERFSTAT)
+#define TOTAL_IDLE 0
+#define TOTAL_USER 1
+#define TOTAL_SYS 2
+#define TOTAL_WAIT 3
+#define TOTAL_STAT_NUM 4
+static value_to_rate_state_t total_conv[TOTAL_STAT_NUM];
 static perfstat_cpu_t *perfcpu;
 static int numcpu;
 static int pnumcpu;
@@ -330,7 +336,6 @@ static void submit_value (int cpu_num, int cpu_state, const char *type, value_t
        vl.values = &value;
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "cpu", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, cpu_state_names[cpu_state],
@@ -399,6 +404,24 @@ static cpu_state_t *get_cpu_state (size_t cpu_num, size_t state) /* {{{ */
        return (&cpu_states[index]);
 } /* }}} cpu_state_t *get_cpu_state */
 
+#if defined(HAVE_PERFSTAT) /* {{{ */
+/* populate global aggregate cpu rate */
+static int total_rate(gauge_t *sum_by_state, size_t state, derive_t d,
+                                         value_to_rate_state_t* conv, cdtime_t now)
+{
+       gauge_t rate = NAN;
+       int status = value_to_rate (&rate, (value_t) { .derive = d }, DS_TYPE_DERIVE, now, conv);
+       if (status != 0)
+               return (status);
+
+       sum_by_state[state] = rate;
+
+       if (state != COLLECTD_CPU_STATE_IDLE)
+               RATE_ADD (sum_by_state[COLLECTD_CPU_STATE_ACTIVE], sum_by_state[state]);
+       return (0);
+}
+#endif /* }}} HAVE_PERFSTAT */
+
 /* Populates the per-CPU COLLECTD_CPU_STATE_ACTIVE rate and the global rate_by_state
  * array. */
 static void aggregate (gauge_t *sum_by_state) /* {{{ */
@@ -427,6 +450,27 @@ static void aggregate (gauge_t *sum_by_state) /* {{{ */
 
                RATE_ADD (sum_by_state[COLLECTD_CPU_STATE_ACTIVE], this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate);
        }
+
+#if defined(HAVE_PERFSTAT) /* {{{ */
+       cdtime_t now = cdtime ();
+       perfstat_cpu_total_t cputotal = { 0 };
+
+       if (!perfstat_cpu_total(NULL, &cputotal, sizeof(cputotal), 1)) {
+               char errbuf[1024];
+               WARNING ("cpu plugin: perfstat_cpu_total: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               return;
+       }
+
+       /* Reset COLLECTD_CPU_STATE_ACTIVE */
+       sum_by_state[COLLECTD_CPU_STATE_ACTIVE] = NAN;
+
+       /* Physical Processor Utilization */
+       total_rate(sum_by_state, COLLECTD_CPU_STATE_IDLE,   (derive_t) cputotal.pidle, &total_conv[TOTAL_IDLE], now);
+       total_rate(sum_by_state, COLLECTD_CPU_STATE_USER,   (derive_t) cputotal.puser, &total_conv[TOTAL_USER], now);
+       total_rate(sum_by_state, COLLECTD_CPU_STATE_SYSTEM, (derive_t) cputotal.psys , &total_conv[TOTAL_SYS],  now);
+       total_rate(sum_by_state, COLLECTD_CPU_STATE_WAIT,   (derive_t) cputotal.pwait, &total_conv[TOTAL_WAIT], now);
+#endif /* }}} HAVE_PERFSTAT */
 } /* }}} void aggregate */
 
 /* Commits (dispatches) the values for one CPU or the global aggregation.
@@ -464,7 +508,6 @@ static void cpu_commit_num_cpu (gauge_t value) /* {{{ */
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "cpu", sizeof (vl.plugin));
        sstrncpy (vl.type, "count", sizeof (vl.type));
 
index a2cc3ad..285ee6c 100644 (file)
@@ -63,7 +63,6 @@ static void cpufreq_submit (int cpu_num, value_t value)
 
        vl.values = &value;
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "cpufreq", sizeof (vl.plugin));
        sstrncpy (vl.type, "cpufreq", sizeof (vl.type));
        ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%i", cpu_num);
index 5de0e47..31bb25d 100644 (file)
@@ -41,7 +41,6 @@ static void cpusleep_submit(derive_t cpu_sleep) {
 
   vl.values = &(value_t) { .derive = cpu_sleep };
   vl.values_len = 1;
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, "cpusleep", sizeof(vl.plugin));
   sstrncpy(vl.type, "total_time_in_ms", sizeof(vl.type));
 
index 8401e6c..1a5258e 100644 (file)
@@ -614,7 +614,6 @@ static void cc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */
 
   vl.values = &value;
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, wm->type, sizeof (vl.type));
@@ -630,7 +629,6 @@ static void cc_submit_response_code (const web_page_t *wp, long code) /* {{{ */
 
   vl.values = &(value_t) { .gauge = (gauge_t) code };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, "response_code", sizeof (vl.type));
@@ -645,7 +643,6 @@ static void cc_submit_response_time (const web_page_t *wp, /* {{{ */
 
   vl.values = &(value_t) { .gauge = CDTIME_T_TO_DOUBLE (response_time) };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, "response_time", sizeof (vl.type));
index 8573579..c9e49f8 100644 (file)
@@ -101,7 +101,7 @@ static int init_hostname (void)
        int status;
 
        str = global_option_get ("Hostname");
-       if (str != NULL)
+       if ((str != NULL) && (str[0] != 0))
        {
                sstrncpy (hostname_g, str, sizeof (hostname_g));
                return (0);
@@ -602,7 +602,7 @@ int main (int argc, char **argv)
         * something wrong.
         */
        if (init_global_variables () != 0)
-               return (1);
+               exit (EXIT_FAILURE);
 
        if (test_config)
                return (0);
index e05da5c..3d1420d 100644 (file)
 extern kstat_ctl_t *kc;
 #endif
 
+/* AIX doesn't have MSG_DONTWAIT */
+#ifndef MSG_DONTWAIT
+#  define MSG_DONTWAIT MSG_NONBLOCK
+#endif
+
 #if !HAVE_GETPWNAM_R
 static pthread_mutex_t getpwnam_r_lock = PTHREAD_MUTEX_INITIALIZER;
 #endif
@@ -1147,7 +1152,7 @@ int parse_value (const char *value_orig, value_t *ret_value, int ds_type)
   }
 
   if (value == endptr) {
-    ERROR ("parse_value: Failed to parse string as %s: %s.",
+    ERROR ("parse_value: Failed to parse string as %s: \"%s\".",
         DS_TYPE_TO_STRING (ds_type), value);
     sfree (value);
     return -1;
index d4b962f..7446b6f 100644 (file)
@@ -360,7 +360,7 @@ static void log_list_callbacks (llist_t **list, /* {{{ */
 } /* }}} void log_list_callbacks */
 
 static int create_register_callback (llist_t **list, /* {{{ */
-               const char *name, void *callback, user_data_t *ud)
+               const char *name, void *callback, user_data_t const *ud)
 {
        callback_func_t *cf;
 
@@ -723,6 +723,9 @@ static value_list_t *plugin_value_list_clone (value_list_t const *vl_orig) /* {{
                return (NULL);
        memcpy (vl, vl_orig, sizeof (*vl));
 
+       if (vl->host[0] == 0)
+               sstrncpy (vl->host, hostname_g, sizeof (vl->host));
+
        vl->values = calloc (vl_orig->values_len, sizeof (*vl->values));
        if (vl->values == NULL)
        {
@@ -1261,7 +1264,7 @@ int plugin_register_read (const char *name,
 int plugin_register_complex_read (const char *group, const char *name,
                plugin_read_cb callback,
                cdtime_t interval,
-               user_data_t *user_data)
+               user_data_t const *user_data)
 {
        read_func_t *rf;
        int status;
@@ -1305,7 +1308,7 @@ int plugin_register_complex_read (const char *group, const char *name,
 } /* int plugin_register_complex_read */
 
 int plugin_register_write (const char *name,
-               plugin_write_cb callback, user_data_t *ud)
+               plugin_write_cb callback, user_data_t const *ud)
 {
        return (create_register_callback (&list_write, name,
                                (void *) callback, ud));
@@ -1352,7 +1355,7 @@ static char *plugin_flush_callback_name (const char *name)
 } /* static char *plugin_flush_callback_name */
 
 int plugin_register_flush (const char *name,
-               plugin_flush_cb callback, user_data_t *ud)
+               plugin_flush_cb callback, user_data_t const *ud)
 {
        int status;
        plugin_ctx_t ctx = plugin_get_ctx ();
@@ -1389,15 +1392,15 @@ int plugin_register_flush (const char *name,
                }
                cb->timeout = ctx.flush_timeout;
 
-               ud->data = cb;
-               ud->free_func = plugin_flush_timeout_callback_free;
-
                status = plugin_register_complex_read (
                        /* group     = */ "flush",
                        /* name      = */ flush_name,
                        /* callback  = */ plugin_flush_timeout_callback,
                        /* interval  = */ ctx.flush_interval,
-                       /* user data = */ ud);
+                       /* user data = */ &(user_data_t) {
+                               .data = cb,
+                               .free_func = plugin_flush_timeout_callback_free,
+                       });
 
                sfree (flush_name);
                if (status != 0)
@@ -1412,7 +1415,7 @@ int plugin_register_flush (const char *name,
 } /* int plugin_register_flush */
 
 int plugin_register_missing (const char *name,
-               plugin_missing_cb callback, user_data_t *ud)
+               plugin_missing_cb callback, user_data_t const *ud)
 {
        return (create_register_callback (&list_missing, name,
                                (void *) callback, ud));
@@ -1483,14 +1486,14 @@ int plugin_register_data_set (const data_set_t *ds)
 } /* int plugin_register_data_set */
 
 int plugin_register_log (const char *name,
-               plugin_log_cb callback, user_data_t *ud)
+               plugin_log_cb callback, user_data_t const *ud)
 {
        return (create_register_callback (&list_log, name,
                                (void *) callback, ud));
 } /* int plugin_register_log */
 
 int plugin_register_notification (const char *name,
-               plugin_notification_cb callback, user_data_t *ud)
+               plugin_notification_cb callback, user_data_t const *ud)
 {
        return (create_register_callback (&list_notification, name,
                                (void *) callback, ud));
@@ -2078,15 +2081,16 @@ static int plugin_dispatch_values_internal (value_list_t *vl)
        int status;
        static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
 
-       value_t *saved_values;
-       int      saved_values_len;
-
        data_set_t *ds;
 
-       int free_meta_data = 0;
+       _Bool free_meta_data = 0;
 
-       assert(vl);
-       assert(vl->plugin);
+       assert (vl != NULL);
+
+       /* These fields are initialized by plugin_value_list_clone() if needed: */
+       assert (vl->host[0] != 0);
+       assert (vl->time != 0); /* The time is determined at _enqueue_ time. */
+       assert (vl->interval != 0);
 
        if (vl->type[0] == 0 || vl->values == NULL || vl->values_len < 1)
        {
@@ -2126,11 +2130,6 @@ static int plugin_dispatch_values_internal (value_list_t *vl)
                return (-1);
        }
 
-       /* Assured by plugin_value_list_clone(). The time is determined at
-        * _enqueue_ time. */
-       assert (vl->time != 0);
-       assert (vl->interval != 0);
-
        DEBUG ("plugin_dispatch_values: time = %.3f; interval = %.3f; "
                        "host = %s; "
                        "plugin = %s; plugin_instance = %s; "
@@ -2168,31 +2167,6 @@ static int plugin_dispatch_values_internal (value_list_t *vl)
        escape_slashes (vl->type, sizeof (vl->type));
        escape_slashes (vl->type_instance, sizeof (vl->type_instance));
 
-       /* Copy the values. This way, we can assure `targets' that they get
-        * dynamically allocated values, which they can free and replace if
-        * they like. */
-       if ((pre_cache_chain != NULL) || (post_cache_chain != NULL))
-       {
-               saved_values     = vl->values;
-               saved_values_len = vl->values_len;
-
-               vl->values = (value_t *) calloc (vl->values_len,
-                               sizeof (*vl->values));
-               if (vl->values == NULL)
-               {
-                       ERROR ("plugin_dispatch_values: calloc failed.");
-                       vl->values = saved_values;
-                       return (-1);
-               }
-               memcpy (vl->values, saved_values,
-                               vl->values_len * sizeof (*vl->values));
-       }
-       else /* if ((pre == NULL) && (post == NULL)) */
-       {
-               saved_values     = NULL;
-               saved_values_len = 0;
-       }
-
        if (pre_cache_chain != NULL)
        {
                status = fc_process_chain (ds, vl, pre_cache_chain);
@@ -2204,17 +2178,7 @@ static int plugin_dispatch_values_internal (value_list_t *vl)
                                        status, status);
                }
                else if (status == FC_TARGET_STOP)
-               {
-                       /* Restore the state of the value_list so that plugins
-                        * don't get confused.. */
-                       if (saved_values != NULL)
-                       {
-                               sfree (vl->values);
-                               vl->values     = saved_values;
-                               vl->values_len = saved_values_len;
-                       }
                        return (0);
-               }
        }
 
        /* Update the value cache */
@@ -2234,15 +2198,6 @@ static int plugin_dispatch_values_internal (value_list_t *vl)
        else
                fc_default_action (ds, vl);
 
-       /* Restore the state of the value_list so that plugins don't get
-        * confused.. */
-       if (saved_values != NULL)
-       {
-               sfree (vl->values);
-               vl->values     = saved_values;
-               vl->values_len = saved_values_len;
-       }
-
        if ((free_meta_data != 0) && (vl->meta != NULL))
        {
                meta_data_destroy (vl->meta);
index c4cf566..5a4e4c7 100644 (file)
@@ -120,9 +120,7 @@ struct value_list_s
 };
 typedef struct value_list_s value_list_t;
 
-#define VALUE_LIST_INIT { NULL, 0, 0, plugin_get_interval (), \
-       "localhost", "", "", "", "", NULL }
-#define VALUE_LIST_STATIC { NULL, 0, 0, 0, "localhost", "", "", "", "", NULL }
+#define VALUE_LIST_INIT { .values = NULL, .meta = NULL }
 
 struct data_source_s
 {
@@ -306,20 +304,20 @@ int plugin_register_read (const char *name,
 int plugin_register_complex_read (const char *group, const char *name,
                plugin_read_cb callback,
                cdtime_t interval,
-               user_data_t *user_data);
+               user_data_t const *user_data);
 int plugin_register_write (const char *name,
-               plugin_write_cb callback, user_data_t *user_data);
+               plugin_write_cb callback, user_data_t const *user_data);
 int plugin_register_flush (const char *name,
-               plugin_flush_cb callback, user_data_t *user_data);
+               plugin_flush_cb callback, user_data_t const *user_data);
 int plugin_register_missing (const char *name,
-               plugin_missing_cb callback, user_data_t *user_data);
+               plugin_missing_cb callback, user_data_t const *user_data);
 int plugin_register_shutdown (const char *name,
                plugin_shutdown_cb callback);
 int plugin_register_data_set (const data_set_t *ds);
 int plugin_register_log (const char *name,
-               plugin_log_cb callback, user_data_t *user_data);
+               plugin_log_cb callback, user_data_t const *user_data);
 int plugin_register_notification (const char *name,
-               plugin_notification_cb callback, user_data_t *user_data);
+               plugin_notification_cb callback, user_data_t const *user_data);
 
 int plugin_unregister_config (const char *name);
 int plugin_unregister_complex_config (const char *name);
index 93c2519..e020429 100644 (file)
@@ -85,9 +85,9 @@ uc_iter_t *uc_get_iterator (void);
  *
  * PARAMETERS
  *   `iter'     The iterator object to advance.
- *   `ret_name' Pointer to a string where to store the name. The returned
- *              value is a copy of the value and has to be freed by the
- *              caller.
+ *   `ret_name' Optional pointer to a string where to store the name. If not
+ *              NULL, the returned value is a copy of the value and has to be
+ *              freed by the caller.
  *
  * RETURN VALUE
  *   Zero upon success or non-zero if the iterator ie NULL or no further
index ffcaa90..377336f 100644 (file)
@@ -88,7 +88,6 @@ static int simple_submit_match (cu_match_t *match, void *user_data)
 
   vl.values = values;
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, data->plugin, sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, data->plugin_instance,
       sizeof (vl.plugin_instance));
index 632787b..d9ffa8b 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -165,7 +165,6 @@ static void df_submit_one (char *plugin_instance,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "df", sizeof (vl.plugin));
        if (plugin_instance != NULL)
                sstrncpy (vl.plugin_instance, plugin_instance,
index 2c0d8b5..a07288d 100644 (file)
@@ -305,7 +305,6 @@ static void disk_submit (const char *plugin_instance,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
@@ -325,7 +324,6 @@ static void submit_io_time (char const *plugin_instance, derive_t io_time, deriv
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, "disk_io_time", sizeof (vl.type));
@@ -341,7 +339,6 @@ static void submit_in_progress (char const *disk_name, gauge_t in_progress)
 
        vl.values = &(value_t) { .gauge = in_progress };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, disk_name, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, "pending_operations", sizeof (vl.type));
index ae53710..04e5a1e 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -374,7 +374,6 @@ static void submit_derive (const char *type, const char *type_instance,
 
        vl.values = &(value_t) { .derive = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
@@ -392,7 +391,6 @@ static void submit_octets (derive_t queries, derive_t responses)
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
        sstrncpy (vl.type, "dns_octets", sizeof (vl.type));
 
index 5842543..3c636f7 100644 (file)
@@ -147,13 +147,13 @@ static void dpdk_config_init_default(void) {
 
 static int dpdk_config(oconfig_item_t *ci) {
   int port_counter = 0;
-  char errbuf[ERR_BUF_SIZE];
   /* Allocate g_configuration and
    * initialize a POSIX SHared Memory (SHM) object.
    */
   int err = dpdk_shm_init(sizeof(dpdk_config_t));
   if (err) {
-    DEBUG("dpdkstat: error in shm_init, %s",
+    char errbuf[ERR_BUF_SIZE];
+    ERROR("dpdkstat: error in shm_init, %s",
           sstrerror(errno, errbuf, sizeof(errbuf)));
     return -1;
   }
@@ -555,76 +555,75 @@ static void dpdk_submit_xstats(const char *dev_name,
                                const struct rte_eth_xstats *xstats,
                                uint32_t counters, cdtime_t port_read_time) {
   for (uint32_t j = 0; j < counters; j++) {
-    value_list_t dpdkstat_vl = VALUE_LIST_INIT;
+    value_list_t vl = VALUE_LIST_INIT;
     char *type_end;
 
-    dpdkstat_vl.values = &(value_t){.derive = (derive_t)xstats[j].value};
-    dpdkstat_vl.values_len = 1; /* Submit stats one at a time */
-    dpdkstat_vl.time = port_read_time;
-    sstrncpy(dpdkstat_vl.host, hostname_g, sizeof(dpdkstat_vl.host));
-    sstrncpy(dpdkstat_vl.plugin, "dpdkstat", sizeof(dpdkstat_vl.plugin));
-    sstrncpy(dpdkstat_vl.plugin_instance, dev_name,
-             sizeof(dpdkstat_vl.plugin_instance));
+    vl.values = &(value_t){.derive = (derive_t)xstats[j].value};
+    vl.values_len = 1; /* Submit stats one at a time */
+    vl.time = port_read_time;
+    sstrncpy(vl.plugin, "dpdkstat", sizeof(vl.plugin));
+    sstrncpy(vl.plugin_instance, dev_name,
+             sizeof(vl.plugin_instance));
 
     type_end = strrchr(xstats[j].name, '_');
 
     if ((type_end != NULL) &&
         (strncmp(xstats[j].name, "rx_", strlen("rx_")) == 0)) {
       if (strncmp(type_end, "_errors", strlen("_errors")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_rx_errors", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_rx_errors", sizeof(vl.type));
       } else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_rx_dropped", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_rx_dropped", sizeof(vl.type));
       } else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_rx_octets", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_rx_octets", sizeof(vl.type));
       } else if (strncmp(type_end, "_packets", strlen("_packets")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_rx_packets", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_rx_packets", sizeof(vl.type));
       } else if (strncmp(type_end, "_placement", strlen("_placement")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_rx_errors", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_rx_errors", sizeof(vl.type));
       } else if (strncmp(type_end, "_buff", strlen("_buff")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_rx_errors", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_rx_errors", sizeof(vl.type));
       } else {
         /* Does not fit obvious type: use a more generic one */
-        sstrncpy(dpdkstat_vl.type, "derive", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "derive", sizeof(vl.type));
       }
 
     } else if ((type_end != NULL) &&
                (strncmp(xstats[j].name, "tx_", strlen("tx_"))) == 0) {
       if (strncmp(type_end, "_errors", strlen("_errors")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_tx_errors", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_tx_errors", sizeof(vl.type));
       } else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_tx_dropped", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_tx_dropped", sizeof(vl.type));
       } else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_tx_octets", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_tx_octets", sizeof(vl.type));
       } else if (strncmp(type_end, "_packets", strlen("_packets")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "if_tx_packets", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "if_tx_packets", sizeof(vl.type));
       } else {
         /* Does not fit obvious type: use a more generic one */
-        sstrncpy(dpdkstat_vl.type, "derive", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "derive", sizeof(vl.type));
       }
     } else if ((type_end != NULL) &&
                (strncmp(xstats[j].name, "flow_", strlen("flow_"))) == 0) {
 
       if (strncmp(type_end, "_filters", strlen("_filters")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "operations", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "operations", sizeof(vl.type));
       } else if (strncmp(type_end, "_errors", strlen("_errors")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "errors", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "errors", sizeof(vl.type));
       } else if (strncmp(type_end, "_filters", strlen("_filters")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "filter_result", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "filter_result", sizeof(vl.type));
       }
     } else if ((type_end != NULL) &&
                (strncmp(xstats[j].name, "mac_", strlen("mac_"))) == 0) {
       if (strncmp(type_end, "_errors", strlen("_errors")) == 0) {
-        sstrncpy(dpdkstat_vl.type, "errors", sizeof(dpdkstat_vl.type));
+        sstrncpy(vl.type, "errors", sizeof(vl.type));
       }
     } else {
       /* Does not fit obvious type, or strrchr error:
        *   use a more generic type */
-      sstrncpy(dpdkstat_vl.type, "derive", sizeof(dpdkstat_vl.type));
+      sstrncpy(vl.type, "derive", sizeof(vl.type));
     }
 
-    sstrncpy(dpdkstat_vl.type_instance, xstats[j].name,
-             sizeof(dpdkstat_vl.type_instance));
-    plugin_dispatch_values(&dpdkstat_vl);
+    sstrncpy(vl.type_instance, xstats[j].name,
+             sizeof(vl.type_instance));
+    plugin_dispatch_values(&vl);
   }
 }
 
index 70f03ca..40a3eb2 100644 (file)
@@ -101,7 +101,6 @@ static int drbd_submit_fields (long int resource,
        }
 
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "drbd", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
index 97fbdfe..1027eb9 100644 (file)
@@ -657,7 +657,6 @@ static void email_submit (const char *type, const char *type_instance, gauge_t v
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "email", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
index b385c2a..02ea9e1 100644 (file)
@@ -41,7 +41,6 @@ static void entropy_submit (value_t value)
 
        vl.values = &value;
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin));
        sstrncpy (vl.type, "entropy", sizeof (vl.type));
 
index f0b8d9f..6dccb45 100644 (file)
@@ -191,7 +191,6 @@ static void ethstat_submit_value (const char *device,
   vl.values = &(value_t) { .derive = value };
   vl.values_len = 1;
 
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ethstat", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, device, sizeof (vl.plugin_instance));
   if (map != NULL)
index 616d079..fc40d4a 100644 (file)
@@ -274,7 +274,7 @@ static void set_environment (void) /* {{{ */
       CDTIME_T_TO_DOUBLE (plugin_get_interval ()));
   setenv ("COLLECTD_INTERVAL", buffer, /* overwrite = */ 1);
 
-  ssnprintf (buffer, sizeof (buffer), "%s", hostname_g);
+  sstrncpy (buffer, hostname_g, sizeof (buffer));
   setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1);
 #else
   ssnprintf (buffer, sizeof (buffer), "COLLECTD_INTERVAL=%.3f",
index a2f5aa8..00bd732 100644 (file)
@@ -66,7 +66,6 @@ static void fhcount_submit(
   vl.values_len = 1;
 
   // Compose the metric
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, "fhcount", sizeof(vl.plugin));
   sstrncpy(vl.type, type, sizeof(vl.type));
   sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
index c1e53a2..74bc5fb 100644 (file)
@@ -65,7 +65,6 @@ static void fc_submit_dir (const fc_directory_conf_t *dir)
 
   vl.values = &(value_t) { .gauge = (gauge_t) dir->files_num };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "filecount", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, dir->instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, "files", sizeof (vl.type));
index 33633d6..3a5baf5 100644 (file)
@@ -115,7 +115,6 @@ static void fscache_submit (const char *section, const char *name,
     vl.values = &value;
     vl.values_len = 1;
 
-    sstrncpy(vl.host, hostname_g, sizeof (vl.host));
     sstrncpy(vl.plugin, "fscache", sizeof (vl.plugin));
     sstrncpy(vl.plugin_instance, section, sizeof (vl.plugin_instance));
     sstrncpy(vl.type, "fscache_stat", sizeof(vl.type));
index d5b7176..644967b 100644 (file)
--- a/src/gps.c
+++ b/src/gps.c
@@ -224,7 +224,6 @@ static void cgps_submit (const char *type, gauge_t value, const char *type_insta
 
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "gps", sizeof (vl.plugin));
   sstrncpy (vl.type, type, sizeof (vl.type));
   sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
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 ece9c1a..cb6f6d2 100644 (file)
@@ -258,7 +258,6 @@ static void hddtemp_submit (char *type_instance, double value)
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "hddtemp", sizeof (vl.plugin));
        sstrncpy (vl.type, "temperature", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
index f62df83..1eb8b0c 100644 (file)
@@ -85,7 +85,6 @@ static void submit_hp(const struct entry_info *info) {
   vl.values = &(value_t) { .gauge = NAN };
   vl.values_len = 1;
 
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, g_plugin_name, sizeof(vl.plugin));
   if (info->node) {
     ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%zuKb",
diff --git a/src/intel_rdt.c b/src/intel_rdt.c
new file mode 100644 (file)
index 0000000..21f3a20
--- /dev/null
@@ -0,0 +1,676 @@
+/**
+ * collectd - src/intel_rdt.c
+ *
+ * Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *   Serhiy Pshyk <serhiyx.pshyk@intel.com>
+ **/
+
+#include "collectd.h"
+#include "common.h"
+
+#include <pqos.h>
+
+#define RDT_PLUGIN "intel_rdt"
+
+#define RDT_MAX_SOCKETS 8
+#define RDT_MAX_SOCKET_CORES 64
+#define RDT_MAX_CORES (RDT_MAX_SOCKET_CORES * RDT_MAX_SOCKETS)
+
+struct rdt_core_group_s {
+  char *desc;
+  size_t num_cores;
+  unsigned *cores;
+  enum pqos_mon_event events;
+};
+typedef struct rdt_core_group_s rdt_core_group_t;
+
+struct rdt_ctx_s {
+  rdt_core_group_t cgroups[RDT_MAX_CORES];
+  struct pqos_mon_data *pgroups[RDT_MAX_CORES];
+  size_t num_groups;
+  const struct pqos_cpuinfo *pqos_cpu;
+  const struct pqos_cap *pqos_cap;
+  const struct pqos_capability *cap_mon;
+};
+typedef struct rdt_ctx_s rdt_ctx_t;
+
+static rdt_ctx_t *g_rdt = NULL;
+
+static int isdup(const uint64_t *nums, size_t size, uint64_t val) {
+  for (size_t i = 0; i < size; i++)
+    if (nums[i] == val)
+      return 1;
+  return 0;
+}
+
+static int strtouint64(const char *s, uint64_t *n) {
+  char *endptr = NULL;
+
+  assert(s != NULL);
+  assert(n != NULL);
+
+  *n = strtoull(s, &endptr, 0);
+
+  if (!(*s != '\0' && *endptr == '\0')) {
+    DEBUG(RDT_PLUGIN ": Error converting '%s' to unsigned number.", s);
+    return (-EINVAL);
+  }
+
+  return (0);
+}
+
+/*
+ * NAME
+ *   strlisttonums
+ *
+ * DESCRIPTION
+ *   Converts string of characters representing list of numbers into array of
+ *   numbers. Allowed formats are:
+ *     0,1,2,3
+ *     0-10,20-18
+ *     1,3,5-8,10,0x10-12
+ *
+ *   Numbers can be in decimal or hexadecimal format.
+ *
+ * PARAMETERS
+ *   `s'         String representing list of unsigned numbers.
+ *   `nums'      Array to put converted numeric values into.
+ *   `max'       Maximum number of elements that nums can accommodate.
+ *
+ * RETURN VALUE
+ *    Number of elements placed into nums.
+ */
+static size_t strlisttonums(char *s, uint64_t *nums, size_t max) {
+  int ret;
+  size_t index = 0;
+  char *saveptr = NULL;
+
+  if (s == NULL || nums == NULL || max == 0)
+    return index;
+
+  for (;;) {
+    char *p = NULL;
+    char *token = NULL;
+
+    token = strtok_r(s, ",", &saveptr);
+    if (token == NULL)
+      break;
+
+    s = NULL;
+
+    while (isspace(*token))
+      token++;
+    if (*token == '\0')
+      continue;
+
+    p = strchr(token, '-');
+    if (p != NULL) {
+      uint64_t n, start, end;
+      *p = '\0';
+      ret = strtouint64(token, &start);
+      if (ret < 0)
+        return (0);
+      ret = strtouint64(p + 1, &end);
+      if (ret < 0)
+        return (0);
+      if (start > end) {
+        return (0);
+      }
+      for (n = start; n <= end; n++) {
+        if (!(isdup(nums, index, n))) {
+          nums[index] = n;
+          index++;
+        }
+        if (index >= max)
+          return index;
+      }
+    } else {
+      uint64_t val;
+
+      ret = strtouint64(token, &val);
+      if (ret < 0)
+        return (0);
+
+      if (!(isdup(nums, index, val))) {
+        nums[index] = val;
+        index++;
+      }
+      if (index >= max)
+        return index;
+    }
+  }
+
+  return index;
+}
+
+/*
+ * NAME
+ *   cgroup_cmp
+ *
+ * DESCRIPTION
+ *   Function to compare cores in 2 core groups.
+ *
+ * PARAMETERS
+ *   `cg_a'      Pointer to core group a.
+ *   `cg_b'      Pointer to core group b.
+ *
+ * RETURN VALUE
+ *    1 if both groups contain the same cores
+ *    0 if none of their cores match
+ *    -1 if some but not all cores match
+ */
+static int cgroup_cmp(const rdt_core_group_t *cg_a,
+                      const rdt_core_group_t *cg_b) {
+  int found = 0;
+
+  assert(cg_a != NULL);
+  assert(cg_b != NULL);
+
+  const int sz_a = cg_a->num_cores;
+  const int sz_b = cg_b->num_cores;
+  const unsigned *tab_a = cg_a->cores;
+  const unsigned *tab_b = cg_b->cores;
+
+  for (int i = 0; i < sz_a; i++) {
+    for (int j = 0; j < sz_b; j++)
+      if (tab_a[i] == tab_b[j])
+        found++;
+  }
+  /* if no cores are the same */
+  if (!found)
+    return 0;
+  /* if group contains same cores */
+  if (sz_a == sz_b && sz_b == found)
+    return 1;
+  /* if not all cores are the same */
+  return -1;
+}
+
+static int cgroup_set(rdt_core_group_t *cg, char *desc, uint64_t *cores,
+                      size_t num_cores) {
+  assert(cg != NULL);
+  assert(desc != NULL);
+  assert(cores != NULL);
+  assert(num_cores > 0);
+
+  cg->cores = calloc(num_cores, sizeof(unsigned));
+  if (cg->cores == NULL) {
+    ERROR(RDT_PLUGIN ": Error allocating core group table");
+    return (-ENOMEM);
+  }
+  cg->num_cores = num_cores;
+  cg->desc = strdup(desc);
+  if (cg->desc == NULL) {
+    ERROR(RDT_PLUGIN ": Error allocating core group description");
+    sfree(cg->cores);
+    return (-ENOMEM);
+  }
+
+  for (size_t i = 0; i < num_cores; i++)
+    cg->cores[i] = (unsigned)cores[i];
+
+  return 0;
+}
+
+/*
+ * NAME
+ *   oconfig_to_cgroups
+ *
+ * DESCRIPTION
+ *   Function to set the descriptions and cores for each core group.
+ *   Takes a config option containing list of strings that are used to set
+ *   core group values.
+ *
+ * PARAMETERS
+ *   `item'        Config option containing core groups.
+ *   `groups'      Table of core groups to set values in.
+ *   `max_groups'  Maximum number of core groups allowed.
+ *   `max_core'    Maximum allowed core value.
+ *
+ * RETURN VALUE
+ *   On success, the number of core groups set up. On error, appropriate
+ *   negative error value.
+ */
+static int oconfig_to_cgroups(oconfig_item_t *item, rdt_core_group_t *groups,
+                              size_t max_groups, uint64_t max_core) {
+  int index = 0;
+
+  assert(groups != NULL);
+  assert(max_groups > 0);
+  assert(item != NULL);
+
+  for (int j = 0; j < item->values_num; j++) {
+    int ret;
+    size_t n;
+    uint64_t cores[RDT_MAX_CORES] = {0};
+    char value[DATA_MAX_NAME_LEN];
+
+    if ((item->values[j].value.string == NULL) ||
+        (strlen(item->values[j].value.string) == 0))
+      continue;
+
+    sstrncpy(value, item->values[j].value.string, sizeof(value));
+
+    n = strlisttonums(value, cores, STATIC_ARRAY_SIZE(cores));
+    if (n == 0) {
+      ERROR(RDT_PLUGIN ": Error parsing core group (%s)",
+            item->values[j].value.string);
+      return (-EINVAL);
+    }
+
+    for (int i = 0; i < n; i++) {
+      if (cores[i] > max_core) {
+        ERROR(RDT_PLUGIN ": Core group (%s) contains invalid core id (%d)",
+              item->values[j].value.string, (int)cores[i]);
+        return (-EINVAL);
+      }
+    }
+
+    /* set core group info */
+    ret = cgroup_set(&groups[index], item->values[j].value.string, cores, n);
+    if (ret < 0)
+      return ret;
+
+    index++;
+
+    if (index >= max_groups) {
+      WARNING(RDT_PLUGIN ": Too many core groups configured");
+      return index;
+    }
+  }
+
+  return index;
+}
+
+#if COLLECT_DEBUG
+static void rdt_dump_cgroups(void) {
+  char cores[RDT_MAX_CORES * 4];
+
+  if (g_rdt == NULL)
+    return;
+
+  DEBUG(RDT_PLUGIN ": Core Groups Dump");
+  DEBUG(RDT_PLUGIN ":  groups count: %zu", g_rdt->num_groups);
+
+  for (int i = 0; i < g_rdt->num_groups; i++) {
+
+    memset(cores, 0, sizeof(cores));
+    for (int j = 0; j < g_rdt->cgroups[i].num_cores; j++) {
+      snprintf(cores + strlen(cores), sizeof(cores) - strlen(cores) - 1, " %d",
+               g_rdt->cgroups[i].cores[j]);
+    }
+
+    DEBUG(RDT_PLUGIN ":  group[%d]:", i);
+    DEBUG(RDT_PLUGIN ":    description: %s", g_rdt->cgroups[i].desc);
+    DEBUG(RDT_PLUGIN ":    cores: %s", cores);
+    DEBUG(RDT_PLUGIN ":    events: 0x%X", g_rdt->cgroups[i].events);
+  }
+
+  return;
+}
+
+static inline double bytes_to_kb(const double bytes) { return bytes / 1024.0; }
+
+static inline double bytes_to_mb(const double bytes) {
+  return bytes / (1024.0 * 1024.0);
+}
+
+static void rdt_dump_data(void) {
+  /*
+   * CORE - monitored group of cores
+   * RMID - Resource Monitoring ID associated with the monitored group
+   * LLC - last level cache occupancy
+   * MBL - local memory bandwidth
+   * MBR - remote memory bandwidth
+   */
+  DEBUG("  CORE     RMID    LLC[KB]   MBL[MB]    MBR[MB]");
+  for (int i = 0; i < g_rdt->num_groups; i++) {
+
+    const struct pqos_event_values *pv = &g_rdt->pgroups[i]->values;
+
+    double llc = bytes_to_kb(pv->llc);
+    double mbr = bytes_to_mb(pv->mbm_remote_delta);
+    double mbl = bytes_to_mb(pv->mbm_local_delta);
+
+    DEBUG(" [%s] %8u %10.1f %10.1f %10.1f", g_rdt->cgroups[i].desc,
+          g_rdt->pgroups[i]->poll_ctx[0].rmid, llc, mbl, mbr);
+  }
+}
+#endif /* COLLECT_DEBUG */
+
+static void rdt_free_cgroups(void) {
+  for (int i = 0; i < RDT_MAX_CORES; i++) {
+    sfree(g_rdt->cgroups[i].desc);
+
+    sfree(g_rdt->cgroups[i].cores);
+    g_rdt->cgroups[i].num_cores = 0;
+
+    sfree(g_rdt->pgroups[i]);
+  }
+}
+
+static int rdt_default_cgroups(void) {
+  int ret;
+
+  /* configure each core in separate group */
+  for (unsigned i = 0; i < g_rdt->pqos_cpu->num_cores; i++) {
+    char desc[DATA_MAX_NAME_LEN];
+    uint64_t core = i;
+
+    ssnprintf(desc, sizeof(desc), "%d", g_rdt->pqos_cpu->cores[i].lcore);
+
+    /* set core group info */
+    ret = cgroup_set(&g_rdt->cgroups[i], desc, &core, 1);
+    if (ret < 0)
+      return ret;
+  }
+
+  return g_rdt->pqos_cpu->num_cores;
+}
+
+static int rdt_config_cgroups(oconfig_item_t *item) {
+  int n = 0;
+  enum pqos_mon_event events = 0;
+
+  if (item == NULL) {
+    DEBUG(RDT_PLUGIN ": cgroups_config: Invalid argument.");
+    return (-EINVAL);
+  }
+
+  DEBUG(RDT_PLUGIN ": Core groups [%d]:", item->values_num);
+  for (int j = 0; j < item->values_num; j++) {
+    if (item->values[j].type != OCONFIG_TYPE_STRING) {
+      ERROR(RDT_PLUGIN ": given core group value is not a string [idx=%d]", j);
+      return (-EINVAL);
+    }
+    DEBUG(RDT_PLUGIN ":  [%d]: %s", j, item->values[j].value.string);
+  }
+
+  n = oconfig_to_cgroups(item, g_rdt->cgroups, RDT_MAX_CORES,
+                         g_rdt->pqos_cpu->num_cores - 1);
+  if (n < 0) {
+    rdt_free_cgroups();
+    ERROR(RDT_PLUGIN ": Error parsing core groups configuration.");
+    return (-EINVAL);
+  }
+
+  if (n == 0) {
+    /* create default core groups if "Cores" config option is empty */
+    n = rdt_default_cgroups();
+    if (n < 0) {
+      rdt_free_cgroups();
+      ERROR(RDT_PLUGIN ": Error creating default core groups configuration.");
+      return n;
+    }
+    INFO(RDT_PLUGIN
+         ": No core groups configured. Default core groups created.");
+  }
+
+  /* Get all available events on this platform */
+  for (int i = 0; i < g_rdt->cap_mon->u.mon->num_events; i++)
+    events |= g_rdt->cap_mon->u.mon->events[i].type;
+
+  events &= ~(PQOS_PERF_EVENT_LLC_MISS);
+
+  DEBUG(RDT_PLUGIN ": Number of cores in the system: %u",
+        g_rdt->pqos_cpu->num_cores);
+  DEBUG(RDT_PLUGIN ": Available events to monitor: %#x", events);
+
+  g_rdt->num_groups = n;
+  for (int i = 0; i < n; i++) {
+    for (int j = 0; j < i; j++) {
+      int found = 0;
+      found = cgroup_cmp(&g_rdt->cgroups[j], &g_rdt->cgroups[i]);
+      if (found != 0) {
+        rdt_free_cgroups();
+        ERROR(RDT_PLUGIN ": Cannot monitor same cores in different groups.");
+        return (-EINVAL);
+      }
+    }
+
+    g_rdt->cgroups[i].events = events;
+    g_rdt->pgroups[i] = calloc(1, sizeof(*g_rdt->pgroups[i]));
+    if (g_rdt->pgroups[i] == NULL) {
+      rdt_free_cgroups();
+      ERROR(RDT_PLUGIN ": Failed to allocate memory for monitoring data.");
+      return (-ENOMEM);
+    }
+  }
+
+  return (0);
+}
+
+static int rdt_preinit(void) {
+  int ret;
+
+  if (g_rdt != NULL) {
+    /* already initialized if config callback was called before init callback */
+    return (0);
+  }
+
+  g_rdt = calloc(1, sizeof(*g_rdt));
+  if (g_rdt == NULL) {
+    ERROR(RDT_PLUGIN ": Failed to allocate memory for rdt context.");
+    return (-ENOMEM);
+  }
+
+  /* In case previous instance of the application was not closed properly
+   * call fini and ignore return code. */
+  pqos_fini();
+
+  /* TODO:
+   * stdout should not be used here. Will be reworked when support of log
+   * callback is added to PQoS library.
+  */
+  ret = pqos_init(&(struct pqos_config){.fd_log = STDOUT_FILENO});
+  if (ret != PQOS_RETVAL_OK) {
+    ERROR(RDT_PLUGIN ": Error initializing PQoS library!");
+    goto rdt_preinit_error1;
+  }
+
+  ret = pqos_cap_get(&g_rdt->pqos_cap, &g_rdt->pqos_cpu);
+  if (ret != PQOS_RETVAL_OK) {
+    ERROR(RDT_PLUGIN ": Error retrieving PQoS capabilities.");
+    goto rdt_preinit_error2;
+  }
+
+  ret = pqos_cap_get_type(g_rdt->pqos_cap, PQOS_CAP_TYPE_MON, &g_rdt->cap_mon);
+  if (ret == PQOS_RETVAL_PARAM) {
+    ERROR(RDT_PLUGIN ": Error retrieving monitoring capabilities.");
+    goto rdt_preinit_error2;
+  }
+
+  if (g_rdt->cap_mon == NULL) {
+    ERROR(
+        RDT_PLUGIN
+        ": Monitoring capability not detected. Nothing to do for the plugin.");
+    goto rdt_preinit_error2;
+  }
+
+  return (0);
+
+rdt_preinit_error2:
+  pqos_fini();
+
+rdt_preinit_error1:
+
+  sfree(g_rdt);
+
+  return (-1);
+}
+
+static int rdt_config(oconfig_item_t *ci) {
+  int ret = 0;
+
+  ret = rdt_preinit();
+  if (ret != 0)
+    return ret;
+
+  for (int i = 0; i < ci->children_num; i++) {
+    oconfig_item_t *child = ci->children + i;
+
+    if (strcasecmp("Cores", child->key) == 0) {
+
+      ret = rdt_config_cgroups(child);
+      if (ret != 0)
+        return ret;
+
+#if COLLECT_DEBUG
+      rdt_dump_cgroups();
+#endif /* COLLECT_DEBUG */
+
+    } else {
+      ERROR(RDT_PLUGIN ": Unknown configuration parameter \"%s\".", child->key);
+    }
+  }
+
+  return (0);
+}
+
+static void rdt_submit_derive(char *cgroup, char *type, char *type_instance,
+                              derive_t value) {
+  value_list_t vl = VALUE_LIST_INIT;
+
+  vl.values = &(value_t){.derive = value};
+  vl.values_len = 1;
+
+  sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
+  snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
+  sstrncpy(vl.type, type, sizeof(vl.type));
+  if (type_instance)
+    sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
+
+  plugin_dispatch_values(&vl);
+}
+
+static void rdt_submit_gauge(char *cgroup, char *type, char *type_instance,
+                             gauge_t value) {
+  value_list_t vl = VALUE_LIST_INIT;
+
+  vl.values = &(value_t){.gauge = value};
+  vl.values_len = 1;
+
+  sstrncpy(vl.plugin, RDT_PLUGIN, sizeof(vl.plugin));
+  snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cgroup);
+  sstrncpy(vl.type, type, sizeof(vl.type));
+  if (type_instance)
+    sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
+
+  plugin_dispatch_values(&vl);
+}
+
+static int rdt_read(__attribute__((unused)) user_data_t *ud) {
+  int ret;
+
+  if (g_rdt == NULL) {
+    ERROR(RDT_PLUGIN ": rdt_read: plugin not initialized.");
+    return (-EINVAL);
+  }
+
+  ret = pqos_mon_poll(&g_rdt->pgroups[0], (unsigned)g_rdt->num_groups);
+  if (ret != PQOS_RETVAL_OK) {
+    ERROR(RDT_PLUGIN ": Failed to poll monitoring data.");
+    return (-1);
+  }
+
+#if COLLECT_DEBUG
+  rdt_dump_data();
+#endif /* COLLECT_DEBUG */
+
+  for (int i = 0; i < g_rdt->num_groups; i++) {
+    enum pqos_mon_event mbm_events =
+        (PQOS_MON_EVENT_LMEM_BW | PQOS_MON_EVENT_TMEM_BW |
+         PQOS_MON_EVENT_RMEM_BW);
+
+    const struct pqos_event_values *pv = &g_rdt->pgroups[i]->values;
+
+    /* Submit only monitored events data */
+
+    if (g_rdt->cgroups[i].events & PQOS_MON_EVENT_L3_OCCUP)
+      rdt_submit_gauge(g_rdt->cgroups[i].desc, "bytes", "llc", pv->llc);
+
+    if (g_rdt->cgroups[i].events & PQOS_PERF_EVENT_IPC)
+      rdt_submit_gauge(g_rdt->cgroups[i].desc, "ipc", NULL, pv->ipc);
+
+    if (g_rdt->cgroups[i].events & mbm_events) {
+      rdt_submit_derive(g_rdt->cgroups[i].desc, "memory_bandwidth", "local",
+                        pv->mbm_local_delta);
+      rdt_submit_derive(g_rdt->cgroups[i].desc, "memory_bandwidth", "remote",
+                        pv->mbm_remote_delta);
+    }
+  }
+
+  return (0);
+}
+
+static int rdt_init(void) {
+  int ret;
+
+  ret = rdt_preinit();
+  if (ret != 0)
+    return ret;
+
+  /* Start monitoring */
+  for (int i = 0; i < g_rdt->num_groups; i++) {
+    rdt_core_group_t *cg = &g_rdt->cgroups[i];
+
+    ret = pqos_mon_start(cg->num_cores, cg->cores, cg->events, (void *)cg->desc,
+                         g_rdt->pgroups[i]);
+
+    if (ret != PQOS_RETVAL_OK)
+      ERROR(RDT_PLUGIN ": Error starting monitoring group %s (pqos status=%d)",
+            cg->desc, ret);
+  }
+
+  return (0);
+}
+
+static int rdt_shutdown(void) {
+  int ret;
+
+  DEBUG(RDT_PLUGIN ": rdt_shutdown.");
+
+  if (g_rdt == NULL)
+    return (0);
+
+  /* Stop monitoring */
+  for (int i = 0; i < g_rdt->num_groups; i++) {
+    pqos_mon_stop(g_rdt->pgroups[i]);
+  }
+
+  ret = pqos_fini();
+  if (ret != PQOS_RETVAL_OK)
+    ERROR(RDT_PLUGIN ": Error shutting down PQoS library.");
+
+  rdt_free_cgroups();
+  sfree(g_rdt);
+
+  return (0);
+}
+
+void module_register(void) {
+  plugin_register_init(RDT_PLUGIN, rdt_init);
+  plugin_register_complex_config(RDT_PLUGIN, rdt_config);
+  plugin_register_complex_read(NULL, RDT_PLUGIN, rdt_read, 0, NULL);
+  plugin_register_shutdown(RDT_PLUGIN, rdt_shutdown);
+}
index 849de95..c0021d3 100644 (file)
@@ -179,7 +179,6 @@ static void if_submit (const char *dev, const char *type,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "interface", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index d6d2bbd..7f909e2 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -101,7 +101,6 @@ static void ipc_submit_g (const char *plugin_instance,
 
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ipc", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
index a42b787..3267275 100644 (file)
@@ -216,7 +216,6 @@ static void sensor_read_handler (ipmi_sensor_t *sensor,
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
 
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ipmi", sizeof (vl.plugin));
   sstrncpy (vl.type, list_item->sensor_type, sizeof (vl.type));
   sstrncpy (vl.type_instance, list_item->sensor_name, sizeof (vl.type_instance));
index 35975e6..657b6ba 100644 (file)
@@ -259,7 +259,6 @@ static int submit6_match (const struct ip6t_entry_match *match,
             return (0);
     }
 
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "ip6tables", sizeof (vl.plugin));
 
     status = ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
@@ -317,7 +316,6 @@ static int submit_match (const struct ipt_entry_match *match,
             return (0);
     }
 
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "iptables", sizeof (vl.plugin));
 
     status = ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
index d2ceb50..6bd868e 100644 (file)
@@ -233,7 +233,6 @@ static void cipvs_submit_connections (const char *pi, const char *ti,
        vl.values     = &(value_t) { .derive = value };
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, "connections", sizeof (vl.type));
@@ -256,7 +255,6 @@ static void cipvs_submit_if (const char *pi, const char *t, const char *ti,
        vl.values     = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, t, sizeof (vl.type));
index cb444a4..06c50ff 100644 (file)
--- a/src/irq.c
+++ b/src/irq.c
@@ -79,7 +79,6 @@ static void irq_submit (const char *irq_name, derive_t value)
 
        vl.values = &(value_t) { .derive = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "irq", sizeof (vl.plugin));
        sstrncpy (vl.type, "irq", sizeof (vl.type));
        sstrncpy (vl.type_instance, irq_name, sizeof (vl.type_instance));
index a3f6bb1..53854d1 100644 (file)
@@ -105,7 +105,6 @@ static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "load", sizeof (vl.plugin));
        sstrncpy (vl.type, "load", sizeof (vl.type));
 
index 0e32c83..69a56e1 100644 (file)
@@ -123,10 +123,6 @@ static void lpar_submit (const char *type_instance, double value)
                sstrncpy (vl.host, serial, sizeof (vl.host));
                sstrncpy (vl.plugin_instance, hostname_g, sizeof (vl.plugin));
        }
-       else
-       {
-               sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-       }
        sstrncpy (vl.plugin, "lpar", sizeof (vl.plugin));
        sstrncpy (vl.type, "vcpu", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
index d10b4ea..45fd7d5 100644 (file)
--- a/src/lua.c
+++ b/src/lua.c
@@ -543,7 +543,7 @@ static int lua_config_script(const oconfig_item_t *ci) /* {{{ */
   if (status != 0)
     return (status);
 
-  INFO("Lua plugin: File \"%s\" loaded succesfully", abs_path);
+  INFO("Lua plugin: File \"%s\" loaded successfully", abs_path);
 
   return 0;
 } /* }}} int lua_config_script */
index e43bf03..5e130d8 100644 (file)
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -60,7 +60,6 @@ static void lvm_submit (char const *plugin_instance, char const *type_instance,
     vl.values = &(value_t) { .gauge = (gauge_t) ivalue };
     vl.values_len = 1;
 
-    sstrncpy(vl.host, hostname_g, sizeof (vl.host));
     sstrncpy(vl.plugin, "lvm", sizeof (vl.plugin));
     sstrncpy(vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
     sstrncpy(vl.type, "df_complex", sizeof (vl.type));
index 42474bc..82c7e2f 100644 (file)
@@ -544,7 +544,6 @@ static void submit (const char *dev, const char *type, const char *ti1,
 
        vl.values = val;
        vl.values_len = len;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "madwifi", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index b72be89..87e54fa 100644 (file)
@@ -222,7 +222,6 @@ static void mbmon_submit (const char *type, const char *type_instance,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "mbmon", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
index db85c46..793b172 100644 (file)
--- a/src/md.c
+++ b/src/md.c
@@ -76,7 +76,6 @@ static void md_submit (const int minor, const char *type_instance,
 
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "md", sizeof (vl.plugin));
   ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
       "%i", minor);
index 97e75c0..766637b 100644 (file)
@@ -447,7 +447,6 @@ static void cmc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */
 
   vl.values = &value;
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "memcachec", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, wm->type, sizeof (vl.type));
index 77cadeb..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,23 +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;
-
-  /* Set vl->host to hostname_g, 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))
-    host = hostname_g;
-
   sstrncpy (vl->plugin, "memcached", sizeof (vl->plugin));
-  sstrncpy (vl->host, host, sizeof (vl->host));
-  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));
 }
 
@@ -545,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,
@@ -564,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>
@@ -580,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++)
   {
@@ -607,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.",
@@ -675,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)
index 16b8e09..55e7de1 100644 (file)
@@ -527,7 +527,6 @@ static int memory_read (void) /* {{{ */
 
        vl.values = v;
        vl.values_len = STATIC_ARRAY_SIZE (v);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "memory", sizeof (vl.plugin));
        sstrncpy (vl.type, "memory", sizeof (vl.type));
        vl.time = cdtime ();
index 5ec382b..51e6775 100644 (file)
--- a/src/mic.c
+++ b/src/mic.c
@@ -160,7 +160,6 @@ static void mic_submit_memory_use(int micnumber, const char *type_instance, U32
        vl.values = &(value_t) { .gauge = ((gauge_t)value) * 1024.0 };
        vl.values_len = 1;
 
-       strncpy (vl.host, hostname_g, sizeof (vl.host));
        strncpy (vl.plugin, "mic", sizeof (vl.plugin));
        ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "%i", micnumber);
        strncpy (vl.type, "memory", sizeof (vl.type));
index 2ffcc8f..9321daf 100644 (file)
@@ -197,7 +197,6 @@ static void multimeter_submit (double value)
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "multimeter", sizeof (vl.plugin));
        sstrncpy (vl.type, "multimeter", sizeof (vl.type));
 
index e83a475..c532062 100644 (file)
@@ -633,8 +633,6 @@ static int submit_values (const char *host, /* {{{ */
 
        if (host != NULL)
                sstrncpy (vl.host, host, sizeof (vl.host));
-       else
-               sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "netapp", sizeof (vl.plugin));
        if (plugin_inst != NULL)
                sstrncpy (vl.plugin_instance, plugin_inst, sizeof (vl.plugin_instance));
index 786056d..70c10c9 100644 (file)
@@ -198,7 +198,6 @@ static void submit_one (const char *dev, const char *type,
 
   vl.values = &(value_t) { .derive = value };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
@@ -221,7 +220,6 @@ static void submit_two (const char *dev, const char *type,
 
   vl.values = values;
   vl.values_len = STATIC_ARRAY_SIZE (values);
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
index 9a0f429..484e610 100644 (file)
@@ -303,7 +303,7 @@ static char            *send_buffer;
 static char            *send_buffer_ptr;
 static int              send_buffer_fill;
 static cdtime_t         send_buffer_last_update;
-static value_list_t     send_buffer_vl = VALUE_LIST_STATIC;
+static value_list_t     send_buffer_vl = VALUE_LIST_INIT;
 static pthread_mutex_t  send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
 
 /* XXX: These counters are incremented from one place only. The spot in which
@@ -3386,7 +3386,6 @@ static int network_stats_read (void) /* {{{ */
        vl.values = values;
        vl.values_len = 2;
        vl.time = 0;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "network", sizeof (vl.plugin));
 
        /* Octets received / sent */
index c128c81..d080cd6 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
@@ -386,7 +386,6 @@ static void nfs_procedures_submit (const char *plugin_instance,
        value_list_t vl = VALUE_LIST_INIT;
 
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "nfs", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
index 3850acc..08c24f9 100644 (file)
@@ -139,7 +139,7 @@ static int init (void)
 #else
     static char credentials[1024];
     int status = ssnprintf (credentials, sizeof (credentials),
-       "%s:%s", user, pass == NULL ? "" : pass);
+        "%s:%s", user, pass == NULL ? "" : pass);
     if ((status < 0) || ((size_t) status >= sizeof (credentials)))
     {
       ERROR ("nginx plugin: Credentials would have been truncated.");
@@ -211,9 +211,7 @@ static void submit (const char *type, const char *inst, long long value)
 
   vl.values = values;
   vl.values_len = STATIC_ARRAY_SIZE (values);
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "nginx", sizeof (vl.plugin));
-  sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
 
   if (inst != NULL)
@@ -258,39 +256,43 @@ static int nginx_read (void)
   /*
    * Active connections: 291
    * server accepts handled requests
-   *  16630948 16630948 31070465
+   *  101059015 100422216 347910649
    * Reading: 6 Writing: 179 Waiting: 106
    */
   for (int i = 0; i < lines_num; i++)
   {
     fields_num = strsplit (lines[i], fields,
-       (sizeof (fields) / sizeof (fields[0])));
+        (sizeof (fields) / sizeof (fields[0])));
 
     if (fields_num == 3)
     {
       if ((strcmp (fields[0], "Active") == 0)
-         && (strcmp (fields[1], "connections:") == 0))
+          && (strcmp (fields[1], "connections:") == 0))
       {
-       submit ("nginx_connections", "active", atoll (fields[2]));
+        submit ("nginx_connections", "active", atoll (fields[2]));
       }
       else if ((atoll (fields[0]) != 0)
-         && (atoll (fields[1]) != 0)
-         && (atoll (fields[2]) != 0))
+          && (atoll (fields[1]) != 0)
+          && (atoll (fields[2]) != 0))
       {
-       submit ("connections", "accepted", atoll (fields[0]));
-       submit ("connections", "handled", atoll (fields[1]));
-       submit ("nginx_requests", NULL, atoll (fields[2]));
+        submit ("connections", "accepted", atoll (fields[0]));
+        /* TODO: The legacy metric "handled", which is the sum of "accepted" and
+         * "failed", is reported for backwards compatibility only. Remove in the
+         * next major version. */
+        submit ("connections", "handled", atoll (fields[1]));
+        submit ("connections", "failed", (atoll(fields[0]) - atoll (fields[1])));
+        submit ("nginx_requests", NULL, atoll (fields[2]));
       }
     }
     else if (fields_num == 6)
     {
       if ((strcmp (fields[0], "Reading:") == 0)
-         && (strcmp (fields[2], "Writing:") == 0)
-         && (strcmp (fields[4], "Waiting:") == 0))
+          && (strcmp (fields[2], "Writing:") == 0)
+          && (strcmp (fields[4], "Waiting:") == 0))
       {
-       submit ("nginx_connections", "reading", atoll (fields[1]));
-       submit ("nginx_connections", "writing", atoll (fields[3]));
-       submit ("nginx_connections", "waiting", atoll (fields[5]));
+        submit ("nginx_connections", "reading", atoll (fields[1]));
+        submit ("nginx_connections", "writing", atoll (fields[3]));
+        submit ("nginx_connections", "waiting", atoll (fields[5]));
       }
     }
   }
index ccdecd9..7f6f982 100644 (file)
@@ -317,9 +317,7 @@ static void ntpd_submit (const char *type, const char *type_inst, gauge_t value)
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "ntpd", sizeof (vl.plugin));
-       sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
index 8f5bf48..e165383 100644 (file)
@@ -47,7 +47,6 @@ static void numa_dispatch_value (int node, /* {{{ */
   vl.values = &v;
   vl.values_len = 1;
 
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "numa", sizeof (vl.plugin));
   ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "node%i", node);
   sstrncpy (vl.type, "vmpage_action", sizeof (vl.type));
index 3bf7128..3a36723 100644 (file)
@@ -221,7 +221,6 @@ static void olsrd_submit (const char *plugin_instance, /* {{{ */
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
 
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "olsrd", sizeof (vl.plugin));
   if (plugin_instance != NULL)
     sstrncpy (vl.plugin_instance, plugin_instance,
index 0b4b6f5..c333fea 100644 (file)
@@ -346,7 +346,6 @@ static int cow_read_values (const char *path, const char *name,
       return 0;
   }
 
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "onewire", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, name, sizeof (vl.plugin_instance));
 
@@ -505,7 +504,6 @@ static int cow_simple_read (void)
   /* traverse list and check entries */
   for (traverse = direct_list; traverse != NULL; traverse = traverse->next)
   {
-      sstrncpy (vl.host, hostname_g, sizeof (vl.host));
       sstrncpy (vl.plugin, "onewire", sizeof (vl.plugin));
       sstrncpy (vl.plugin_instance, traverse->address, sizeof (vl.plugin_instance));
 
index dd3226d..d5e58b1 100644 (file)
@@ -169,11 +169,7 @@ static void cldap_submit_value (const char *type, const char *type_instance, /*
        vl.values     = &value;
        vl.values_len = 1;
 
-       if ((st->host == NULL)
-                       || (strcmp ("", st->host) == 0)
-                       || (strcmp ("localhost", st->host) == 0))
-               sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-       else
+       if ((st->host != NULL) && (strcmp ("localhost", st->host) != 0))
                sstrncpy (vl.host, st->host, sizeof (vl.host));
 
        sstrncpy (vl.plugin, "openldap", sizeof (vl.plugin));
index 81ffa89..1310c00 100644 (file)
@@ -103,7 +103,6 @@ static void numusers_submit (const char *pinst, const char *tinst,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "openvpn", sizeof (vl.plugin));
        sstrncpy (vl.type, "users", sizeof (vl.type));
        if (pinst != NULL)
@@ -133,7 +132,6 @@ static void iostats_submit (const char *pinst, const char *tinst,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "openvpn", sizeof (vl.plugin));
        if (pinst != NULL)
                sstrncpy (vl.plugin_instance, pinst,
@@ -157,7 +155,6 @@ static void compression_submit (const char *pinst, const char *tinst,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "openvpn", sizeof (vl.plugin));
        if (pinst != NULL)
                sstrncpy (vl.plugin_instance, pinst,
index d7a5a15..ecaa869 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
@@ -70,7 +70,6 @@ static void pf_submit (char const *type, char const *type_instance,
 
        vl.values = values;
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "pf", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof(vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof(vl.type_instance));
index 76b765b..5571ff2 100644 (file)
@@ -680,7 +680,6 @@ static int plugin_submit (const pinba_statnode_t *res) /* {{{ */
   value_list_t vl = VALUE_LIST_INIT;
 
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "pinba", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, res->name, sizeof (vl.plugin_instance));
 
index 39e9de5..6440849 100644 (file)
@@ -619,9 +619,7 @@ static void submit (const char *host, const char *type, /* {{{ */
 
   vl.values = &(value_t) { .gauge = value };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ping", sizeof (vl.plugin));
-  sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
   sstrncpy (vl.type_instance, host, sizeof (vl.type_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
 
index f905eb2..0aac41e 100644 (file)
 </Query>
 
 <Query query_plans>
-       Statement "SELECT sum(seq_scan) AS seq, \
-                       sum(seq_tup_read) AS seq_tup_read, \
-                       sum(idx_scan) AS idx, \
-                       sum(idx_tup_fetch) AS idx_tup_fetch \
+       Statement "SELECT coalesce(sum(seq_scan), 0) AS seq, \
+                         coalesce(sum(seq_tup_read), 0) AS seq_tup_read, \
+                         coalesce(sum(idx_scan), 0) AS idx, \
+                         coalesce(sum(idx_tup_fetch), 0) AS idx_tup_fetch \
                FROM pg_stat_user_tables;"
 
        <Result>
 
 <Query query_plans_by_table>
        Statement "SELECT schemaname, relname, \
-                       seq_scan AS seq, \
-                       seq_tup_read AS seq_tup_read, \
-                       idx_scan AS idx, \
-                       idx_tup_fetch AS idx_tup_fetch \
+                       coalesce(seq_scan, 0) AS seq, \
+                       coalesce(seq_tup_read, 0) AS seq_tup_read, \
+                       coalesce(idx_scan, 0) AS idx, \
+                       coalesce(idx_tup_fetch, 0) AS idx_tup_fetch \
                FROM pg_stat_user_tables;"
 
        <Result>
index eb54180..7e9e874 100644 (file)
@@ -354,7 +354,6 @@ static void submit (const char *plugin_instance, /* {{{ */
 
   vl.values = &value;
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "powerdns", sizeof (vl.plugin));
   sstrncpy (vl.type, type, sizeof (vl.type));
   if (type_instance != NULL)
index f470c84..e1660c5 100644 (file)
@@ -170,13 +170,9 @@ typedef struct procstat_entry_s
        unsigned long vmem_code;
        unsigned long stack_size;
 
-       unsigned long vmem_minflt;
-       unsigned long vmem_majflt;
        derive_t      vmem_minflt_counter;
        derive_t      vmem_majflt_counter;
 
-       unsigned long cpu_user;
-       unsigned long cpu_system;
        derive_t      cpu_user_counter;
        derive_t      cpu_system_counter;
 
@@ -185,9 +181,11 @@ typedef struct procstat_entry_s
        derive_t io_wchar;
        derive_t io_syscr;
        derive_t io_syscw;
+       _Bool    has_io;
 
        derive_t cswitch_vol;
        derive_t cswitch_invol;
+       _Bool    has_cswitch;
 
        struct procstat_entry_s *next;
 } procstat_entry_t;
@@ -229,6 +227,7 @@ typedef struct procstat
 
 static procstat_t *list_head_g = NULL;
 
+static _Bool want_init = 1;
 static _Bool report_ctx_switch = 0;
 
 #if HAVE_THREAD_INFO
@@ -241,6 +240,7 @@ static mach_msg_type_number_t     pset_list_len;
 
 #elif KERNEL_LINUX
 static long pagesize_g;
+static void ps_fill_details (const procstat_t *ps, procstat_entry_t *entry);
 /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
@@ -366,25 +366,24 @@ static int ps_list_match (const char *name, const char *cmdline, procstat_t *ps)
        return (0);
 } /* int ps_list_match */
 
-static void ps_update_counter (_Bool init, derive_t *group_counter,
-                               derive_t *curr_counter, unsigned long *curr_value,
-                               derive_t new_counter, unsigned long new_value)
+static void ps_update_counter (derive_t *group_counter,
+                               derive_t *curr_counter, derive_t new_counter)
 {
-       if (init)
+       unsigned long curr_value;
+       
+       if (want_init)
        {
-               *curr_value = new_value;
-               *curr_counter += new_value;
-               *group_counter += new_value;
+               *curr_counter = new_counter;
                return;
        }
 
        if (new_counter < *curr_counter)
-               *curr_value = new_counter + (ULONG_MAX - *curr_counter);
+               curr_value = new_counter + (ULONG_MAX - *curr_counter);
        else
-               *curr_value = new_counter - *curr_counter;
+               curr_value = new_counter - *curr_counter;
 
        *curr_counter = new_counter;
-       *group_counter += *curr_value;
+       *group_counter += curr_value;
 }
 
 /* add process entry to 'instances' of process 'name' (or refresh it) */
@@ -397,11 +396,13 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
 
        for (procstat_t *ps = list_head_g; ps != NULL; ps = ps->next)
        {
-               _Bool want_init;
-
                if ((ps_list_match (name, cmdline, ps)) == 0)
                        continue;
 
+#if KERNEL_LINUX
+               ps_fill_details(ps, entry);
+#endif
+
                for (pse = ps->instances; pse != NULL; pse = pse->next)
                        if ((pse->id == entry->id) || (pse->next == NULL))
                                break;
@@ -454,27 +455,23 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
                ps->cswitch_vol   += ((pse->cswitch_vol == -1)?0:pse->cswitch_vol);
                ps->cswitch_invol += ((pse->cswitch_invol == -1)?0:pse->cswitch_invol);
 
-               want_init = (entry->vmem_minflt_counter == 0)
-                               && (entry->vmem_majflt_counter == 0);
-               ps_update_counter (want_init,
+               ps_update_counter (
                                &ps->vmem_minflt_counter,
-                               &pse->vmem_minflt_counter, &pse->vmem_minflt,
-                               entry->vmem_minflt_counter, entry->vmem_minflt);
-               ps_update_counter (want_init,
+                               &pse->vmem_minflt_counter,
+                               entry->vmem_minflt_counter);
+               ps_update_counter (
                                &ps->vmem_majflt_counter,
-                               &pse->vmem_majflt_counter, &pse->vmem_majflt,
-                               entry->vmem_majflt_counter, entry->vmem_majflt);
+                               &pse->vmem_majflt_counter,
+                               entry->vmem_majflt_counter);
 
-               want_init = (entry->cpu_user_counter == 0)
-                               && (entry->cpu_system_counter == 0);
-               ps_update_counter (want_init,
+               ps_update_counter (
                                &ps->cpu_user_counter,
-                               &pse->cpu_user_counter, &pse->cpu_user,
-                               entry->cpu_user_counter, entry->cpu_user);
-               ps_update_counter (want_init,
+                               &pse->cpu_user_counter,
+                               entry->cpu_user_counter);
+               ps_update_counter (
                                &ps->cpu_system_counter,
-                               &pse->cpu_system_counter, &pse->cpu_system,
-                               entry->cpu_system_counter, entry->cpu_system);
+                               &pse->cpu_system_counter,
+                               entry->cpu_system_counter);
        }
 }
 
@@ -664,7 +661,6 @@ static void ps_submit_state (const char *state, double value)
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
        sstrncpy (vl.type, "ps_state", sizeof (vl.type));
@@ -680,7 +676,6 @@ static void ps_submit_proc_list (procstat_t *ps)
        value_t values[2];
 
        vl.values = values;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance));
 
@@ -784,7 +779,6 @@ static void ps_submit_fork_rate (derive_t value)
 
        vl.values = &(value_t) { .derive = value };
        vl.values_len = 1;
-       sstrncpy(vl.host, hostname_g, sizeof (vl.host));
        sstrncpy(vl.plugin, "processes", sizeof (vl.plugin));
        sstrncpy(vl.plugin_instance, "", sizeof (vl.plugin_instance));
        sstrncpy(vl.type, "fork_rate", sizeof (vl.type));
@@ -796,7 +790,7 @@ static void ps_submit_fork_rate (derive_t value)
 
 /* ------- additional functions for KERNEL_LINUX/HAVE_THREAD_INFO ------- */
 #if KERNEL_LINUX
-static procstat_t *ps_read_tasks_status (long pid, procstat_t *ps)
+static int ps_read_tasks_status (procstat_entry_t *ps)
 {
        char           dirname[64];
        DIR           *dh;
@@ -809,12 +803,12 @@ static procstat_t *ps_read_tasks_status (long pid, procstat_t *ps)
        char *fields[8];
        int numfields;
 
-       ssnprintf (dirname, sizeof (dirname), "/proc/%li/task", pid);
+       ssnprintf (dirname, sizeof (dirname), "/proc/%li/task", ps->id);
 
        if ((dh = opendir (dirname)) == NULL)
        {
                DEBUG ("Failed to open directory `%s'", dirname);
-               return (NULL);
+               return (-1);
        }
 
        while ((ent = readdir (dh)) != NULL)
@@ -826,7 +820,7 @@ static procstat_t *ps_read_tasks_status (long pid, procstat_t *ps)
 
                tpid = ent->d_name;
 
-               ssnprintf (filename, sizeof (filename), "/proc/%li/task/%s/status", pid, tpid);
+               ssnprintf (filename, sizeof (filename), "/proc/%li/task/%s/status", ps->id, tpid);
                if ((fh = fopen (filename, "r")) == NULL)
                {
                        DEBUG ("Failed to open file `%s'", filename);
@@ -876,7 +870,7 @@ static procstat_t *ps_read_tasks_status (long pid, procstat_t *ps)
        ps->cswitch_vol = cswitch_vol;
        ps->cswitch_invol = cswitch_invol;
 
-       return (ps);
+       return (0);
 } /* int *ps_read_tasks_status */
 
 /* Read data from /proc/pid/status */
@@ -950,7 +944,7 @@ static procstat_t *ps_read_status (long pid, procstat_t *ps)
        return (ps);
 } /* procstat_t *ps_read_vmem */
 
-static procstat_t *ps_read_io (long pid, procstat_t *ps)
+static int ps_read_io (procstat_entry_t *ps)
 {
        FILE *fh;
        char buffer[1024];
@@ -959,9 +953,9 @@ static procstat_t *ps_read_io (long pid, procstat_t *ps)
        char *fields[8];
        int numfields;
 
-       ssnprintf (filename, sizeof (filename), "/proc/%li/io", pid);
+       ssnprintf (filename, sizeof (filename), "/proc/%li/io", ps->id);
        if ((fh = fopen (filename, "r")) == NULL)
-               return (NULL);
+               return (-1);
 
        while (fgets (buffer, sizeof (buffer), fh) != NULL)
        {
@@ -1001,9 +995,36 @@ static procstat_t *ps_read_io (long pid, procstat_t *ps)
                WARNING ("processes: fclose: %s",
                                sstrerror (errno, errbuf, sizeof (errbuf)));
        }
+       return (0);
+} /* int ps_read_io (...) */
 
-       return (ps);
-} /* procstat_t *ps_read_io */
+static void ps_fill_details (const procstat_t *ps, procstat_entry_t *entry)
+{
+       if ( entry->has_io == 0 && ps_read_io (entry) != 0 )
+       {
+               /* no io data */
+               entry->io_rchar = -1;
+               entry->io_wchar = -1;
+               entry->io_syscr = -1;
+               entry->io_syscw = -1;
+
+               DEBUG("ps_read_process: not get io data for pid %li", entry->id);
+       }
+       entry->has_io = 1;
+
+       if ( report_ctx_switch )
+       {
+               if ( entry->has_cswitch == 0 && ps_read_tasks_status(entry) != 0 )
+               {
+                       entry->cswitch_vol = -1;
+                       entry->cswitch_invol = -1;
+
+                       DEBUG("ps_read_tasks_status: not get context "
+                                       "switch data for pid %li", entry->id);
+               }
+               entry->has_cswitch = 1;
+       }
+} /* void ps_fill_details (...) */
 
 static int ps_read_process (long pid, procstat_t *ps, char *state)
 {
@@ -1136,29 +1157,6 @@ static int ps_read_process (long pid, procstat_t *ps, char *state)
        ps->vmem_rss = (unsigned long) vmem_rss;
        ps->stack_size = (unsigned long) stack_size;
 
-       if ( (ps_read_io (pid, ps)) == NULL)
-       {
-               /* no io data */
-               ps->io_rchar = -1;
-               ps->io_wchar = -1;
-               ps->io_syscr = -1;
-               ps->io_syscw = -1;
-
-               DEBUG("ps_read_process: not get io data for pid %li", pid);
-       }
-
-       if ( report_ctx_switch )
-       {
-               if ( (ps_read_tasks_status(pid, ps)) == NULL)
-               {
-                       ps->cswitch_vol = -1;
-                       ps->cswitch_invol = -1;
-
-                       DEBUG("ps_read_tasks_status: not get context "
-                                       "switch data for pid %li", pid);
-               }
-       }
-
        /* success */
        return (0);
 } /* int ps_read_process (...) */
@@ -1847,14 +1845,10 @@ static int ps_read (void)
                pse.vmem_code  = ps.vmem_code;
                pse.stack_size = ps.stack_size;
 
-               pse.vmem_minflt = 0;
                pse.vmem_minflt_counter = ps.vmem_minflt_counter;
-               pse.vmem_majflt = 0;
                pse.vmem_majflt_counter = ps.vmem_majflt_counter;
 
-               pse.cpu_user = 0;
                pse.cpu_user_counter = ps.cpu_user_counter;
-               pse.cpu_system = 0;
                pse.cpu_system_counter = ps.cpu_system_counter;
 
                pse.io_rchar = ps.io_rchar;
@@ -1979,13 +1973,9 @@ static int ps_read (void)
                        pse.vmem_data = procs[i].ki_dsize * pagesize;
                        pse.vmem_code = procs[i].ki_tsize * pagesize;
                        pse.stack_size = procs[i].ki_ssize * pagesize;
-                       pse.vmem_minflt = 0;
                        pse.vmem_minflt_counter = procs[i].ki_rusage.ru_minflt;
-                       pse.vmem_majflt = 0;
                        pse.vmem_majflt_counter = procs[i].ki_rusage.ru_majflt;
 
-                       pse.cpu_user = 0;
-                       pse.cpu_system = 0;
                        pse.cpu_user_counter = 0;
                        pse.cpu_system_counter = 0;
                        /*
@@ -2125,13 +2115,9 @@ static int ps_read (void)
                        pse.vmem_code = procs[i].p_vm_tsize * pagesize;
                        pse.stack_size = procs[i].p_vm_ssize * pagesize;
                        pse.vmem_size = pse.stack_size + pse.vmem_code + pse.vmem_data;
-                       pse.vmem_minflt = 0;
                        pse.vmem_minflt_counter = procs[i].p_uru_minflt;
-                       pse.vmem_majflt = 0;
                        pse.vmem_majflt_counter = procs[i].p_uru_majflt;
 
-                       pse.cpu_user = 0;
-                       pse.cpu_system = 0;
                        pse.cpu_user_counter = procs[i].p_uutime_usec +
                                                (1000000lu * procs[i].p_uutime_sec);
                        pse.cpu_system_counter = procs[i].p_ustime_usec +
@@ -2263,7 +2249,6 @@ static int ps_read (void)
                                        break;
                        }
 
-                       pse.cpu_user = 0;
                        /* tv_usec is nanosec ??? */
                        pse.cpu_user_counter = procentry[i].pi_ru.ru_utime.tv_sec * 1000000 +
                                procentry[i].pi_ru.ru_utime.tv_usec / 1000;
@@ -2273,9 +2258,7 @@ static int ps_read (void)
                        pse.cpu_system_counter = procentry[i].pi_ru.ru_stime.tv_sec * 1000000 +
                                procentry[i].pi_ru.ru_stime.tv_usec / 1000;
 
-                       pse.vmem_minflt = 0;
                        pse.vmem_minflt_counter = procentry[i].pi_minflt;
-                       pse.vmem_majflt = 0;
                        pse.vmem_majflt_counter = procentry[i].pi_majflt;
 
                        pse.vmem_size = procentry[i].pi_tsize + procentry[i].pi_dvm * pagesize;
@@ -2373,14 +2356,10 @@ static int ps_read (void)
                pse.vmem_code  = ps.vmem_code;
                pse.stack_size = ps.stack_size;
 
-               pse.vmem_minflt = 0;
                pse.vmem_minflt_counter = ps.vmem_minflt_counter;
-               pse.vmem_majflt = 0;
                pse.vmem_majflt_counter = ps.vmem_majflt_counter;
 
-               pse.cpu_user = 0;
                pse.cpu_user_counter = ps.cpu_user_counter;
-               pse.cpu_system = 0;
                pse.cpu_system_counter = ps.cpu_system_counter;
 
                pse.io_rchar = ps.io_rchar;
@@ -2425,6 +2404,8 @@ static int ps_read (void)
        read_fork_rate();
 #endif /* KERNEL_SOLARIS */
 
+       want_init = 0;
+
        return (0);
 } /* int ps_read */
 
index ae35c42..f7fd256 100644 (file)
@@ -69,7 +69,6 @@ static void submit (const char *protocol_name,
 
   vl.values = &value;
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "protocols", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, protocol_name, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, "protocol_counter", sizeof (vl.type));
index 7f57571..c3c8efa 100644 (file)
@@ -256,7 +256,6 @@ static void redis_submit (char *plugin_instance,
 
   vl.values = &value;
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "redis", sizeof (vl.plugin));
   if (plugin_instance != NULL)
     sstrncpy (vl.plugin_instance, plugin_instance,
index 07eac7b..6d45ac9 100644 (file)
@@ -287,10 +287,31 @@ static int rc_config (oconfig_item_t *ci)
   return (0);
 } /* int rc_config */
 
+static int try_reconnect (void)
+{
+  int status;
+
+  rrdc_disconnect ();
+
+  rrd_clear_error ();
+  status = rrdc_connect (daemon_address);
+  if (status != 0)
+  {
+    ERROR ("rrdcached plugin: Failed to reconnect to RRDCacheD "
+        "at %s: %s (status=%d)", daemon_address, rrd_get_error (), status);
+    return (-1);
+  }
+
+  INFO ("rrdcached plugin: Successfully reconnected to RRDCacheD "
+      "at %s", daemon_address);
+  return (0);
+} /* int try_reconnect */
+
 static int rc_read (void)
 {
   int status;
   rrdc_stats_t *head;
+  _Bool retried = 0;
 
   value_list_t vl = VALUE_LIST_INIT;
   vl.values = &(value_t) { .gauge = NAN };
@@ -302,26 +323,40 @@ static int rc_read (void)
   if (!config_collect_stats)
     return (-1);
 
-  if ((strncmp ("unix:", daemon_address, strlen ("unix:")) == 0)
-      || (daemon_address[0] == '/'))
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-  else
+  if ((strncmp ("unix:", daemon_address, strlen ("unix:")) != 0)
+      && (daemon_address[0] != '/'))
     sstrncpy (vl.host, daemon_address, sizeof (vl.host));
   sstrncpy (vl.plugin, "rrdcached", sizeof (vl.plugin));
 
+  rrd_clear_error ();
   status = rrdc_connect (daemon_address);
   if (status != 0)
   {
-    ERROR ("rrdcached plugin: rrdc_connect (%s) failed with status %i.",
-        daemon_address, status);
+    ERROR ("rrdcached plugin: Failed to connect to RRDCacheD "
+        "at %s: %s (status=%d)", daemon_address, rrd_get_error (), status);
     return (-1);
   }
 
-  head = NULL;
-  status = rrdc_stats_get (&head);
-  if (status != 0)
+  while (42)
   {
-    ERROR ("rrdcached plugin: rrdc_stats_get failed with status %i.", status);
+    /* The RRD client lib does not provide any means for checking a
+     * connection, hence we'll have to retry upon failed operations. */
+    head = NULL;
+    rrd_clear_error ();
+    status = rrdc_stats_get (&head);
+    if (status == 0)
+      break;
+
+    if (!retried)
+    {
+      retried = 1;
+      if (try_reconnect () == 0)
+        continue;
+      /* else: report the error and fail */
+    }
+
+    ERROR ("rrdcached plugin: rrdc_stats_get failed: %s (status=%i).",
+        rrd_get_error (), status);
     return (-1);
   }
 
@@ -409,6 +444,7 @@ static int rc_write (const data_set_t *ds, const value_list_t *vl,
   char values[512];
   char *values_array[2];
   int status;
+  _Bool retried = 0;
 
   if (daemon_address == NULL)
   {
@@ -465,20 +501,34 @@ static int rc_write (const data_set_t *ds, const value_list_t *vl,
     }
   }
 
+  rrd_clear_error ();
   status = rrdc_connect (daemon_address);
   if (status != 0)
   {
-    ERROR ("rrdcached plugin: rrdc_connect (%s) failed with status %i.",
-        daemon_address, status);
+    ERROR ("rrdcached plugin: Failed to connect to RRDCacheD "
+        "at %s: %s (status=%d)", daemon_address, rrd_get_error (), status);
     return (-1);
   }
 
-  status = rrdc_update (filename, /* values_num = */ 1, (void *) values_array);
-  if (status != 0)
+  while (42)
   {
-    ERROR ("rrdcached plugin: rrdc_update (%s, [%s], 1) failed with "
-        "status %i.",
-        filename, values_array[0], status);
+    /* The RRD client lib does not provide any means for checking a
+     * connection, hence we'll have to retry upon failed operations. */
+    rrd_clear_error ();
+    status = rrdc_update (filename, /* values_num = */ 1, (void *) values_array);
+    if (status == 0)
+      break;
+
+    if (!retried)
+    {
+      retried = 1;
+      if (try_reconnect () == 0)
+        continue;
+      /* else: report the error and fail */
+    }
+
+    ERROR ("rrdcached plugin: rrdc_update (%s, [%s], 1) failed: %s (status=%i)",
+        filename, values_array[0], rrd_get_error (), status);
     return (-1);
   }
 
@@ -491,6 +541,7 @@ static int rc_flush (__attribute__((unused)) cdtime_t timeout, /* {{{ */
 {
   char filename[PATH_MAX + 1];
   int status;
+  _Bool retried = 0;
 
   if (identifier == NULL)
     return (EINVAL);
@@ -500,19 +551,34 @@ static int rc_flush (__attribute__((unused)) cdtime_t timeout, /* {{{ */
   else
     ssnprintf (filename, sizeof (filename), "%s.rrd", identifier);
 
+  rrd_clear_error ();
   status = rrdc_connect (daemon_address);
   if (status != 0)
   {
-    ERROR ("rrdcached plugin: rrdc_connect (%s) failed with status %i.",
-        daemon_address, status);
+    ERROR ("rrdcached plugin: Failed to connect to RRDCacheD "
+        "at %s: %s (status=%d)", daemon_address, rrd_get_error (), status);
     return (-1);
   }
 
-  status = rrdc_flush (filename);
-  if (status != 0)
+  while (42)
   {
-    ERROR ("rrdcached plugin: rrdc_flush (%s) failed with status %i.",
-        filename, status);
+    /* The RRD client lib does not provide any means for checking a
+     * connection, hence we'll have to retry upon failed operations. */
+    rrd_clear_error ();
+    status = rrdc_flush (filename);
+    if (status == 0)
+      break;
+
+    if (!retried)
+    {
+      retried = 1;
+      if (try_reconnect () == 0)
+        continue;
+      /* else: report the error and fail */
+    }
+
+    ERROR ("rrdcached plugin: rrdc_flush (%s) failed: %s (status=%i).",
+        filename, rrd_get_error (), status);
     return (-1);
   }
   DEBUG ("rrdcached plugin: rrdc_flush (%s): Success.", filename);
index f13b3ea..438cd74 100644 (file)
@@ -503,7 +503,6 @@ static void sensors_submit (const char *plugin_instance,
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "sensors", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
index 4822320..dc868fc 100644 (file)
@@ -41,7 +41,6 @@ static void serial_submit (const char *type_instance,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "serial", sizeof (vl.plugin));
        sstrncpy (vl.type, "serial_octets", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance,
index 5b85004..78837cf 100644 (file)
@@ -200,10 +200,8 @@ static void sigrok_feed_callback(const struct sr_dev_inst *sdi,
        analog = packet->payload;
        vl.values = &(value_t) { .gauge = analog->data[0] };
        vl.values_len = 1;
-       sstrncpy(vl.host, hostname_g, sizeof(vl.host));
        sstrncpy(vl.plugin, "sigrok", sizeof(vl.plugin));
-       ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance),
-                       "%s", cfdev->name);
+       sstrncpy(vl.plugin_instance, cfdev->name, sizeof(vl.plugin_instance));
        sstrncpy(vl.type, sigrok_value_type(analog), sizeof(vl.type));
 
        plugin_dispatch_values(&vl);
index 52e78a1..285eb86 100644 (file)
@@ -90,7 +90,6 @@ static void smart_submit (const char *dev, const char *type,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "smart", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
@@ -117,7 +116,6 @@ static void smart_handle_disk_attribute(SkDisk *d, const SkSmartAttributeParsedD
 
   vl.values = values;
   vl.values_len = STATIC_ARRAY_SIZE (values);
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "smart", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, "smart_attribute", sizeof (vl.type));
index 82ae387..491fe42 100644 (file)
@@ -756,7 +756,6 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
 
   vl.values = &(value_t) { .gauge = NAN };
   vl.values_len = 1;
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "statsd", sizeof (vl.plugin));
 
   if (metric->type == STATSD_GAUGE)
index 3cc9516..403b148 100644 (file)
@@ -198,7 +198,6 @@ static void swap_submit_usage (char const *plugin_instance, /* {{{ */
 
        vl.values = &(value_t) { .gauge = NAN };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
        if (plugin_instance != NULL)
                sstrncpy (vl.plugin_instance, plugin_instance,
@@ -224,7 +223,6 @@ static void swap_submit_derive (char const *type_instance, /* {{{ */
 
        vl.values = &(value_t) { .derive = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
        sstrncpy (vl.type, "swap_io", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
index 81e9461..7181795 100644 (file)
@@ -384,7 +384,6 @@ static int tbl_result_dispatch (tbl_t *tbl, tbl_result_t *res,
        vl.values     = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "table", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, tbl->instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, res->type, sizeof (vl.type));
index faeb56f..0247387 100644 (file)
@@ -69,7 +69,6 @@ static int tcsv_submit (instance_definition_t *id,
     vl.values_len = 1;
     vl.values = &v;
 
-    sstrncpy(vl.host, hostname_g, sizeof (vl.host));
     sstrncpy(vl.plugin, "tail_csv", sizeof(vl.plugin));
     if (id->instance != NULL)
         sstrncpy(vl.plugin_instance, id->instance, sizeof(vl.plugin_instance));
@@ -535,7 +534,7 @@ static int tcsv_init(void) { /* {{{ */
         else if (ds->ds_num != 1)
         {
             ERROR ("tail_csv plugin: The type \"%s\" has %zu data sources. "
-                    "Only types with a single data soure are supported.",
+                    "Only types with a single data source are supported.",
                     ds->type, ds->ds_num);
             continue;
         }
index 8ec9bf2..c7d56c7 100644 (file)
@@ -69,7 +69,6 @@ static void tape_submit (const char *plugin_instance,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "tape", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
index e74e4bc..8c93405 100644 (file)
@@ -296,7 +296,6 @@ static void conn_prepare_vl (value_list_t *vl, value_t *values)
 {
   vl->values = values;
   vl->values_len = 1;
-  sstrncpy (vl->host, hostname_g, sizeof (vl->host));
   sstrncpy (vl->plugin, "tcpconns", sizeof (vl->plugin));
   sstrncpy (vl->type, "tcp_connections", sizeof (vl->type));
 }
index a709e79..1bd969b 100644 (file)
@@ -125,7 +125,6 @@ static void tss2_submit_gauge (const char *plugin_instance,
 
        vl.values     = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin));
 
        if (plugin_instance != NULL)
@@ -155,7 +154,6 @@ static void tss2_submit_io (const char *plugin_instance, const char *type,
 
        vl.values     = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin));
 
        if (plugin_instance != NULL)
index f167546..001eddf 100644 (file)
--- a/src/ted.c
+++ b/src/ted.c
@@ -267,7 +267,6 @@ static void ted_submit (const char *type, double value)
 
     vl.values = &(value_t) { .gauge = value };
     vl.values_len = 1;
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "ted", sizeof (vl.plugin));
     sstrncpy (vl.type, type, sizeof (vl.type));
 
index aa95dac..09d9157 100644 (file)
@@ -54,7 +54,6 @@ static void thermal_submit (const char *plugin_instance, enum dev_type dt,
        vl.values = &value;
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin));
        if (plugin_instance != NULL)
                sstrncpy (vl.plugin_instance, plugin_instance,
index e74cba2..3132149 100644 (file)
@@ -527,7 +527,6 @@ turbostat_submit (const char *plugin_instance,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, PLUGIN_NAME, sizeof (vl.plugin));
        if (plugin_instance != NULL)
                sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
index e3da48a..cb7501e 100644 (file)
@@ -114,12 +114,14 @@ if_tx_packets           value:DERIVE:0:U
 invocations             value:DERIVE:0:U
 io_octets               rx:DERIVE:0:U, tx:DERIVE:0:U
 io_packets              rx:DERIVE:0:U, tx:DERIVE:0:U
+ipc                     value:GAUGE:0:U
 ipt_bytes               value:DERIVE:0:U
 ipt_packets             value:DERIVE:0:U
 irq                     value:DERIVE:0:U
 latency                 value:GAUGE:0:U
 links                   value:GAUGE:0:U
 load                    shortterm:GAUGE:0:5000, midterm:GAUGE:0:5000, longterm:GAUGE:0:5000
+memory_bandwidth        value:DERIVE:0:U
 md_disks                value:GAUGE:0:U
 memcached_command       value:DERIVE:0:U
 memcached_connections   value:GAUGE:0:U
index 34c3e85..f0e1a6f 100644 (file)
@@ -65,7 +65,6 @@ static void uptime_submit (gauge_t value)
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "uptime", sizeof (vl.plugin));
        sstrncpy (vl.type, "uptime", sizeof (vl.type));
 
index ce626ae..e0c5116 100644 (file)
@@ -49,7 +49,6 @@ static void users_submit (gauge_t value)
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "users", sizeof (vl.plugin));
        sstrncpy (vl.type, "users", sizeof (vl.plugin));
 
index b3765e9..b5a8e61 100644 (file)
@@ -111,7 +111,7 @@ static int checked_lookup_search (lookup_t *obj,
     _Bool expect_new)
 {
   int status;
-  value_list_t vl = VALUE_LIST_STATIC;
+  value_list_t vl = VALUE_LIST_INIT;
   data_set_t const *ds = &ds_unknown;
 
   strncpy (vl.host, host, sizeof (vl.host));
index 18f5902..e1464dc 100644 (file)
@@ -94,13 +94,10 @@ static int varnish_submit (const char *plugin_instance, /* {{{ */
        vl.values = &value;
        vl.values_len = 1;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-
        sstrncpy (vl.plugin, "varnish", sizeof (vl.plugin));
 
        if (plugin_instance == NULL)
                plugin_instance = "default";
-
        ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
                "%s-%s", plugin_instance, category);
 
index 027f7bd..98c4c2a 100644 (file)
@@ -51,7 +51,6 @@ static void submit (const char *plugin_instance, const char *type,
   vl.values = values;
   vl.values_len = values_len;
 
-  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "vmem", sizeof (vl.plugin));
   if (plugin_instance != NULL)
     sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
index f3a2b5a..0e58a97 100644 (file)
@@ -64,7 +64,6 @@ static void traffic_submit (const char *plugin_instance,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, "if_octets", sizeof (vl.type));
@@ -85,7 +84,6 @@ static void load_submit (const char *plugin_instance,
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, "load", sizeof (vl.type));
@@ -101,7 +99,6 @@ static void submit_gauge (const char *plugin_instance, const char *type,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
@@ -129,15 +126,7 @@ static derive_t vserver_get_sock_bytes(const char *s)
 
 static int vserver_read (void)
 {
-#if NAME_MAX < 1024
-# define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + 1024 + 1)
-#else
-# define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + NAME_MAX + 1)
-#endif
-
-       DIR                     *proc;
-       struct dirent   *dent; /* 42 */
-       char dirent_buffer[DIRENT_BUFFER_SIZE];
+       DIR *proc;
 
        errno = 0;
        proc = opendir (PROCDIR);
@@ -151,6 +140,7 @@ static int vserver_read (void)
 
        while (42)
        {
+               struct dirent *dent;
                int len;
                char file[BUFSIZE];
 
@@ -162,20 +152,20 @@ static int vserver_read (void)
 
                int status;
 
-               status = readdir_r (proc, (struct dirent *) dirent_buffer, &dent);
-               if (status != 0)
+               errno = 0;
+               dent = readdir (proc);
+               if (dent == NULL)
                {
                        char errbuf[4096];
-                       ERROR ("vserver plugin: readdir_r failed: %s",
-                                       sstrerror (errno, errbuf, sizeof (errbuf)));
+
+                       if (errno == 0) /* end of directory */
+                               break;
+
+                       ERROR ("vserver plugin: failed to read directory %s: %s",
+                                       PROCDIR, sstrerror (errno, errbuf, sizeof (errbuf)));
                        closedir (proc);
                        return (-1);
                }
-               else if (dent == NULL)
-               {
-                       /* end of directory */
-                       break;
-               }
 
                if (dent->d_name[0] == '.')
                        continue;
index 7d57fea..16aad50 100644 (file)
@@ -58,7 +58,6 @@ static void wireless_submit (const char *plugin_instance, const char *type,
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "wireless", sizeof (vl.plugin));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
index ebc5ce2..ad8dfce 100644 (file)
 
 #include <netdb.h>
 
-#define WG_DEFAULT_NODE "localhost"
-#define WG_DEFAULT_SERVICE "2003"
-#define WG_DEFAULT_PROTOCOL "tcp"
-#define WG_DEFAULT_LOG_SEND_ERRORS 1
-#define WG_DEFAULT_ESCAPE '_'
+#ifndef WG_DEFAULT_NODE
+# define WG_DEFAULT_NODE "localhost"
+#endif
+
+#ifndef WG_DEFAULT_SERVICE
+# define WG_DEFAULT_SERVICE "2003"
+#endif
+
+#ifndef WG_DEFAULT_PROTOCOL
+# define WG_DEFAULT_PROTOCOL "tcp"
+#endif
+
+#ifndef WG_DEFAULT_LOG_SEND_ERRORS
+# define WG_DEFAULT_LOG_SEND_ERRORS 1
+#endif
+
+#ifndef WG_DEFAULT_ESCAPE
+# define WG_DEFAULT_ESCAPE '_'
+#endif
 
 /* Ethernet - (IPv6 + TCP) = 1500 - (40 + 32) = 1428 */
-#define WG_SEND_BUF_SIZE 1428
+#ifndef WG_SEND_BUF_SIZE
+# define WG_SEND_BUF_SIZE 1428
+#endif
 
-#define WG_MIN_RECONNECT_INTERVAL TIME_T_TO_CDTIME_T (1)
+#ifndef WG_MIN_RECONNECT_INTERVAL
+# define WG_MIN_RECONNECT_INTERVAL TIME_T_TO_CDTIME_T (1)
+#endif
 
 /*
  * Private variables
index 3d1fe3d..a7bb2e0 100644 (file)
@@ -820,13 +820,10 @@ static int wh_config_node (oconfig_item_t *ci) /* {{{ */
                         callback_name, cb->location);
 
         user_data_t user_data = {
-                .data = cb
+                .data = cb,
+                .free_func = wh_callback_free,
         };
 
-        plugin_register_flush (callback_name, wh_flush, &user_data);
-
-        user_data.free_func = wh_callback_free;
-
         if (cb->send_metrics)
         {
                 plugin_register_write (callback_name, wh_write, &user_data);
index def3d9c..bafbfe5 100644 (file)
@@ -91,7 +91,7 @@ static int wr_write (const data_set_t *ds, /* {{{ */
     node->conn = redisConnectWithTimeout ((char *)node->host, node->port, node->timeout);
     if (node->conn == NULL)
     {
-      ERROR ("write_redis plugin: Connecting to host \"%s\" (port %i) failed: Unkown reason",
+      ERROR ("write_redis plugin: Connecting to host \"%s\" (port %i) failed: Unknown reason",
           (node->host != NULL) ? node->host : "localhost",
           (node->port != 0) ? node->port : 6379);
       pthread_mutex_unlock (&node->lock);
index 93575df..de375d2 100644 (file)
@@ -115,7 +115,6 @@ static void submit_value (int cpu_num, gauge_t value)
     vl.values = &(value_t) { .gauge = value };
     vl.values_len = 1;
 
-    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "xencpu", sizeof (vl.plugin));
     sstrncpy (vl.type, "percent", sizeof (vl.type));
     sstrncpy (vl.type_instance, "load", sizeof (vl.type_instance));
index 2ba3082..5a2774b 100644 (file)
@@ -39,7 +39,6 @@ static void cxmms_submit (const char *type, gauge_t value)
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "xmms", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
 
index e411085..ad287bb 100644 (file)
@@ -145,7 +145,6 @@ static void za_submit (const char* type, const char* type_instance, value_t* val
        vl.values = values;
        vl.values_len = values_len;
 
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "zfs_arc", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
index d9e46f5..bd51c55 100644 (file)
@@ -91,7 +91,6 @@ zone_submit_value(char *zone, gauge_t value)
 
        vl.values = values;
        vl.values_len = 1; /*STATIC_ARRAY_SIZE (values);*/
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "zone", sizeof (vl.plugin));
        sstrncpy (vl.type, "percent", sizeof (vl.type));
        sstrncpy (vl.type_instance, zone, sizeof (vl.type_instance));
index 7e55191..539112e 100644 (file)
@@ -72,7 +72,6 @@ static void zookeeper_submit_gauge (const char * type, const char * type_inst, g
 
        vl.values = &(value_t) { .gauge = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        if (type_inst != NULL)
@@ -87,7 +86,6 @@ static void zookeeper_submit_derive (const char * type, const char * type_inst,
 
        vl.values = &(value_t) { .derive = value };
        vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        if (type_inst != NULL)
index 2ef5279..e106d80 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEFAULT_VERSION="5.6.0.git"
+DEFAULT_VERSION="5.6.1.git"
 
 if [ -d .git ]; then
        VERSION="`git describe --dirty=+ --abbrev=7 2> /dev/null | grep collectd | sed -e 's/^collectd-//' -e 's/-/./g'`"