Merge pull request #2598 from octo/ff/delayacct
authorFlorian Forster <ff@octo.it>
Fri, 8 Dec 2017 18:51:50 +0000 (19:51 +0100)
committerGitHub <noreply@github.com>
Fri, 8 Dec 2017 18:51:50 +0000 (19:51 +0100)
processes plugin: Add support for Linux Delay Accounting.

1  2 
Makefile.am
configure.ac
src/collectd.conf.in
src/collectd.conf.pod

diff --combined Makefile.am
@@@ -516,7 -516,6 +516,7 @@@ liboconfig_la_SOURCES = 
        src/liboconfig/aux_types.h \
        src/liboconfig/scanner.l \
        src/liboconfig/parser.y
 +liboconfig_la_CPPFLAGS = -I$(srcdir)/src/liboconfig $(AM_CPPFLAGS)
  liboconfig_la_LDFLAGS = -avoid-version $(LEXLIB)
  
  
@@@ -1422,14 -1421,28 +1422,28 @@@ python_la_CPPFLAGS = $(AM_CPPFLAGS) $(L
  python_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBPYTHON_LDFLAGS)
  endif
  
+ if HAVE_LIBMNL
+ noinst_LTLIBRARIES += libtaskstats.la
+ libtaskstats_la_SOURCES = \
+       src/utils_taskstats.c \
+       src/utils_taskstats.h
+ libtaskstats_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMNL_CFLAGS)
+ libtaskstats_la_LIBADD = $(BUILD_WITH_LIBMNL_LIBS)
+ endif
  if BUILD_PLUGIN_PROCESSES
  pkglib_LTLIBRARIES += processes.la
  processes_la_SOURCES = src/processes.c
+ processes_la_CPPFLAGS = $(AM_CPPFLAGS)
  processes_la_LDFLAGS = $(PLUGIN_LDFLAGS)
  processes_la_LIBADD =
  if BUILD_WITH_LIBKVM_GETPROCS
  processes_la_LIBADD += -lkvm
  endif
+ if HAVE_LIBMNL
+ processes_la_CPPFLAGS += -DHAVE_LIBTASKSTATS=1
+ processes_la_LIBADD += libtaskstats.la
+ endif
  endif
  
  if BUILD_PLUGIN_PROTOCOLS
diff --combined configure.ac
@@@ -2635,7 -2635,6 +2635,7 @@@ AC_ARG_WITH([libgrpc++]
      if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
        with_libgrpcpp_cppflags="-I$withval/include"
        with_libgrpcpp_ldflags="-L$withval/lib"
 +      with_libgrpcpp_bin="$withval/bin"
        with_libgrpcpp="yes"
      fi
      if test "x$withval" = "xno"; then
@@@ -2715,11 -2714,7 +2715,11 @@@ AC_SUBST([BUILD_WITH_LIBGRPCPP_LIBS]
  # }}}
  
  AC_ARG_VAR([GRPC_CPP_PLUGIN], [path to the grpc_cpp_plugin binary])
 -AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
 +if test "x$with_libgrpcpp_bin" = "x"; then
 +  AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
 +else
 +  AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin], [], "$with_libgrpcpp_bin:$PATH")
 +fi
  AM_CONDITIONAL([HAVE_GRPC_CPP], [test "x$GRPC_CPP_PLUGIN" != "x"])
  
  # --with-libiptc {{{
@@@ -3673,6 -3668,7 +3673,7 @@@ if test "x$with_libmnl" = "xyes"; the
  fi
  AC_SUBST([BUILD_WITH_LIBMNL_CFLAGS])
  AC_SUBST([BUILD_WITH_LIBMNL_LIBS])
+ AM_CONDITIONAL([HAVE_LIBMNL], [test "x$with_libmnl" = "xyes"])
  # }}}
  
  # --with-libnetapp {{{
@@@ -6383,18 -6379,8 +6384,18 @@@ if test "x$with_libgps" = "xyes"; the
    plugin_gps="yes"
  fi
  
 -if test "x$with_libgrpcpp" = "xyes" && test "x$with_libprotobuf" = "xyes" && test "x$have_protoc3" = "xyes" && test "x$GRPC_CPP_PLUGIN" != "x"; then
 -  plugin_grpc="yes"
 +plugin_grpc="yes"
 +if test "x$GRPC_CPP_PLUGIN" = "x"; then
 +  plugin_grpc="no (grpc_cpp_plugin not found)"
 +fi
 +if test "x$have_protoc3" != "xyes"; then
 +  plugin_grpc="no (protoc3 not found)"
 +fi
 +if test "x$with_libprotobuf" != "xyes"; then
 +  plugin_grpc="no (libprotobuf not found)"
 +fi
 +if test "x$with_libgrpcpp" != "xyes"; then
 +  plugin_grpc="no (libgrpc++ not found)"
  fi
  
  if test "x$have_getifaddrs" = "xyes"; then
diff --combined src/collectd.conf.in
  #             SSLCACertificateFile "/path/to/root.pem"
  #             SSLCertificateFile "/path/to/client.pem"
  #             SSLCertificateKeyFile "/path/to/client.key"
 +#             VerifyPeer true
  #     </Listen>
  #</Plugin>
  
  #     CollectFileDescriptor true
  #     CollectContextSwitch true
  #     CollectMemoryMaps true
+ #     CollectDelayAccounting false
  #     Process "name"
  #     ProcessMatch "name" "regex"
  #     <Process "collectd">
  #             CollectFileDescriptor false
  #             CollectContextSwitch false
+ #             CollectDelayAccounting true
  #     </Process>
  #     <ProcessMatch "name" "regex">
  #             CollectFileDescriptor false
diff --combined src/collectd.conf.pod
@@@ -3094,13 -3094,6 +3094,13 @@@ Whether to enable SSL for incoming conn
  Filenames specifying SSL certificate and key material to be used with SSL
  connections.
  
 +=item B<VerifyPeer> B<true>|B<false>
 +
 +When enabled, a valid client certificate is required to connect to the server.
 +When disabled, a client certifiacte is not requested and any unsolicited client
 +certificate is accepted.
 +Enabled by default.
 +
  =back
  
  =back
@@@ -6849,22 -6842,25 +6849,25 @@@ The statistics collected for matched pr
   - number of memory mapped files (under Linux)
   - io data (where available)
   - context switches (under Linux)
-  - minor and major pagefaults.
+  - minor and major pagefaults
+  - Delay Accounting information (Linux only, requires libmnl)
  
  B<Synopsis:>
  
   <Plugin processes>
-    CollectFileDescriptor true
-    CollectContextSwitch true
+    CollectFileDescriptor  true
+    CollectContextSwitch   true
+    CollectDelayAccounting false
     Process "name"
     ProcessMatch "name" "regex"
     <Process "collectd">
-      CollectFileDescriptor false
-      CollectContextSwitch false
+      CollectFileDescriptor  false
+      CollectContextSwitch   false
+      CollectDelayAccounting true
     </Process>
     <ProcessMatch "name" "regex">
       CollectFileDescriptor false
-      CollectContextSwitch true
+      CollectContextSwitch  true
     </Process>
   </Plugin>
  
@@@ -6890,6 -6886,18 +6893,18 @@@ I<name> must not contain slashes
  Collect the number of context switches for matched processes.
  Disabled by default.
  
+ =item B<CollectDelayAccounting> I<Boolean>
+ If enabled, collect Linux Delay Accounding information for matching processes.
+ Delay Accounting provides the time processes wait for the CPU to become
+ available, for I/O operations to finish, for pages to be swapped in and for
+ freed pages to be reclaimed. The metrics are reported as "seconds per second"
+ using the C<delay_rate> type, e.g. C<delay_rate-delay-cpu>.
+ Disabled by default.
+ This option is only available on Linux, requires the C<libmnl> library and
+ requires the C<CAP_NET_ADMIN> capability at runtime.
  =item B<CollectFileDescriptor> I<Boolean>
  
  Collect number of file descriptors of matched processes.
@@@ -6903,9 -6911,12 +6918,12 @@@ the Linux kernel
  
  =back
  
- Options B<CollectContextSwitch> and B<CollectFileDescriptor> may be used inside
- B<Process> and B<ProcessMatch> blocks - then they affect corresponding match
- only. Otherwise they set the default value for subsequent matches.
+ The B<CollectContextSwitch>, B<CollectDelayAccounting>,
+ B<CollectFileDescriptor> and B<CollectMemoryMaps> options may be used inside
+ B<Process> and B<ProcessMatch> blocks. When used there, these options affect
+ reporting the corresponding processes only. Outside of B<Process> and
+ B<ProcessMatch> blocks these options set the default value for subsequent
+ matches.
  
  =head2 Plugin C<protocols>