Skip to content

Commit

Permalink
process-exporter (voxpupuli#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
NairolfL authored and brutus333 committed Mar 13, 2017
1 parent 8765439 commit fdaedde
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 0 deletions.
9 changes: 9 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
$haproxy_exporter_package_name = 'haproxy_exporter'
$haproxy_exporter_user = 'haproxy-user'
$haproxy_exporter_version = '0.7.1'
$process_exporter_download_extension = 'tar.gz'
$process_exporter_download_url_base = 'https://github.com/ncabatoff/process-exporter/releases'
$process_exporter_extra_groups = []
$process_exporter_group = 'process-exporter'
$process_exporter_package_ensure = 'latest'
$process_exporter_package_name = 'process-exporter'
$process_exporter_user = 'process-exporter'
$process_exporter_version = '0.1.0'
$process_exporter_config_path = '/etc/process-exporter.yaml'
$mysqld_exporter_cnf_config_path = '/etc/.my.cnf'
$mysqld_exporter_cnf_host = 'localhost'
$mysqld_exporter_cnf_password = 'password'
Expand Down
144 changes: 144 additions & 0 deletions manifests/process_exporter.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Class: prometheus::process_exporter
#
# This module manages prometheus process_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
#
# [*extra_groups*]
# Extra groups to add the binary user to
#
# [*extra_options*]
# Extra 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::process_exporter(
$arch = $::prometheus::params::arch,
$bin_dir = $::prometheus::params::bin_dir,
$download_extension = $::prometheus::params::process_exporter_download_extension,
$download_url = undef,
$download_url_base = $::prometheus::params::process_exporter_download_url_base,
$extra_groups = $::prometheus::params::process_exporter_extra_groups,
$extra_options = '',
$config_mode = $::prometheus::params::config_mode,
$group = $::prometheus::params::process_exporter_group,
$init_style = $::prometheus::params::init_style,
$install_method = $::prometheus::params::install_method,
$manage_group = true,
$manage_service = true,
$manage_user = true,
$os = $::prometheus::params::os,
$package_ensure = $::prometheus::params::process_exporter_package_ensure,
$package_name = $::prometheus::params::process_exporter_package_name,
$purge_config_dir = true,
$restart_on_change = true,
$service_enable = true,
$service_ensure = 'running',
$user = $::prometheus::params::process_exporter_user,
$version = $::prometheus::params::process_exporter_version,
$config_path = $::prometheus::params::process_exporter_config_path,
$watched_processes = []
) inherits prometheus::params {

$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
validate_bool($purge_config_dir)
validate_bool($manage_user)
validate_bool($manage_service)
validate_bool($restart_on_change)
$notify_service = $restart_on_change ? {
true => Service['process-exporter'],
default => undef,
}

file { $config_path:
ensure => 'file',
mode => $config_mode,
owner => $user,
group => $group,
content => template('prometheus/process-exporter.yaml.erb'),
notify => $notify_service,
}

$options = "-config.path=${config_path} ${extra_options}"

prometheus::daemon { 'process-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,
extra_groups => $extra_groups,
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,
}

}
2 changes: 2 additions & 0 deletions templates/process-exporter.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<% require 'yaml' -%>
<%= {"process_names" => @watched_processes}.to_yaml %>

0 comments on commit fdaedde

Please sign in to comment.