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
[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
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
+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
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.
- 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.
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.
- 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.
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).
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'.
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
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.
* 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
* 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)
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.
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
-------------------------------
The `build.sh' script takes no arguments.
+
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
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.
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=""
plugin_gps="no"
plugin_grpc="no"
plugin_hugepages="no"
+plugin_intel_rdt="no"
plugin_interface="no"
plugin_ipmi="no"
plugin_ipvs="no"
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])
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])
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])
#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)));
* 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
%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
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
%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
%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
%{?_with_disk} \
%{?_with_dns} \
%{?_with_drbd} \
+ %{?_with_dpdkstat} \
%{?_with_email} \
%{?_with_entropy} \
%{?_with_ethstat} \
%{?_with_grpc} \
%{?_with_hddtemp} \
%{?_with_hugepages} \
+ %{?_with_intel_rdt} \
%{?_with_interface} \
%{?_with_ipc} \
%{?_with_ipmi} \
%if %{with_drbd}
%{_libdir}/%{name}/drbd.so
%endif
+%if %{with_dpdkstat}
+%{_libdir}/%{name}/dpdkstat.so
+%endif
%if %{with_ethstat}
%{_libdir}/%{name}/ethstat.so
%endif
%{_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
%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
--- /dev/null
+# 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`.
--- /dev/null
+# 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`.
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
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
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)
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));
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));
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));
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)
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));
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));
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));
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));
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));
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 =
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,
}
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));
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));
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)
{
=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)>
#@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>
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).
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
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.
=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
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>
=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
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.
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>
=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>
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
=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
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)
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));
/* #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;
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],
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) /* {{{ */
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.
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));
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);
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));
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));
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));
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));
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);
* something wrong.
*/
if (init_global_variables () != 0)
- return (1);
+ exit (EXIT_FAILURE);
if (test_config)
return (0);
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
}
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;
} /* }}} 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;
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)
{
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;
} /* 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));
} /* 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 ();
}
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)
} /* 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));
} /* 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));
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)
{
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; "
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);
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 */
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);
};
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
{
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);
*
* 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
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));
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,
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));
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));
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));
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));
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));
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;
}
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);
}
}
}
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));
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));
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));
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)
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",
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));
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));
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));
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));
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;
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));
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",
--- /dev/null
+/**
+ * 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);
+}
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));
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));
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));
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),
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),
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));
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));
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));
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));
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));
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 */
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));
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));
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));
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);
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));
struct memcached_s
{
char *name;
- char *socket;
char *host;
- char *port;
+ char *socket;
+ char *connhost;
+ char *connport;
};
typedef struct memcached_s memcached_t;
return;
sfree (st->name);
- sfree (st->socket);
sfree (st->host);
- sfree (st->port);
+ sfree (st->socket);
+ sfree (st->connhost);
+ sfree (st->connport);
sfree (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));
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));
}
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,
* <Plugin memcached>
* <Instance "instance_name">
* Host foo.zomg.com
+ * Address 1.2.3.4
* Port "1234"
* </Instance>
* </Plugin>
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++)
{
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.",
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)
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 ();
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));
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));
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));
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));
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));
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
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 */
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));
#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.");
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)
/*
* 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]));
}
}
}
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));
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));
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,
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));
/* 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));
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));
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)
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,
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,
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));
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));
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));
</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>
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)
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;
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;
static procstat_t *list_head_g = NULL;
+static _Bool want_init = 1;
static _Bool report_ctx_switch = 0;
#if HAVE_THREAD_INFO
#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)
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) */
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;
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);
}
}
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));
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));
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));
/* ------- 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;
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)
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);
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 */
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];
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)
{
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)
{
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 (...) */
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;
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;
/*
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 +
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;
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;
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;
read_fork_rate();
#endif /* KERNEL_SOLARIS */
+ want_init = 0;
+
return (0);
} /* int ps_read */
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));
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,
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 };
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);
}
char values[512];
char *values_array[2];
int status;
+ _Bool retried = 0;
if (daemon_address == NULL)
{
}
}
+ 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);
}
{
char filename[PATH_MAX + 1];
int status;
+ _Bool retried = 0;
if (identifier == NULL)
return (EINVAL);
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);
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));
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,
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);
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));
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));
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)
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,
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));
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));
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));
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;
}
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));
{
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));
}
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)
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)
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));
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,
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));
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
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));
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));
_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));
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);
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));
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));
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));
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));
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);
while (42)
{
+ struct dirent *dent;
int len;
char file[BUFSIZE];
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;
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));
#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
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);
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);
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));
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));
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));
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));
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)
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)
#!/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'`"