Skip to content

Commit 0eb44b3

Browse files
authored
Merge pull request #168 from elainemccloskey/SUP-2736
(SUP-2736) Add puppet string documentation
2 parents 3bfa451 + fd523d7 commit 0eb44b3

File tree

15 files changed

+212
-133
lines changed

15 files changed

+212
-133
lines changed

1

Lines changed: 0 additions & 65 deletions
This file was deleted.

manifests/collect.pp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
# Create systemd units for collecting a given metric
1+
#
2+
# @summary
3+
# Creates systemd units for collecting a given metric
4+
#
25
define puppet_metrics_collector::collect (
36
String $metrics_type = $title,
47
String $metrics_command = undef,
58
String $tidy_command = undef,
69
String $metric_ensure = 'present',
710
String $minute = '5',
811
) {
9-
1012
$service_ensure = $metric_ensure ? {
1113
'present' => running,
1214
'absent' => stopped,
@@ -17,26 +19,26 @@
1719
'absent' => false,
1820
}
1921

20-
file {"/etc/systemd/system/puppet_${metrics_type}-metrics.service":
22+
file { "/etc/systemd/system/puppet_${metrics_type}-metrics.service":
2123
ensure => $metric_ensure,
2224
content => epp('puppet_metrics_collector/service.epp',
2325
{ 'service' => "puppet_${metrics_type}", 'metrics_command' => $metrics_command }
2426
),
2527
}
26-
file {"/etc/systemd/system/puppet_${metrics_type}-metrics.timer":
28+
file { "/etc/systemd/system/puppet_${metrics_type}-metrics.timer":
2729
ensure => $metric_ensure,
2830
content => epp('puppet_metrics_collector/timer.epp',
2931
{ 'service' => "puppet_${metrics_type}", 'minute' => $minute },
3032
),
3133
}
3234

33-
file {"/etc/systemd/system/puppet_${metrics_type}-tidy.service":
35+
file { "/etc/systemd/system/puppet_${metrics_type}-tidy.service":
3436
ensure => $metric_ensure,
3537
content => epp('puppet_metrics_collector/tidy.epp',
3638
{ 'service' => "puppet_${metrics_type}", 'tidy_command' => $tidy_command }
3739
),
3840
}
39-
file {"/etc/systemd/system/puppet_${metrics_type}-tidy.timer":
41+
file { "/etc/systemd/system/puppet_${metrics_type}-tidy.timer":
4042
ensure => $metric_ensure,
4143
content => epp('puppet_metrics_collector/tidy_timer.epp',
4244
{ 'service' => "puppet_${metrics_type}" }

manifests/init.pp

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,76 @@
1-
# Collect Metrics
1+
# @summary
2+
# This module manages the collection of Puppet and system Metrics
3+
#
4+
# @param puppetserver_metrics_ensure
5+
# Whether to enable or disable the collection of Puppetserver metrics. Valid values are 'present', and 'absent'. Default : 'present'
6+
#
7+
# @param output_dir
8+
# The directory to write the metrics to. Default: '/opt/puppetlabs/puppet-metrics-collector'
9+
#
10+
# @param collection_frequency
11+
# The frequency to collect metrics in minutes. Default: '5'
12+
#
13+
# @param retention_days
14+
# The number of days to retain metrics. Default: '90'
15+
#
16+
# @param puppetserver_hosts
17+
# The list of puppetserver hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the puppetserver profile.
18+
#
19+
# @param puppetserver_port
20+
# Port to connect to puppetserver on. Default: '8140'
21+
#
22+
# @param puppetdb_metrics_ensure
23+
# Whether to enable or disable the collection of PuppetDB metrics. Valid values are 'present', and 'absent'. Default : 'present'
24+
#
25+
# @param puppetdb_hosts
26+
# The list of puppetdb hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the puppetdb profile.
27+
#
28+
# @param puppetdb_port
29+
# Port to connect to puppetdb on. Default: '8081'
30+
#
31+
# @param orchestrator_metrics_ensure
32+
# Whether to enable or disable the collection of Orchestrator metrics. Valid values are 'present', and 'absent'. Default : 'present'
33+
#
34+
# @param orchestrator_hosts
35+
# The list of orchestrator hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the orchestrator profile.
36+
#
37+
# @param orchestrator_port
38+
# Port to connect to orchestrator on. Default: '8143'
39+
#
40+
# @param ace_metrics_ensure
41+
# Whether to enable or disable the collection of Ace metrics. Valid values are 'present', and 'absent'. Default : 'present'
42+
#
43+
# @param ace_hosts
44+
# The list of ace hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the ace profile.
45+
#
46+
# @param ace_port
47+
# Port to connect to ace on. Default: '44633'
48+
#
49+
# @param bolt_metrics_ensure
50+
# Whether to enable or disable the collection of Bolt metrics. Valid values are 'present', and 'absent'. Default : 'present'
51+
#
52+
# @param bolt_hosts
53+
# The list of bolt hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the bolt profile.
54+
#
55+
# @param bolt_port
56+
# Port to connect to bolt on. Default: '62658'
57+
#
58+
# @param metrics_server_type
59+
# Optional Enum['influxdb','graphite','splunk_hec']: The metrics server type to send data to. Default: undef
60+
#
61+
# @ param metrics_server_hostname
62+
# Optional String: The hostname of the metrics server to send data to. Default: undef
63+
#
64+
# @ param metrics_server_port
65+
# Optional Integer: The port number of the metrics server to send data to. Default: undef
66+
#
67+
# @param metrics_server_db_name
68+
# Optional String: The database name on the metrics server to send data to.
69+
# Required for metrics_server_type of influxdb. Default: undef
70+
#
71+
# @param override_metrics_command
72+
# Optional String: Allows you to define the command that is executed to gather metrics. Default: undef
73+
#
274
class puppet_metrics_collector (
375
String $puppetserver_metrics_ensure = 'present',
476
String $output_dir = '/opt/puppetlabs/puppet-metrics-collector',
@@ -48,13 +120,13 @@
48120
file { "${scripts_dir}/create-metrics-archive":
49121
ensure => file,
50122
mode => '0755',
51-
source => 'puppet:///modules/puppet_metrics_collector/create-metrics-archive'
123+
source => 'puppet:///modules/puppet_metrics_collector/create-metrics-archive',
52124
}
53125

54126
file { "${scripts_dir}/metrics_tidy":
55127
ensure => file,
56128
mode => '0744',
57-
source => 'puppet:///modules/puppet_metrics_collector/metrics_tidy'
129+
source => 'puppet:///modules/puppet_metrics_collector/metrics_tidy',
58130
}
59131
}
60132

@@ -65,25 +137,25 @@
65137
file { "${scripts_dir}/json2timeseriesdb" :
66138
ensure => file,
67139
mode => '0755',
68-
source => 'puppet:///modules/puppet_metrics_collector/json2timeseriesdb'
140+
source => 'puppet:///modules/puppet_metrics_collector/json2timeseriesdb',
69141
}
70142

71143
file { "${scripts_dir}/pe_metrics.rb" :
72144
ensure => file,
73145
mode => '0755',
74-
source => 'puppet:///modules/puppet_metrics_collector/pe_metrics.rb'
146+
source => 'puppet:///modules/puppet_metrics_collector/pe_metrics.rb',
75147
}
76148

77149
file { "${scripts_dir}/puma_metrics" :
78150
ensure => file,
79151
mode => '0755',
80-
source => 'puppet:///modules/puppet_metrics_collector/puma_metrics'
152+
source => 'puppet:///modules/puppet_metrics_collector/puma_metrics',
81153
}
82154

83155
file { "${scripts_dir}/tk_metrics" :
84156
ensure => file,
85157
mode => '0755',
86-
source => 'puppet:///modules/puppet_metrics_collector/tk_metrics'
158+
source => 'puppet:///modules/puppet_metrics_collector/tk_metrics',
87159
}
88160

89161
exec { 'puppet_metrics_collector_daemon_reload':

manifests/sar_metric.pp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
# Collect System Metrics
1+
#
2+
# @summary
3+
# This class manages the collections of SAR metrics
4+
#
5+
# @param collection_frequency
6+
# The frequency to collect metrics in minutes. Default: '5'
7+
#
8+
# @param retention_days
9+
# The number of days to retain metrics. Default: '90'
10+
#
11+
# @param polling_frequency_seconds
12+
# How often the target is requested to provide data, in seconds. Default: 1
13+
#
14+
# @param cron_minute
15+
# The minute to run the cron job. Default: '0/5'
16+
#
217
define puppet_metrics_collector::sar_metric (
318
String $metrics_type = $title,
419
Enum['absent', 'present'] $metric_ensure = 'present',
@@ -9,7 +24,6 @@
924
String $metric_script_file = 'system_metrics',
1025
String $metrics_shipping_command = $puppet_metrics_collector::system::metrics_shipping_command,
1126
) {
12-
1327
$metrics_output_dir = "${puppet_metrics_collector::system::output_dir}/${metrics_type}"
1428

1529
$metrics_output_dir_ensure = $metric_ensure ? {
@@ -27,11 +41,11 @@
2741
$file_interval_seconds = $collection_frequency * 60
2842

2943
$base_metrics_command = join([$metric_script_file_path,
30-
"--metric_type ${metrics_type}",
31-
"--file_interval ${file_interval_seconds}",
32-
"--polling_interval ${polling_frequency_seconds}",
33-
"--metrics_dir ${puppet_metrics_collector::system::output_dir}",
34-
], ' ')
44+
"--metric_type ${metrics_type}",
45+
"--file_interval ${file_interval_seconds}",
46+
"--polling_interval ${polling_frequency_seconds}",
47+
"--metrics_dir ${puppet_metrics_collector::system::output_dir}",
48+
], ' ')
3549

3650
$metrics_command = "${base_metrics_command} ${metrics_shipping_command} > /dev/null"
3751

@@ -41,7 +55,7 @@
4155

4256
$tidy_command = "${puppet_metrics_collector::system::scripts_dir}/metrics_tidy -d ${metrics_output_dir} -r ${retention_days}"
4357

44-
puppet_metrics_collector::collect {$metrics_type:
58+
puppet_metrics_collector::collect { $metrics_type:
4559
metrics_command => $metrics_command,
4660
tidy_command => $tidy_command,
4761
metric_ensure => $metric_ensure,

manifests/service/ace.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Collect Service Metrics
1+
# @summary Collects ace metrics
2+
#
3+
# @api private
4+
#
25
class puppet_metrics_collector::service::ace (
36
String $metrics_ensure = $puppet_metrics_collector::ace_metrics_ensure,
47
Integer $collection_frequency = $puppet_metrics_collector::collection_frequency,
@@ -12,7 +15,7 @@
1215
Optional[String] $metrics_server_hostname = $puppet_metrics_collector::metrics_server_hostname,
1316
Optional[Integer] $metrics_server_port = $puppet_metrics_collector::metrics_server_port,
1417
Optional[String] $metrics_server_db_name = $puppet_metrics_collector::metrics_server_db_name,
15-
) {
18+
) {
1619
puppet_metrics_collector::pe_metric { 'ace' :
1720
metric_ensure => $metrics_ensure,
1821
cron_minute => "0/${collection_frequency}",

manifests/service/bolt.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Collect Service Metrics
1+
# @summary Collects bolt metrics
2+
#
3+
# @api private
4+
#
25
class puppet_metrics_collector::service::bolt (
36
String $metrics_ensure = $puppet_metrics_collector::bolt_metrics_ensure,
47
Integer $collection_frequency = $puppet_metrics_collector::collection_frequency,
@@ -12,7 +15,7 @@
1215
Optional[String] $metrics_server_hostname = $puppet_metrics_collector::metrics_server_hostname,
1316
Optional[Integer] $metrics_server_port = $puppet_metrics_collector::metrics_server_port,
1417
Optional[String] $metrics_server_db_name = $puppet_metrics_collector::metrics_server_db_name,
15-
) {
18+
) {
1619
puppet_metrics_collector::pe_metric { 'bolt' :
1720
metric_ensure => $metrics_ensure,
1821
cron_minute => "0/${collection_frequency}",

manifests/service/orchestrator.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Collect Service Metrics
1+
# @summary Collects orchestrator metrics
2+
#
3+
# @api private
4+
#
25
class puppet_metrics_collector::service::orchestrator (
36
String $metrics_ensure = $puppet_metrics_collector::orchestrator_metrics_ensure,
47
Integer $collection_frequency = $puppet_metrics_collector::collection_frequency,
@@ -12,7 +15,7 @@
1215
Optional[String] $metrics_server_hostname = $puppet_metrics_collector::metrics_server_hostname,
1316
Optional[Integer] $metrics_server_port = $puppet_metrics_collector::metrics_server_port,
1417
Optional[String] $metrics_server_db_name = $puppet_metrics_collector::metrics_server_db_name,
15-
) {
18+
) {
1619
puppet_metrics_collector::pe_metric { 'orchestrator' :
1720
metric_ensure => $metrics_ensure,
1821
cron_minute => "0/${collection_frequency}",

0 commit comments

Comments
 (0)