Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/collectd exporter #272

Merged
merged 7 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This module automates the install and configuration of Prometheus monitoring too
* Installs a configuration file for prometheus daemon (/etc/prometheus/prometheus.yaml) or for alertmanager (/etc/prometheus/alert.rules)
* Manages the services via upstart, sysv, or systemd
* Optionally creates alert rules
* The following exporters are currently implemented: node_exporter, statsd_exporter, process_exporter, haproxy_exporter, mysqld_exporter, blackbox_exporter, consul_exporter, redis_exporter, varnish_exporter, graphite_exporter, postgres_exporter
* The following exporters are currently implemented: node_exporter, statsd_exporter, process_exporter, haproxy_exporter, mysqld_exporter, blackbox_exporter, consul_exporter, redis_exporter, varnish_exporter, graphite_exporter, postgres_exporter, collectd_exporter

## Usage

Expand Down
15 changes: 15 additions & 0 deletions data/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,18 @@ prometheus::graphite_exporter::manage_group: true
prometheus::graphite_exporter::manage_service: true
prometheus::graphite_exporter::manage_user: true
prometheus::graphite_exporter::options: ''
prometheus::collectd_exporter::download_extension: 'tar.gz'
prometheus::collectd_exporter::download_url_base: 'https://github.com/prometheus/collectd_exporter/releases'
prometheus::collectd_exporter::group: 'collectd-exporter'
prometheus::collectd_exporter::package_ensure: 'latest'
prometheus::collectd_exporter::package_name: 'collectd_exporter'
prometheus::collectd_exporter::user: 'collectd-exporter'
prometheus::collectd_exporter::version: '0.4.0'
prometheus::collectd_exporter::purge_config_dir: true
prometheus::collectd_exporter::restart_on_change: true
prometheus::collectd_exporter::service_enable: true
prometheus::collectd_exporter::service_ensure: 'running'
prometheus::collectd_exporter::manage_group: true
prometheus::collectd_exporter::manage_service: true
prometheus::collectd_exporter::manage_user: true
prometheus::collectd_exporter::options: ''
122 changes: 122 additions & 0 deletions manifests/collectd_exporter.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Class: prometheus::collectd_exporter
#
# This module manages prometheus node collectd_exporter
#
# Parameters:
# [*arch*]
# Architecture (amd64 or i386)
#
# [*bin_dir*]
# Directory where binaries are located
#
# [*download_extension*]
# Extension for the release binary archive
#
# [*download_url*]
# Complete URL corresponding to the where the release binary archive can be downloaded
#
# [*download_url_base*]
# Base URL for the binary archive
#
# [*options*]
# Options added to the startup command
#
# [*group*]
# Group under which the binary is running
#
# [*init_style*]
# Service startup scripts style (e.g. rc, upstart or systemd)
#
# [*install_method*]
# Installation method: url or package (only url is supported currently)
#
# [*manage_group*]
# Whether to create a group for or rely on external code for that
#
# [*manage_service*]
# Should puppet manage the service? (default true)
#
# [*manage_user*]
# Whether to create user or rely on external code for that
#
# [*os*]
# Operating system (linux is the only one supported)
#
# [*package_ensure*]
# If package, then use this for package ensure default 'latest'
#
# [*package_name*]
# The binary package name - not available yet
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*restart_on_change*]
# Should puppet restart the service on configuration change? (default true)
#
# [*service_enable*]
# Whether to enable the service from puppet (default true)
#
# [*service_ensure*]
# State ensured for the service (default 'running')
#
# [*user*]
# User which runs the service
#
# [*version*]
# The binary release version
#
class prometheus::collectd_exporter (
String $download_extension,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all strings, could you please switch to String[1]? That will enforce a minimal string length of one.

String $download_url_base,
String $group,
String $package_ensure,
String $package_name,
String $user,
String $version,
Boolean $purge_config_dir,
Boolean $restart_on_change,
Boolean $service_enable,
String $service_ensure,
Boolean $manage_group,
Boolean $manage_service,
Boolean $manage_user,
String $options,
String $os = $prometheus::os,
String $init_style = $prometheus::init_style,
String $install_method = $prometheus::install_method,
Optional[String] $download_url = undef,
String $arch = $prometheus::real_arch,
String $bin_dir = $prometheus::bin_dir,
) inherits prometheus {

$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

$notify_service = $restart_on_change ? {
true => Service['collectd_exporter'],
default => undef,
}

prometheus::daemon { 'collectd_exporter':
install_method => $install_method,
version => $version,
download_extension => $download_extension,
os => $os,
arch => $arch,
real_download_url => $real_download_url,
bin_dir => $bin_dir,
notify_service => $notify_service,
package_name => $package_name,
package_ensure => $package_ensure,
manage_user => $manage_user,
user => $user,
group => $group,
manage_group => $manage_group,
purge => $purge_config_dir,
options => $options,
init_style => $init_style,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
}
}
30 changes: 30 additions & 0 deletions spec/classes/collectd_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

describe 'prometheus::collectd_exporter' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(os_specific_facts(facts))
end

context 'without parameters' do
it { is_expected.to contain_prometheus__daemon('collectd_exporter') }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_group('collectd-exporter') }
it { is_expected.to contain_service('collectd_exporter') }
it { is_expected.to contain_user('collectd-exporter') }
it { is_expected.to contain_class('prometheus') }
end

context 'with params' do
let :params do
{
install_method: 'url'
}
end

it { is_expected.to contain_archive('/tmp/collectd_exporter-0.4.0.tar.gz') }
end
end
end
end