add support for collectd
authorLars Kellogg-Stedman <lars@redhat.com>
Thu, 15 Dec 2016 03:07:26 +0000 (22:07 -0500)
committerLars Kellogg-Stedman <lars@redhat.com>
Fri, 16 Dec 2016 16:30:06 +0000 (11:30 -0500)
This is the glue between the collectd composable service in
tripleo-heat-templates and the puppet-collectd module.

Change-Id: I7e899e3af870b04dcd45503bd322278997fa53d0

manifests/profile/base/metrics/collectd.pp [new file with mode: 0644]
manifests/profile/base/metrics/collectd/plugin_helper.pp [new file with mode: 0644]

diff --git a/manifests/profile/base/metrics/collectd.pp b/manifests/profile/base/metrics/collectd.pp
new file mode 100644 (file)
index 0000000..0f738d1
--- /dev/null
@@ -0,0 +1,88 @@
+# == Class: tripleo::profile::base::metrics::collectd
+#
+# Collectd configuration for TripleO
+#
+# === Parameters
+#
+# [*collectd_plugins*]
+#   (Optional) List. A list of collectd plugins to configure (the
+#   corresponding collectd::plugin::NAME class must exist in the
+#   collectd package).
+#
+# [*collectd_server*]
+#   (Optional) String. The name or address of a collectd server to
+#   which we should send metrics.
+#
+# [*collectd_port*]
+#   (Optional) Integer. The port to which we will connect on the
+#   collectd server.
+#
+# [*collectd_username*]
+#   (Optional) String.  Username for authenticating to the remote
+#   collectd server.
+#
+# [*collectd_password*]
+#   (Optional) String. Password for authenticating to the remote
+#   collectd server.
+#
+# [*collectd_securitylevel*]
+#   (Optional) String.
+#
+# [*collectd_interface*]
+#   (Optional) String. Name of a network interface.
+#
+# [*collectd_graphite_server*]
+#   (Optional) String. The name or address of a graphite server to
+#   which we should send metrics.
+#
+# [*collectd_graphite_port*]
+#   (Optional) Integer.  This is the port to which we will connect on
+#   the graphite server. Defaults to 2004.
+#
+# [*collectd_graphite_prefix*]
+#   (Optional) String. Prefix to add to metric names. Defaults to
+#   'overcloud.'.
+#
+# [*collectd_graphite_protocol*]
+#   (Optional) String. One of 'udp' or 'tcp'.
+#
+class tripleo::profile::base::metrics::collectd (
+  $collectd_plugins = [],
+
+  $collectd_server = undef,
+  $collectd_port = 25826,
+  $collectd_username = undef,
+  $collectd_password = undef,
+  $collectd_securitylevel = undef,
+
+  $collectd_graphite_server = undef,
+  $collectd_graphite_port = 2004,
+  $collectd_graphite_prefix = undef,
+  $collectd_graphite_protocol = 'udp'
+) {
+  include ::collectd
+  ::tripleo::profile::base::metrics::collectd::plugin_helper { $collectd_plugins: }
+
+  if ! ($collectd_graphite_protocol in ['udp', 'tcp']) {
+    fail("collectd_graphite_protocol must be one of 'udp' or 'tcp'")
+  }
+
+  if $collectd_server {
+    ::collectd::plugin::network::server { $collectd_server:
+      username      => $collectd_username,
+      password      => $collectd_password,
+      port          => $collectd_port,
+      securitylevel => $collectd_securitylevel,
+    }
+  }
+
+  if $collectd_graphite_server {
+    ::collectd::plugin::write_graphite::carbon { 'openstack_graphite':
+      graphitehost   => $collectd_graphite_server,
+      graphiteport   => $collectd_graphite_port,
+      graphiteprefix => $collectd_graphite_prefix,
+      protocol       => $collectd_graphite_protocol,
+    }
+  }
+}
+
diff --git a/manifests/profile/base/metrics/collectd/plugin_helper.pp b/manifests/profile/base/metrics/collectd/plugin_helper.pp
new file mode 100644 (file)
index 0000000..b624ee1
--- /dev/null
@@ -0,0 +1,6 @@
+# We use this to transform a list of unqualified plugin names
+# (like ['disk', 'ntpd']) into the correct collectd plugin classes.
+define tripleo::profile::base::metrics::collectd::plugin_helper (
+) {
+  include "collectd::plugin::${title}"
+}