Skip to content

Commit 34c7f7a

Browse files
author
Jarret Lavallee
committed
(SUP-1969) Convert pe_metric to use shipping function
Prior to this commit, there was logic in pe_metric to determine the metric shipping information for the command in cron. This commit moves that logic out to the existing function.
1 parent bc68c76 commit 34c7f7a

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

manifests/pe_metric.pp

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,44 +62,25 @@
6262
}
6363

6464
$metric_script_file_path = "${puppet_metrics_collector::scripts_dir}/${metric_script_file}"
65-
$conversion_script_file_path = "${puppet_metrics_collector::scripts_dir}/json2timeseriesdb"
6665

67-
# lint:ignore:140chars
6866
if empty($override_metrics_command) {
6967
$base_metrics_command = "${metric_script_file_path} --metrics_type ${metrics_type} --output_dir ${metrics_output_dir}"
68+
$metrics_shipping_command = puppet_metrics_collector::generate_metrics_server_command(
69+
$puppet_metrics_collector::scripts_dir,
70+
$metrics_server_type,
71+
$metrics_server_hostname,
72+
$metrics_server_db_name,
73+
$metrics_server_port
74+
)
7075

7176
if !empty($metrics_server_type) {
72-
$server_hostname = $metrics_server_hostname
73-
$server_port = $metrics_server_port
74-
$server_type = $metrics_server_type
75-
$server_db = $metrics_server_db_name
76-
77-
if empty($server_db) and $server_type == 'influxdb' {
78-
fail('When specifying an InfluxDB metrics server, you must specify a metrics server db_name')
79-
}
80-
81-
$conv_metrics_command = "${base_metrics_command} | ${conversion_script_file_path} --netcat ${server_hostname} --convert-to ${server_type} -"
82-
83-
$full_metrics_command = empty($server_port) ? {
84-
false => "${conv_metrics_command} --port ${server_port}",
85-
true => $conv_metrics_command,
86-
}
87-
88-
# We use only the base metrics command for the 'splunk_hec' metrics server type.
89-
90-
$metrics_command = $server_type ? {
91-
'influxdb' => "${full_metrics_command} --influx-db ${server_db} > /dev/null",
92-
'graphite' => "${full_metrics_command} > /dev/null",
93-
'splunk_hec' => "${base_metrics_command} | /opt/puppetlabs/bin/puppet splunk_hec --sourcetype puppet:metrics --pe_metrics > /dev/null",
94-
default => "${full_metrics_command} > /dev/null",
95-
}
77+
$metrics_command = "${base_metrics_command} ${metrics_shipping_command} > /dev/null"
9678
} else {
9779
$metrics_command = "${base_metrics_command} --no-print"
9880
}
9981
} else {
10082
$metrics_command = $override_metrics_command
10183
}
102-
# lint:endignore
10384

10485
$tidy_command = "${puppet_metrics_collector::scripts_dir}/metrics_tidy -d ${metrics_output_dir} -r ${retention_days}"
10586

0 commit comments

Comments
 (0)