From 79ce5d0c8171faae215ae9989b7d3ed35d22f18f Mon Sep 17 00:00:00 2001 From: Pavel Shpilev Date: Tue, 3 Jun 2014 16:56:31 +1000 Subject: [PATCH 1/5] Fixing elasticsearch plugin --- manifests/plugin/elasticsearch/install.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugin/elasticsearch/install.pp b/manifests/plugin/elasticsearch/install.pp index d06851a..05d5572 100644 --- a/manifests/plugin/elasticsearch/install.pp +++ b/manifests/plugin/elasticsearch/install.pp @@ -10,6 +10,6 @@ fail("No package defined for OS ${::operatingsystem}") } - ensure_packages($pkg) + ensure_packages([$pkg]) } From 51029e7951a3a66ffc39a3239f83b82093565eb2 Mon Sep 17 00:00:00 2001 From: Pavel Shpilev Date: Tue, 3 Jun 2014 16:56:56 +1000 Subject: [PATCH 2/5] Fixing Redis plugin --- manifests/plugin/redis/install.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugin/redis/install.pp b/manifests/plugin/redis/install.pp index ca8e10b..aff6a6e 100644 --- a/manifests/plugin/redis/install.pp +++ b/manifests/plugin/redis/install.pp @@ -10,6 +10,6 @@ fail("No package defined for OS ${::operatingsystem}") } - ensure_packages($pkg) + ensure_packages([$pkg]) } From 2dae4e23c25e29b3c8bece5c5c24c69e6e7064f7 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 4 Jun 2014 10:10:38 +1000 Subject: [PATCH 3/5] Working elasticsearch plugin configuration --- .../etc/collectd.d/{elasticsearch.conf => elasticsearch.conf.erb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename templates/Linux/opt/stackdriver/collectd/etc/collectd.d/{elasticsearch.conf => elasticsearch.conf.erb} (100%) diff --git a/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf b/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf.erb similarity index 100% rename from templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf rename to templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf.erb From 09eb41240120ccb5cf2a6cd1f47bae626903fe97 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 4 Jun 2014 10:47:24 +1000 Subject: [PATCH 4/5] More fixes to elasticsearch plugin configuration. --- README.md | 16 ++++++++++++---- manifests/plugin/elasticsearch.pp | 11 +++++++++++ manifests/plugin/elasticsearch/config.pp | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index db652bc..e5ce7fd 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ Values enclosed in () have an undef default and are optional. ### Redis -Configures the redis plugin on the local host running on port 6379. Note: this module requires hiredis-devel be available to the system. +Configures the redis plugin on the local host running on port 6379. +Note: this module requires hiredis-devel be available to the system. ```yaml stackdriver::plugin::redis::host: 'localhost' @@ -144,7 +145,8 @@ stackdriver::plugin::mongo::port: '27017' ### Postgresql -Configures the Postgreqsql plugin on the local host using UNIX domain sockets. Prerequisites for this plugin are documented on Stackdriver's [support site](http://feedback.stackdriver.com/knowledgebase/articles/232555-postgresql-plugin). +Configures the Postgreqsql plugin on the local host using UNIX domain sockets. +Prerequisites for this plugin are documented on Stackdriver's [support site](http://feedback.stackdriver.com/knowledgebase/articles/232555-postgresql-plugin). ```yaml stackdriver::plugin::postgres::user: 'stackdriver' @@ -176,7 +178,14 @@ stackdriver::plugin::apache::url: 'http://127.0.0.1/mod_status?auto' ### Elasticsearch -Configures the Elasticsearch plugin on the local host using port 9200. Prerequisites for this plugin are documented on Stackdriver's [support site](http://feedback.stackdriver.com/knowledgebase/articles/268555-elasticsearch-plugin). +Configures the Elasticsearch plugin on the local host using port 9200. +Host and Port settings are optional. +Prerequisites for this plugin are documented on Stackdriver's [support site](http://support.stackdriver.com/customer/portal/articles/1491778-elasticsearch-plugin). + +```yaml +stackdriver::plugin::elasticsearch::host: 'localhost' +stackdriver::plugin::elasticsearch::port: '9200' +``` ### RabbitMQ @@ -227,4 +236,3 @@ JAVA_OPTS="${JAVA_OPTS} -Djava.rmi.server.hostname=<%= @fqdn %>" * Stackdriver Website: [http://www.stackdriver.com](http://www.stackdriver.com) * Stackdriver Signup: [http://www.stackdriver.com/signup](http://www.stackdriver.com/signup) - diff --git a/manifests/plugin/elasticsearch.pp b/manifests/plugin/elasticsearch.pp index 9e550c6..40b35a8 100644 --- a/manifests/plugin/elasticsearch.pp +++ b/manifests/plugin/elasticsearch.pp @@ -17,6 +17,14 @@ # - Default - /opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf # - Plugin configuration file # +# [*host*] +# - Default - localhost +# - Target host +# +# [*port*] +# - Default - 6379 +# - Target port +# # === Usage # --- # @@ -43,6 +51,9 @@ $config = '/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf', + $host = 'localhost', + $port = 9200, + ) { if $pkg { validate_string ( $pkg ) } diff --git a/manifests/plugin/elasticsearch/config.pp b/manifests/plugin/elasticsearch/config.pp index 5130fd0..4694e03 100644 --- a/manifests/plugin/elasticsearch/config.pp +++ b/manifests/plugin/elasticsearch/config.pp @@ -8,7 +8,7 @@ file { $config: ensure => file, - source => "puppet:///modules/stackdriver/${::kernel}/${config}", + content => template("stackdriver/${::kernel}/${config}.erb"), owner => 'root', group => 'root', mode => '0444', From 042210896b8ff7eb5ad1aa8c5156983c8a32fe12 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 4 Jun 2014 11:15:17 +1000 Subject: [PATCH 5/5] Adding memcahed plugin. Updating elasticsearch template. --- CONTRIBUTORS.md | 3 ++ README.md | 9 ++++ manifests/plugin/memcached.pp | 53 +++++++++++++++++++ manifests/plugin/memcached/config.pp | 19 +++++++ .../etc/collectd.d/elasticsearch.conf.erb | 16 +++--- .../etc/collectd.d/memcached.conf.erb | 5 ++ 6 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 manifests/plugin/memcached.pp create mode 100644 manifests/plugin/memcached/config.pp create mode 100644 templates/Linux/opt/stackdriver/collectd/etc/collectd.d/memcached.conf.erb diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index b83996c..6b47cf1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -30,4 +30,7 @@ In chronological order: * Hiera support * Windows support +* Pav Shpilev + * Code restructure & bugfixes + * Memcached plugin support diff --git a/README.md b/README.md index e5ce7fd..2d359f0 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,15 @@ stackdriver::plugin::redis::port: '6379' stackdriver::plugin::redis::timeout: '2000' ``` +### Memcached + +Configures the memcahed plugin on the local host running on port 11211. +All settings are optional. + +```yaml +stackdriver::plugin::memcahed::host: 'localhost' +stackdriver::plugin::memcahed::port: '11211' +``` ### MongoDB diff --git a/manifests/plugin/memcached.pp b/manifests/plugin/memcached.pp new file mode 100644 index 0000000..00340e3 --- /dev/null +++ b/manifests/plugin/memcached.pp @@ -0,0 +1,53 @@ +# vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 foldmethod=marker +# +# == Class: stackdriver::plugin::memcached +# +# Enable Memcached Agent Plugin for Stackdriver Agent +# +# === Parameters +# --- +# +# [*conf*] +# - Default - /opt/stackdriver/collectd/etc/collectd.d/memcached.conf +# - Plugin configuration file +# +# [*host*] +# - Default - localhost +# - Target host +# +# [*port*] +# - Default - 11211 +# - Target port +# +# +# === Usage +# --- +# +# ==== Puppet Code +# +# Enable Memcached plugin via Puppet CODE: +# +# include '::stackdriver::plugin::memcached' +# +# ==== Hiera +# +# Enable Memcached plugin via Hiera: +# +# stackdriver::plugins: +# - 'memcached' +# +class stackdriver::plugin::memcached( + + $config = '/opt/stackdriver/collectd/etc/collectd.d/memcached.conf', + $host = 'localhost', + $port = 11211, + +) { + + validate_string ( $config ) + validate_string ( $host ) + + contain "${name}::config" + +} + diff --git a/manifests/plugin/memcached/config.pp b/manifests/plugin/memcached/config.pp new file mode 100644 index 0000000..1731000 --- /dev/null +++ b/manifests/plugin/memcached/config.pp @@ -0,0 +1,19 @@ +# vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 foldmethod=marker +# +# == Class: stackdriver::plugin::memcached::config +# +# Configures Memcached Agent Plugin for Stackdriver Agent +# +class stackdriver::plugin::memcached::config inherits stackdriver::plugin::memcached { + + file { $config: + ensure => file, + content => template("stackdriver/${::kernel}/${config}.erb"), + owner => 'root', + group => 'root', + mode => '0444', + notify => Service[$::stackdriver::svc], + } + +} + diff --git a/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf.erb b/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf.erb index 6c91b84..22f056a 100644 --- a/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf.erb +++ b/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf.erb @@ -15,7 +15,7 @@ LoadPlugin target_set LoadPlugin "curl_json" - +:<%= @port %>/_nodes/_local/stats/"> Instance "elasticsearch" Type "gauge" @@ -32,13 +32,13 @@ LoadPlugin "curl_json" Type "counter" - - Type "counter" - - - Type "counter" - - + + Type "counter" + + + Type "counter" + + Type "counter" diff --git a/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/memcached.conf.erb b/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/memcached.conf.erb new file mode 100644 index 0000000..002e50f --- /dev/null +++ b/templates/Linux/opt/stackdriver/collectd/etc/collectd.d/memcached.conf.erb @@ -0,0 +1,5 @@ +LoadPlugin "memcached" + + Host "<%= @host %>" + Port "<%= @port %>" +