Merge pull request #2923 from qdbp/gpu_nvml_plugin
authorFlorian Forster <ff@octo.it>
Sat, 27 Oct 2018 07:14:25 +0000 (09:14 +0200)
committerGitHub <noreply@github.com>
Sat, 27 Oct 2018 07:14:25 +0000 (09:14 +0200)
New plugin: gpu_nvidia collects NVIDIA GPU stats.

1  2 
configure.ac
src/collectd.conf.pod

diff --combined configure.ac
@@@ -2074,6 -2074,58 +2074,58 @@@ if test "x$with_kvm_openfiles" = "xyes"
    with_libkvm="yes"
  fi
  
+ # --with-cuda {{{
+ # only CUDA provides the nvml.h header
+ AC_ARG_WITH([cuda],
+   [AS_HELP_STRING([--with-cuda@<:@=PREFIX@:>@], [Path to cuda.])],
+   [
+     if test "x$withval" = "xyes"; then
+       with_cuda="yes"
+     else if test "x$withval" = "xno"; then
+       with_cuda="no"
+     else
+       with_cuda="yes"
+       CUDA_CFLAGS="$CUDA_CFLAGS -I$withval/include"
+       CUDA_LDFLAGS="$CUDA_LDFLAGS -L$withval/lib"
+     fi; fi
+   ],
+   [ with_cuda="yes"
+     CUDA_CFLAGS="$CUDA_CFLAGS -I/opt/cuda/include"
+     CUDA_LDFLAGS="$CUDA_LDFLAGS -L/opt/cuda/lib64"
+   ]
+ )
+ SAVE_CFLAGS="$CFLAGS"
+ SAVE_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS $CUDA_CFLAGS"
+ LDFLAGS="$LDFLAGS $CUDA_LDFLAGS"
+ if test "x$with_cuda" = "xyes"; then
+   AC_CHECK_HEADERS([nvml.h],
+     [with_cuda="yes"],
+     [with_cuda="no (header file missing)"]
+   )
+ fi
+ if test "x$with_cuda" = "xpkgconfig"; then
+   AC_CHECK_HEADERS([nvml.h],
+     [],
+     [with_cuda="no (header file missing)"]
+   )
+ fi
+ if test "x$with_cuda" = "xyes"; then
+   BUILD_WITH_CUDA_CFLAGS="$CUDA_CFLAGS"
+   BUILD_WITH_CUDA_LDFLAGS="$CUDA_LDFLAGS"
+   BUILD_WITH_CUDA_LIBS="-lnvidia-ml"
+ fi
+ AC_SUBST([BUILD_WITH_CUDA_CFLAGS])
+ AC_SUBST([BUILD_WITH_CUDA_LDFLAGS])
+ AC_SUBST([BUILD_WITH_CUDA_LIBS])
+ # }}}
  # --with-libaquaero5 {{{
  AC_ARG_WITH([libaquaero5],
    [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
@@@ -5745,15 -5797,15 +5797,15 @@@ if test "x$with_libxmms" = "xyes"; the
  fi
  
  if test "x$with_libxmms" = "xyes"; then
 -  SAVE_CFLAGS="$CFLAGS"
 -  CFLAGS="$with_xmms_cflags"
 +  SAVE_CPPFLAGS="$CFLAGS"
 +  CPPFLAGS="$with_xmms_cflags"
  
    AC_CHECK_HEADER([xmmsctrl.h],
      [with_libxmms="yes"],
      [with_libxmms="no"],
    )
  
 -  CFLAGS="$SAVE_CFLAGS"
 +  CPPFLAGS="$SAVE_CPPFLAGS"
  fi
  
  if test "x$with_libxmms" = "xyes"; then
@@@ -6362,6 -6414,7 +6414,7 @@@ plugin_ethstat="no
  plugin_fhcount="no"
  plugin_fscache="no"
  plugin_gps="no"
+ plugin_gpu_nvidia="no"
  plugin_grpc="no"
  plugin_hugepages="no"
  plugin_intel_pmu="no"
@@@ -6792,6 -6845,7 +6845,7 @@@ AC_PLUGIN([filecount],           [yes]
  AC_PLUGIN([fscache],             [$plugin_fscache],           [fscache statistics])
  AC_PLUGIN([gmond],               [$with_libganglia],          [Ganglia plugin])
  AC_PLUGIN([gps],                 [$plugin_gps],               [GPS plugin])
+ AC_PLUGIN([gpu_nvidia],          [$with_cuda],                [NVIDIA GPU plugin])
  AC_PLUGIN([grpc],                [$plugin_grpc],              [gRPC plugin])
  AC_PLUGIN([hddtemp],             [yes],                       [Query hddtempd])
  AC_PLUGIN([hugepages],           [$plugin_hugepages],         [Hugepages statistics])
@@@ -7102,6 -7156,7 +7156,7 @@@ AC_MSG_RESULT([    YACC  . . . . . . . 
  AC_MSG_RESULT([    YFLAGS  . . . . . . . $YFLAGS])
  AC_MSG_RESULT()
  AC_MSG_RESULT([  Libraries:])
+ AC_MSG_RESULT([    cuda  . . . . . . . . $with_cuda])
  AC_MSG_RESULT([    intel mic . . . . . . $with_mic])
  AC_MSG_RESULT([    libaquaero5 . . . . . $with_libaquaero5])
  AC_MSG_RESULT([    libatasmart . . . . . $with_libatasmart])
@@@ -7216,6 -7271,7 +7271,7 @@@ AC_MSG_RESULT([    filecount . . . . . 
  AC_MSG_RESULT([    fscache . . . . . . . $enable_fscache])
  AC_MSG_RESULT([    gmond . . . . . . . . $enable_gmond])
  AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
+ AC_MSG_RESULT([    gpu_nvidia  . . . . . $enable_gpu_nvidia])
  AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
  AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
  AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
diff --combined src/collectd.conf.pod
@@@ -3210,6 -3210,30 +3210,30 @@@ Pause to apply between attempts of conn
  
  =back
  
+ =head2 Plugin C<gpu_nvidia>
+ Efficiently collects various statistics from the system's NVIDIA GPUs using the
+ NVML library. Currently collected are fan speed, core temperature, percent
+ load, percent memory used, compute and memory frequencies, and power
+ consumption.
+ =over 4
+ =item B<GPUIndex>
+ If one or more of these options is specified, only GPUs at that index (as
+ determined by nvidia-utils through I<nvidia-smi>) have statistics collected.
+ If no instance of this option is specified, all GPUs are monitored.
+ =item B<IgnoreSelected>
+ If set to true, all detected GPUs B<except> the ones at indices specified by
+ B<GPUIndex> entries are collected. For greater clarity, setting IgnoreSelected
+ without any GPUIndex directives will result in B<no> statistics being
+ collected.
+ =back
  =head2 Plugin C<grpc>
  
  The I<grpc> plugin provides an RPC interface to submit values to or query
@@@ -9673,13 -9697,6 +9697,13 @@@ B<Options:
  
  =over 4
  
 +=item B<Host> I<Host>
 +
 +Bind to the hostname / address I<Host>. By default, the plugin will bind to the
 +"any" address, i.e. accept packets sent to any of the hosts addresses.
 +
 +This option is supported only for libmicrohttpd newer than 0.9.0.
 +
  =item B<Port> I<Port>
  
  Port the embedded webserver should listen on. Defaults to B<9103>.