Merge remote-tracking branch 'github/pr/2472'
authorFlorian Forster <octo@collectd.org>
Thu, 18 Oct 2018 08:49:37 +0000 (10:49 +0200)
committerFlorian Forster <octo@collectd.org>
Thu, 18 Oct 2018 08:49:37 +0000 (10:49 +0200)
1  2 
Makefile.am
src/collectd.conf.pod

diff --combined Makefile.am
@@@ -127,7 -127,7 +127,7 @@@ bin_PROGRAMS = 
  endif # BUILD_WIN32
  
  
 -EXTRA_LTLIBRARIES = \
 +noinst_LTLIBRARIES = \
        libavltree.la \
        libcmds.la \
        libcommon.la \
@@@ -574,6 -574,68 +574,68 @@@ liboconfig_la_SOURCES = 
  liboconfig_la_CPPFLAGS = -I$(srcdir)/src/liboconfig $(AM_CPPFLAGS)
  liboconfig_la_LDFLAGS = -avoid-version $(LEXLIB)
  
+ if BUILD_WITH_LIBCURL
+ if BUILD_WITH_LIBSSL
+ if BUILD_WITH_LIBYAJL2
+ EXTRA_LTLIBRARIES += liboauth.la
+ liboauth_la_SOURCES = \
+       src/utils_oauth.c \
+       src/utils_oauth.h
+ liboauth_la_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       $(BUILD_WITH_LIBCURL_CFLAGS) \
+       $(BUILD_WITH_LIBSSL_CFLAGS) \
+       $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+ liboauth_la_LIBADD = \
+       $(BUILD_WITH_LIBCURL_LIBS) \
+       $(BUILD_WITH_LIBSSL_LIBS) \
+       $(BUILD_WITH_LIBYAJL_LIBS)
+ check_PROGRAMS += test_utils_oauth
+ TESTS += test_utils_oauth
+ test_utils_oauth_SOURCES = \
+       src/utils_oauth_test.c
+ test_utils_oauth_LDADD = \
+       liboauth.la \
+       libcommon.la \
+       libplugin_mock.la
+ EXTRA_LTLIBRARIES += libgce.la
+ libgce_la_SOURCES = \
+       src/utils_gce.c \
+       src/utils_gce.h
+ libgce_la_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       $(BUILD_WITH_LIBCURL_CFLAGS)
+ libgce_la_LIBADD = \
+       $(BUILD_WITH_LIBCURL_LIBS)
+ endif
+ endif
+ endif
+ if BUILD_WITH_LIBYAJL2
+ EXTRA_LTLIBRARIES += libformat_stackdriver.la
+ libformat_stackdriver_la_SOURCES = \
+       src/utils_format_stackdriver.c \
+       src/utils_format_stackdriver.h
+ libformat_stackdriver_la_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+ libformat_stackdriver_la_LIBADD = \
+       libavltree.la \
+       $(BUILD_WITH_LIBSSL_LIBS) \
+       $(BUILD_WITH_LIBYAJL_LIBS)
+ check_PROGRAMS += test_format_stackdriver
+ TESTS += test_format_stackdriver
+ test_format_stackdriver_SOURCES = \
+       src/utils_format_stackdriver_test.c \
+       src/testing.h
+ test_format_stackdriver_LDADD = \
+       libformat_stackdriver.la \
+       libplugin_mock.la \
+       -lm
+ endif
  
  if BUILD_PLUGIN_AGGREGATION
  pkglib_LTLIBRARIES += aggregation.la
@@@ -1517,7 -1579,7 +1579,7 @@@ python_la_LDFLAGS = $(PLUGIN_LDFLAGS) $
  endif
  
  if HAVE_LIBMNL
 -EXTRA_LTLIBRARIES += libtaskstats.la
 +noinst_LTLIBRARIES += libtaskstats.la
  libtaskstats_la_SOURCES = \
        src/utils_taskstats.c \
        src/utils_taskstats.h
@@@ -1977,6 -2039,15 +2039,15 @@@ write_sensu_la_SOURCES = src/write_sens
  write_sensu_la_LDFLAGS = $(PLUGIN_LDFLAGS)
  endif
  
+ if BUILD_PLUGIN_WRITE_STACKDRIVER
+ pkglib_LTLIBRARIES += write_stackdriver.la
+ write_stackdriver_la_SOURCES = src/write_stackdriver.c
+ write_stackdriver_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ write_stackdriver_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+ write_stackdriver_la_LIBADD = libformat_stackdriver.la libgce.la liboauth.la \
+                      $(BUILD_WITH_LIBCURL_LIBS)
+ endif
  if BUILD_PLUGIN_WRITE_TSDB
  pkglib_LTLIBRARIES += write_tsdb.la
  write_tsdb_la_SOURCES = src/write_tsdb.c
diff --combined src/collectd.conf.pod
@@@ -9106,40 -9106,6 +9106,40 @@@ only on the host system
  
  Only I<Connection> is required.
  
 +Consider the following example config:
 +
 + <Plugin "virt">
 +   Connection "qemu:///system"
 +   HostnameFormat "hostname"
 +   InterfaceFormat "address"
 +   PluginInstanceFormat "name"
 + </Plugin>
 +
 +It will generate the following values:
 +
 +  node42.example.com/virt-instance-0006f26c/disk_octets-vda
 +  node42.example.com/virt-instance-0006f26c/disk_ops-vda
 +  node42.example.com/virt-instance-0006f26c/if_dropped-ca:fe:ca:fe:ca:fe
 +  node42.example.com/virt-instance-0006f26c/if_errors-ca:fe:ca:fe:ca:fe
 +  node42.example.com/virt-instance-0006f26c/if_octets-ca:fe:ca:fe:ca:fe
 +  node42.example.com/virt-instance-0006f26c/if_packets-ca:fe:ca:fe:ca:fe
 +  node42.example.com/virt-instance-0006f26c/memory-actual_balloon
 +  node42.example.com/virt-instance-0006f26c/memory-available
 +  node42.example.com/virt-instance-0006f26c/memory-last_update
 +  node42.example.com/virt-instance-0006f26c/memory-major_fault
 +  node42.example.com/virt-instance-0006f26c/memory-minor_fault
 +  node42.example.com/virt-instance-0006f26c/memory-rss
 +  node42.example.com/virt-instance-0006f26c/memory-swap_in
 +  node42.example.com/virt-instance-0006f26c/memory-swap_out
 +  node42.example.com/virt-instance-0006f26c/memory-total
 +  node42.example.com/virt-instance-0006f26c/memory-unused
 +  node42.example.com/virt-instance-0006f26c/memory-usable
 +  node42.example.com/virt-instance-0006f26c/virt_cpu_total
 +  node42.example.com/virt-instance-0006f26c/virt_vcpu-0
 +
 +You can get information on the metric's units from the online libvirt documentation.
 +For instance, I<virt_cpu_total> is in nanoseconds.
 +
  =over 4
  
  =item B<Connection> I<uri>
@@@ -9242,8 -9208,7 +9242,8 @@@ B<uuid> means use the guest's UUID. Thi
  same guest across migrations.
  
  B<hostname> means to use the global B<Hostname> setting, which is probably not
 -useful on its own because all guests will appear to have the same name.
 +useful on its own because all guests will appear to have the same name. This is
 +useful in conjunction with B<PluginInstanceFormat> though.
  
  You can also specify combinations of these fields. For example B<name uuid>
  means to concatenate the guest name and UUID (with a literal colon character
@@@ -10342,6 -10307,133 +10342,133 @@@ attribute for each metric being sent ou
  
  =back
  
+ =head2 Plugin C<write_stackdriver>
+ The C<write_stackdriver> plugin writes metrics to the
+ I<Google Stackdriver Monitoring> service.
+ This plugin supports two authentication methods: When configured, credentials
+ are read from the JSON credentials file specified with B<CredentialFile>.
+ Alternatively, when running on
+ I<Google Compute Engine> (GCE), an I<OAuth> token is retrieved from the
+ I<metadata server> and used to authenticate to GCM.
+ B<Synopsis:>
+  <Plugin write_stackdriver>
+    CredentialFile "/path/to/service_account.json"
+    <Resource "global">
+      Label "project_id" "monitored_project"
+    </Resource>
+  </Plugin>
+ =over 4
+ =item B<CredentialFile> I<file>
+ Path to a JSON credentials file holding the credentials for a GCP service
+ account.
+ If B<CredentialFile> is not specified, the plugin uses I<Application Default
+ Credentials>. That means which credentials are used depends on the environment:
+ =over 4
+ =item
+ The environment variable C<GOOGLE_APPLICATION_CREDENTIALS> is checked. If this
+ variable is specified it should point to a JSON file that defines the
+ credentials.
+ =item
+ The path C<${HOME}/.config/gcloud/application_default_credentials.json> is
+ checked. This where credentials used by the I<gcloud> command line utility are
+ stored. You can use C<gcloud auth application-default login> to create these
+ credentials.
+ Please note that these credentials are often of your personal account, not a
+ service account, and are therefore unfit to be used in a production
+ environment.
+ =item
+ When running on GCE, the built-in service account associated with the virtual
+ machine instance is used.
+ See also the B<Email> option below.
+ =back
+ =item B<Project> I<Project>
+ The I<Project ID> or the I<Project Number> of the I<Stackdriver Account>. The
+ I<Project ID> is a string identifying the GCP project, which you can chose
+ freely when creating a new project. The I<Project Number> is a 12-digit decimal
+ number. You can look up both on the I<Developer Console>.
+ This setting is optional. If not set, the project ID is read from the
+ credentials file or determined from the GCE's metadata service.
+ =item B<Email> I<Email> (GCE only)
+ Choses the GCE I<Service Account> used for authentication.
+ Each GCE instance has a C<default> I<Service Account> but may also be
+ associated with additional I<Service Accounts>. This is often used to restrict
+ the permissions of services running on the GCE instance to the required
+ minimum. The I<write_stackdriver plugin> requires the
+ C<https://www.googleapis.com/auth/monitoring> scope. When multiple I<Service
+ Accounts> are available, this option selects which one is used by
+ I<write_stackdriver plugin>.
+ =item B<Resource> I<ResourceType>
+ Configures the I<Monitored Resource> to use when storing metrics.
+ More information on I<Monitored Resources> and I<Monitored Resource Types> are
+ available at L<https://cloud.google.com/monitoring/api/resources>.
+ This block takes one string argument, the I<ResourceType>. Inside the block are
+ one or more B<Label> options which configure the resource labels.
+ This block is optional. The default value depends on the runtime environment:
+ on GCE, the C<gce_instance> resource type is used, otherwise the C<global>
+ resource type ist used:
+ =over 4
+ =item
+ B<On GCE>, defaults to the equivalent of this config:
+   <Resource "gce_instance">
+     Label "project_id" "<project_id>"
+     Label "instance_id" "<instance_id>"
+     Label "zone" "<zone>"
+   </Resource>
+ The values for I<project_id>, I<instance_id> and I<zone> are read from the GCE
+ metadata service.
+ =item
+ B<Elsewhere>, i.e. not on GCE, defaults to the equivalent of this config:
+   <Resource "global">
+     Label "project_id" "<Project>"
+   </Resource>
+ Where I<Project> refers to the value of the B<Project> option or the project ID
+ inferred from the B<CredentialFile>.
+ =back
+ =item B<Url> I<Url>
+ URL of the I<Stackdriver Monitoring> API. Defaults to
+ C<https://monitoring.googleapis.com/v3>.
+ =back
  =head2 Plugin C<xencpu>
  
  This plugin collects metrics of hardware CPU load for machine running Xen