|
62 | 62 | } |
63 | 63 |
|
64 | 64 | $metric_script_file_path = "${puppet_metrics_collector::scripts_dir}/${metric_script_file}" |
65 | | - $conversion_script_file_path = "${puppet_metrics_collector::scripts_dir}/json2timeseriesdb" |
66 | 65 |
|
67 | | - # lint:ignore:140chars |
68 | 66 | if empty($override_metrics_command) { |
69 | 67 | $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 | + ) |
70 | 75 |
|
71 | 76 | 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" |
96 | 78 | } else { |
97 | 79 | $metrics_command = "${base_metrics_command} --no-print" |
98 | 80 | } |
99 | 81 | } else { |
100 | 82 | $metrics_command = $override_metrics_command |
101 | 83 | } |
102 | | - # lint:endignore |
103 | 84 |
|
104 | 85 | $tidy_command = "${puppet_metrics_collector::scripts_dir}/metrics_tidy -d ${metrics_output_dir} -r ${retention_days}" |
105 | 86 |
|
|
0 commit comments